|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.client.gui.ImageLibrary
public final class ImageLibrary
Holds various images that can be called upon by others in order to display certain things.
| Field Summary | |
|---|---|
private java.util.EnumMap<Tension.Level,java.awt.Image> |
alarmChips
|
private java.util.EnumMap<Tension.Level,java.awt.Image> |
alarmChipsUnvisited
|
static int |
BEACH_STYLES
|
private static java.lang.String |
beachDirectory
|
private java.util.List<javax.swing.ImageIcon> |
beaches
|
private static java.lang.String |
beachName
|
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> |
border1
|
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> |
border2
|
private static java.lang.String |
borderName
|
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> |
coast1
|
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> |
coast2
|
private java.util.Map<java.awt.Color,java.awt.Image> |
colorChips
|
static java.lang.String |
DARKNESS
|
private java.lang.String |
dataDirectory
|
static java.lang.String |
DELETE
|
private static java.lang.String |
deltaName
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
deltas
|
private java.util.Map<java.awt.Color,java.awt.Image> |
expertMissionChips
|
private static java.lang.String |
extension
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
forests
|
private static java.lang.String |
large
|
private static java.util.logging.Logger |
logger
|
static java.lang.String |
LOST_CITY_RUMOUR
|
private java.util.Map<java.awt.Color,java.awt.Image> |
missionChips
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
overlay1
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
overlay2
|
private static java.lang.String |
path
|
static java.lang.String |
PLOWED
|
static int |
RIVER_STYLES
|
private static java.lang.String |
riverDirectory
|
private static java.lang.String |
riverName
|
private java.util.List<javax.swing.ImageIcon> |
rivers
A ArrayList of Image objects. |
private float |
scalingFactor
The scaling factor used when creating this ImageLibrary. |
private static java.lang.String |
small
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
terrain1
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
terrain2
|
private static java.lang.String |
terrainDirectory
|
static java.lang.String |
TILE_OWNED_BY_INDIANS
|
static java.lang.String |
TILE_TAKEN
|
private static java.lang.String |
tileName
|
private static java.lang.String |
unexploredDirectory
|
private static java.lang.String |
unexploredName
|
static java.lang.String |
UNIT_SELECT
|
| Constructor Summary | |
|---|---|
|
ImageLibrary()
The constructor to use. |
|
ImageLibrary(java.lang.String freeColHome)
A constructor that takes a directory as FreeCol's home. |
private |
ImageLibrary(java.lang.String dataDirectory,
float scalingFactor)
|
| Method Summary | |
|---|---|
private javax.swing.ImageIcon |
findImage(java.lang.String filePath,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Finds the image file in the given filePath. |
java.awt.Image |
getAlarmChip(Tension.Level alarm,
boolean visited)
Returns the alarm chip with the given color. |
java.awt.Image |
getBeachImage(int index)
Returns the beach image at the given index. |
java.awt.Image |
getBonusImage(ResourceType type)
|
java.awt.Image |
getBonusImage(Tile tile)
Returns the bonus-image for the given tile. |
javax.swing.ImageIcon |
getBonusImageIcon(ResourceType type)
Returns the bonus-ImageIcon at the given index. |
java.awt.Image |
getBorderImage(TileType type,
Map.Direction direction,
int x,
int y)
Returns the border terrain-image for the given type. |
java.awt.Image |
getCoastImage(TileType type,
Map.Direction direction,
int x,
int y)
Returns the coast terrain-image for the given type. |
java.awt.Image |
getCoatOfArmsImage(Nation nation)
Returns the coat-of-arms image for the given Nation. |
javax.swing.ImageIcon |
getCoatOfArmsImageIcon(Nation nation)
Returns the coat-of-arms image for the given Nation. |
java.awt.Image |
getColorChip(java.awt.Color color)
Returns the color chip with the given color. |
int |
getCompoundTerrainImageHeight(TileType type)
Returns the height of the terrain-image including overlays and forests for the given terrain type. |
java.awt.Image |
getForestImage(TileType type)
Returns the forest image for a terrain type. |
java.awt.Image |
getFoundingFatherImage(FoundingFather father)
Returns the portrait of this Founding Father. |
java.awt.Image |
getGoodsImage(GoodsType goodsType)
Returns the goods-image at the given index. |
javax.swing.ImageIcon |
getGoodsImageIcon(GoodsType goodsType)
Returns the goods-image for a goods type. |
java.awt.Image |
getMiscImage(java.lang.String id)
Returns the image with the given id. |
javax.swing.ImageIcon |
getMiscImageIcon(java.lang.String id)
Returns the image with the given id. |
java.awt.Image |
getMissionChip(java.awt.Color color,
boolean expertMission)
Returns the mission chip with the given color. |
java.awt.Image |
getMonarchImage(Nation nation)
Returns the monarch-image for the given tile. |
javax.swing.ImageIcon |
getMonarchImageIcon(Nation nation)
Returns the monarch-image icon for the given Nation. |
java.awt.Image |
getOverlayImage(TileType type,
int x,
int y)
Returns the overlay-image for the given type. |
java.awt.Image |
getRiverImage(int index)
Returns the river image at the given index. |
java.awt.Image |
getRiverMouthImage(Map.Direction direction,
int magnitude,
int x,
int y)
Returns the river mouth terrain-image for the direction and magnitude. |
javax.swing.ImageIcon |
getScaledBonusImageIcon(ResourceType type,
float scale)
|
javax.swing.ImageIcon |
getScaledGoodsImageIcon(GoodsType type,
float scale)
Returns the scaled goods-ImageIcon for a goods type. |
javax.swing.ImageIcon |
getScaledImageIcon(java.awt.Image image,
float scale)
Returns the scaled ImageIcon. |
javax.swing.ImageIcon |
getScaledImageIcon(javax.swing.ImageIcon inputIcon,
float scale)
Returns the scaled ImageIcon. |
ImageLibrary |
getScaledImageLibrary(float scalingFactor)
Gets a scaled version of this ImageLibrary. |
java.awt.Image |
getScaledTerrainImage(TileType type,
float scale)
Returns the scaled terrain-image for a terrain type (and position 0, 0). |
float |
getScalingFactor()
Returns the scaling factor used when creating this ImageLibrary. |
java.awt.Image |
getSettlementImage(Settlement.SettlementType settlementType)
Returns the graphics that will represent the given settlement. |
java.awt.Image |
getSettlementImage(Settlement settlement)
Returns the graphics that will represent the given settlement. |
java.awt.Image |
getTerrainImage(TileType type,
int x,
int y)
Returns the terrain-image for the given type. |
int |
getTerrainImageHeight(TileType type)
Returns the height of the terrain-image for a terrain type. |
int |
getTerrainImageWidth(TileType type)
Returns the width of the terrain-image for a terrain type. |
javax.swing.ImageIcon |
getUnitImageIcon(Unit unit)
Returns the ImageIcon that will represent the given unit. |
javax.swing.ImageIcon |
getUnitImageIcon(Unit unit,
boolean grayscale)
Returns the ImageIcon that will represent the given unit. |
javax.swing.ImageIcon |
getUnitImageIcon(UnitType unitType)
Returns the ImageIcon that will represent a unit of the given type. |
javax.swing.ImageIcon |
getUnitImageIcon(UnitType unitType,
boolean grayscale)
Returns the ImageIcon that will represent a unit of the given type. |
javax.swing.ImageIcon |
getUnitImageIcon(UnitType unitType,
Unit.Role role)
Returns the ImageIcon that will represent a unit of the given type and role. |
javax.swing.ImageIcon |
getUnitImageIcon(UnitType unitType,
Unit.Role role,
boolean grayscale)
Returns the ImageIcon that will represent a unit of the given type and role. |
void |
init()
Performs all necessary init operations such as loading of data files. |
private void |
loadAlarmChip(java.awt.GraphicsConfiguration gc,
Tension.Level alarm,
boolean visited)
Generates a alarm chip image and stores it in memory. |
private void |
loadBeaches(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Loads the beach images from file into memory. |
private void |
loadColorChip(java.awt.GraphicsConfiguration gc,
java.awt.Color c)
Generates a color chip image and stores it in memory. |
private void |
loadForests(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Loads the forest images from file into memory. |
private void |
loadMissionChip(java.awt.GraphicsConfiguration gc,
java.awt.Color c,
boolean expertMission)
Generates a mission chip image and stores it in memory. |
private void |
loadRiverMouths(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Loads the river mouth images from file into memory. |
private void |
loadRivers(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Loads the river images from file into memory. |
private void |
loadTerrain(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
Loads the terrain-images from file into memory. |
javax.swing.ImageIcon |
scaleIcon(javax.swing.ImageIcon icon,
float scale)
|
java.awt.Image |
scaleImage(java.awt.Image image,
float scale)
|
private java.util.ArrayList<javax.swing.ImageIcon> |
scaleImages(java.util.List<javax.swing.ImageIcon> input,
float scale)
|
private java.util.Map<java.lang.String,javax.swing.ImageIcon> |
scaleImages(java.util.Map<java.lang.String,javax.swing.ImageIcon> input,
float scale)
|
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> |
scaleImages2(java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> input,
float scale)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final int RIVER_STYLES
public static final int BEACH_STYLES
public static final java.lang.String UNIT_SELECT
public static final java.lang.String DELETE
public static final java.lang.String PLOWED
public static final java.lang.String TILE_TAKEN
public static final java.lang.String TILE_OWNED_BY_INDIANS
public static final java.lang.String LOST_CITY_RUMOUR
public static final java.lang.String DARKNESS
private static final java.lang.String path
private static final java.lang.String extension
private static final java.lang.String terrainDirectory
private static final java.lang.String beachDirectory
private static final java.lang.String beachName
private static final java.lang.String tileName
private static final java.lang.String borderName
private static final java.lang.String unexploredDirectory
private static final java.lang.String unexploredName
private static final java.lang.String riverDirectory
private static final java.lang.String riverName
private final java.lang.String dataDirectory
private static final java.lang.String deltaName
private static final java.lang.String small
private static final java.lang.String large
private java.util.List<javax.swing.ImageIcon> rivers
private java.util.List<javax.swing.ImageIcon> beaches
private java.util.Map<java.lang.String,javax.swing.ImageIcon> terrain1
private java.util.Map<java.lang.String,javax.swing.ImageIcon> terrain2
private java.util.Map<java.lang.String,javax.swing.ImageIcon> overlay1
private java.util.Map<java.lang.String,javax.swing.ImageIcon> overlay2
private java.util.Map<java.lang.String,javax.swing.ImageIcon> forests
private java.util.Map<java.lang.String,javax.swing.ImageIcon> deltas
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> border1
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> border2
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> coast1
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> coast2
private java.util.EnumMap<Tension.Level,java.awt.Image> alarmChips
private java.util.EnumMap<Tension.Level,java.awt.Image> alarmChipsUnvisited
private java.util.Map<java.awt.Color,java.awt.Image> colorChips
private java.util.Map<java.awt.Color,java.awt.Image> missionChips
private java.util.Map<java.awt.Color,java.awt.Image> expertMissionChips
private final float scalingFactor
ImageLibrary. The value
1 is used if this object is not
a result of a scaling operation.
| Constructor Detail |
|---|
public ImageLibrary()
throws FreeColException
FreeColException - If one of the data files could not be found.
public ImageLibrary(java.lang.String freeColHome)
throws FreeColException
freeColHome - The home of the freecol files.
FreeColException - If one of the data files could not be found.
private ImageLibrary(java.lang.String dataDirectory,
float scalingFactor)
| Method Detail |
|---|
public void init()
throws FreeColException
FreeColException - If one of the data files could not be found. *public float getScalingFactor()
getScaledImageLibrary(float) was used to create
this object.
public ImageLibrary getScaledImageLibrary(float scalingFactor)
throws FreeColException
ImageLibrary.
scalingFactor - The factor used when scaling. 2 is twice
the size of the original images and 0.5 is half.
ImageLibrary.
FreeColException
public java.awt.Image scaleImage(java.awt.Image image,
float scale)
public javax.swing.ImageIcon scaleIcon(javax.swing.ImageIcon icon,
float scale)
private java.util.Map<java.lang.String,javax.swing.ImageIcon> scaleImages(java.util.Map<java.lang.String,javax.swing.ImageIcon> input,
float scale)
private java.util.ArrayList<javax.swing.ImageIcon> scaleImages(java.util.List<javax.swing.ImageIcon> input,
float scale)
private java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> scaleImages2(java.util.Map<java.lang.String,java.util.ArrayList<javax.swing.ImageIcon>> input,
float scale)
private javax.swing.ImageIcon findImage(java.lang.String filePath,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
filePath.
filePath - The path to the image file.doLookup - If true then the resourceLocator
is used when searching for the image file.
FreeColException - If the image could not be found.
private void loadTerrain(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.resourceLocator - The class that is used to locate data files.doLookup - Must be set to 'false' if the path to the image files has
been manually provided by the user. If set to 'true' then a
lookup will be done to search for image files from
net.sf.freecol, in this case the images need to be placed in
net.sf.freecol/images.
FreeColException - If one of the data files could not be found.
private void loadBeaches(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.resourceLocator - The class that is used to locate data files.doLookup - Must be set to 'false' if the path to the image files has
been manually provided by the user. If set to 'true' then a
lookup will be done to search for image files from
net.sf.freecol, in this case the images need to be placed in
net.sf.freecol/images.
FreeColException - If one of the data files could not be found.
private void loadRivers(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.resourceLocator - The class that is used to locate data files.doLookup - Must be set to 'false' if the path to the image files has
been manually provided by the user. If set to 'true' then a
lookup will be done to search for image files from
net.sf.freecol, in this case the images need to be placed in
net.sf.freecol/images.
FreeColException - If one of the data files could not be found.
private void loadRiverMouths(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.resourceLocator - The class that is used to locate data files.doLookup - Must be set to 'false' if the path to the image files has
been manually provided by the user. If set to 'true' then a
lookup will be done to search for image files from
net.sf.freecol, in this case the images need to be placed in
net.sf.freecol/images.
FreeColException - If one of the data files could not be found.
private void loadForests(java.awt.GraphicsConfiguration gc,
java.lang.Class<FreeCol> resourceLocator,
boolean doLookup)
throws FreeColException
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.resourceLocator - The class that is used to locate data files.doLookup - Must be set to 'false' if the path to the image files has
been manually provided by the user. If set to 'true' then a
lookup will be done to search for image files from
net.sf.freecol, in this case the images need to be placed in
net.sf.freecol/images.
FreeColException - If one of the data files could not be found.
private void loadColorChip(java.awt.GraphicsConfiguration gc,
java.awt.Color c)
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.c - The color of the color chip to create.
private void loadMissionChip(java.awt.GraphicsConfiguration gc,
java.awt.Color c,
boolean expertMission)
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.c - The color of the color chip to create.expertMission - Should be true if the mission chip
should represent an expert missionary.
private void loadAlarmChip(java.awt.GraphicsConfiguration gc,
Tension.Level alarm,
boolean visited)
gc - The GraphicsConfiguration is needed to create images that are
compatible with the local environment.alarm - The alarm level.visited - whether the village was visited before.public java.awt.Image getFoundingFatherImage(FoundingFather father)
father - a FoundingFather value
Image valuepublic java.awt.Image getMonarchImage(Nation nation)
nation - The nation this monarch rules.
public javax.swing.ImageIcon getMonarchImageIcon(Nation nation)
nation - The nation this monarch rules.
public javax.swing.ImageIcon getCoatOfArmsImageIcon(Nation nation)
nation - The nation.
public java.awt.Image getCoatOfArmsImage(Nation nation)
nation - The nation.
public java.awt.Image getBonusImage(Tile tile)
tile -
public java.awt.Image getBonusImage(ResourceType type)
public javax.swing.ImageIcon getBonusImageIcon(ResourceType type)
type - The type of the bonus-ImageIcon to return.
public javax.swing.ImageIcon getScaledBonusImageIcon(ResourceType type,
float scale)
public java.awt.Image getScaledTerrainImage(TileType type,
float scale)
type - The type of the terrain-image to return.scale - The scale of the terrain image to return.
public java.awt.Image getOverlayImage(TileType type,
int x,
int y)
type - The type of the terrain-image to return.x - The x-coordinate of the location of the tile that is being
drawn.y - The x-coordinate of the location of the tile that is being
drawn.
public java.awt.Image getTerrainImage(TileType type,
int x,
int y)
type - The type of the terrain-image to return.x - The x-coordinate of the location of the tile that is being
drawn.y - The x-coordinate of the location of the tile that is being
drawn.
public java.awt.Image getBorderImage(TileType type,
Map.Direction direction,
int x,
int y)
type - The type of the terrain-image to return.direction - a Direction valuex - The x-coordinate of the location of the tile that is being
drawn.y - The x-coordinate of the location of the tile that is being
drawn.
public java.awt.Image getRiverMouthImage(Map.Direction direction,
int magnitude,
int x,
int y)
direction - a Direction valuemagnitude - an int valuex - The x-coordinate of the location of the tile that is being
drawn (ignored).y - The x-coordinate of the location of the tile that is being
drawn (ignored).
public java.awt.Image getCoastImage(TileType type,
Map.Direction direction,
int x,
int y)
type - The type of the terrain-image to return.direction - a Direction valuex - The x-coordinate of the location of the tile that is being
drawn.y - The x-coordinate of the location of the tile that is being
drawn.
public java.awt.Image getRiverImage(int index)
index - The index of the image to return.
public java.awt.Image getBeachImage(int index)
index - The index of the image to return.
public java.awt.Image getForestImage(TileType type)
type - The type of the terrain-image to return.
public java.awt.Image getMiscImage(java.lang.String id)
id - The id of the image to return.
public javax.swing.ImageIcon getMiscImageIcon(java.lang.String id)
id - The id of the image to return.
public java.awt.Image getGoodsImage(GoodsType goodsType)
goodsType - The type of the goods-image to return.
public javax.swing.ImageIcon getGoodsImageIcon(GoodsType goodsType)
goodsType - The type of the goods-image to return.
public javax.swing.ImageIcon getScaledGoodsImageIcon(GoodsType type,
float scale)
type - The type of the goods-ImageIcon to return.scale - The scale of the goods-ImageIcon to return.
public java.awt.Image getColorChip(java.awt.Color color)
color - The color of the color chip to return.
public java.awt.Image getMissionChip(java.awt.Color color,
boolean expertMission)
color - The color of the color chip to return.expertMission - Indicates whether or not the missionary is an
expert.
public java.awt.Image getAlarmChip(Tension.Level alarm,
boolean visited)
alarm - The alarm level.
public int getTerrainImageWidth(TileType type)
type - The type of the terrain-image.
public int getTerrainImageHeight(TileType type)
type - The type of the terrain-image.
public int getCompoundTerrainImageHeight(TileType type)
type - The type of the terrain-image.
public java.awt.Image getSettlementImage(Settlement.SettlementType settlementType)
settlementType - The type of settlement whose graphics type is needed.
public java.awt.Image getSettlementImage(Settlement settlement)
settlement - The settlement whose graphics type is needed.
public javax.swing.ImageIcon getUnitImageIcon(Unit unit)
unit - The unit whose graphics type is needed.
ImageIcon valuepublic javax.swing.ImageIcon getUnitImageIcon(UnitType unitType)
unitType - an UnitType value
ImageIcon value
public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType,
Unit.Role role)
unitType - an UnitType valuerole - a Role value
ImageIcon value
public javax.swing.ImageIcon getUnitImageIcon(Unit unit,
boolean grayscale)
unit - an Unit valuegrayscale - a boolean value
ImageIcon value
public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType,
boolean grayscale)
unitType - an UnitType valuegrayscale - a boolean value
ImageIcon value
public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType,
Unit.Role role,
boolean grayscale)
unitType - an UnitType valuerole - a Role valuegrayscale - a boolean value
ImageIcon value
public javax.swing.ImageIcon getScaledImageIcon(javax.swing.ImageIcon inputIcon,
float scale)
inputIcon - an ImageIcon valuescale - The scale of the ImageIcon to return.
public javax.swing.ImageIcon getScaledImageIcon(java.awt.Image image,
float scale)
image - an Image valuescale - The scale of the ImageIcon to return.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||