net.sf.freecol.client.gui
Class ImageLibrary

java.lang.Object
  extended by net.sf.freecol.client.gui.ImageLibrary

public final class ImageLibrary
extends java.lang.Object

Holds various images that can be called upon by others in order to display certain things.


Field Summary
static int BEACH_STYLES
           
static java.lang.String DARKNESS
           
static java.lang.String DELETE
           
static java.lang.String LOST_CITY_RUMOUR
           
static java.lang.String PLOWED
           
static int RIVER_STYLES
           
static java.lang.String TILE_OWNED_BY_INDIANS
           
static java.lang.String TILE_TAKEN
           
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.
 
Method Summary
 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.
 javax.swing.ImageIcon scaleIcon(javax.swing.ImageIcon icon, float scale)
           
 java.awt.Image scaleImage(java.awt.Image image, float scale)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RIVER_STYLES

public static final int RIVER_STYLES
See Also:
Constant Field Values

BEACH_STYLES

public static final int BEACH_STYLES
See Also:
Constant Field Values

UNIT_SELECT

public static final java.lang.String UNIT_SELECT
See Also:
Constant Field Values

DELETE

public static final java.lang.String DELETE
See Also:
Constant Field Values

PLOWED

public static final java.lang.String PLOWED
See Also:
Constant Field Values

TILE_TAKEN

public static final java.lang.String TILE_TAKEN
See Also:
Constant Field Values

TILE_OWNED_BY_INDIANS

public static final java.lang.String TILE_OWNED_BY_INDIANS
See Also:
Constant Field Values

LOST_CITY_RUMOUR

public static final java.lang.String LOST_CITY_RUMOUR
See Also:
Constant Field Values

DARKNESS

public static final java.lang.String DARKNESS
See Also:
Constant Field Values
Constructor Detail

ImageLibrary

public ImageLibrary()
             throws FreeColException
The constructor to use.

Throws:
FreeColException - If one of the data files could not be found.

ImageLibrary

public ImageLibrary(java.lang.String freeColHome)
             throws FreeColException
A constructor that takes a directory as FreeCol's home.

Parameters:
freeColHome - The home of the freecol files.
Throws:
FreeColException - If one of the data files could not be found.
Method Detail

init

public void init()
          throws FreeColException
Performs all necessary init operations such as loading of data files.

Throws:
FreeColException - If one of the data files could not be found. *

getScalingFactor

public float getScalingFactor()
Returns the scaling factor used when creating this ImageLibrary.

Returns:
1 unless getScaledImageLibrary(float) was used to create this object.

getScaledImageLibrary

public ImageLibrary getScaledImageLibrary(float scalingFactor)
                                   throws FreeColException
Gets a scaled version of this ImageLibrary.

Parameters:
scalingFactor - The factor used when scaling. 2 is twice the size of the original images and 0.5 is half.
Returns:
A new ImageLibrary.
Throws:
FreeColException

scaleImage

public java.awt.Image scaleImage(java.awt.Image image,
                                 float scale)

scaleIcon

public javax.swing.ImageIcon scaleIcon(javax.swing.ImageIcon icon,
                                       float scale)

getFoundingFatherImage

public java.awt.Image getFoundingFatherImage(FoundingFather father)
Returns the portrait of this Founding Father.

Parameters:
father - a FoundingFather value
Returns:
an Image value

getMonarchImage

public java.awt.Image getMonarchImage(Nation nation)
Returns the monarch-image for the given tile.

Parameters:
nation - The nation this monarch rules.
Returns:
the monarch-image for the given nation.

getMonarchImageIcon

public javax.swing.ImageIcon getMonarchImageIcon(Nation nation)
Returns the monarch-image icon for the given Nation.

Parameters:
nation - The nation this monarch rules.
Returns:
the monarch-image for the given nation.

getCoatOfArmsImageIcon

public javax.swing.ImageIcon getCoatOfArmsImageIcon(Nation nation)
Returns the coat-of-arms image for the given Nation.

Parameters:
nation - The nation.
Returns:
the coat-of-arms of this nation

getCoatOfArmsImage

public java.awt.Image getCoatOfArmsImage(Nation nation)
Returns the coat-of-arms image for the given Nation.

Parameters:
nation - The nation.
Returns:
the coat-of-arms of this nation

getBonusImage

public java.awt.Image getBonusImage(Tile tile)
Returns the bonus-image for the given tile.

Parameters:
tile -
Returns:
the bonus-image for the given tile.

getBonusImage

public java.awt.Image getBonusImage(ResourceType type)

getBonusImageIcon

public javax.swing.ImageIcon getBonusImageIcon(ResourceType type)
Returns the bonus-ImageIcon at the given index.

Parameters:
type - The type of the bonus-ImageIcon to return.

getScaledBonusImageIcon

public javax.swing.ImageIcon getScaledBonusImageIcon(ResourceType type,
                                                     float scale)

getScaledTerrainImage

public java.awt.Image getScaledTerrainImage(TileType type,
                                            float scale)
Returns the scaled terrain-image for a terrain type (and position 0, 0).

Parameters:
type - The type of the terrain-image to return.
scale - The scale of the terrain image to return.
Returns:
The terrain-image

getOverlayImage

public java.awt.Image getOverlayImage(TileType type,
                                      int x,
                                      int y)
Returns the overlay-image for the given type.

Parameters:
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.
Returns:
The terrain-image at the given index.

getTerrainImage

public java.awt.Image getTerrainImage(TileType type,
                                      int x,
                                      int y)
Returns the terrain-image for the given type.

Parameters:
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.
Returns:
The terrain-image at the given index.

getBorderImage

public java.awt.Image getBorderImage(TileType type,
                                     Map.Direction direction,
                                     int x,
                                     int y)
Returns the border terrain-image for the given type.

Parameters:
type - The type of the terrain-image to return.
direction - a Direction value
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.
Returns:
The terrain-image at the given index.

getRiverMouthImage

public java.awt.Image getRiverMouthImage(Map.Direction direction,
                                         int magnitude,
                                         int x,
                                         int y)
Returns the river mouth terrain-image for the direction and magnitude.

Parameters:
direction - a Direction value
magnitude - an int value
x - 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).
Returns:
The terrain-image at the given index.

getCoastImage

public java.awt.Image getCoastImage(TileType type,
                                    Map.Direction direction,
                                    int x,
                                    int y)
Returns the coast terrain-image for the given type.

Parameters:
type - The type of the terrain-image to return.
direction - a Direction value
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.
Returns:
The terrain-image at the given index.

getRiverImage

public java.awt.Image getRiverImage(int index)
Returns the river image at the given index.

Parameters:
index - The index of the image to return.
Returns:
The image at the given index.

getBeachImage

public java.awt.Image getBeachImage(int index)
Returns the beach image at the given index.

Parameters:
index - The index of the image to return.
Returns:
The image at the given index.

getForestImage

public java.awt.Image getForestImage(TileType type)
Returns the forest image for a terrain type.

Parameters:
type - The type of the terrain-image to return.
Returns:
The image at the given index.

getMiscImage

public java.awt.Image getMiscImage(java.lang.String id)
Returns the image with the given id.

Parameters:
id - The id of the image to return.
Returns:
The image.

getMiscImageIcon

public javax.swing.ImageIcon getMiscImageIcon(java.lang.String id)
Returns the image with the given id.

Parameters:
id - The id of the image to return.
Returns:
The image.

getGoodsImage

public java.awt.Image getGoodsImage(GoodsType goodsType)
Returns the goods-image at the given index.

Parameters:
goodsType - The type of the goods-image to return.
Returns:
The goods-image at the given index.

getGoodsImageIcon

public javax.swing.ImageIcon getGoodsImageIcon(GoodsType goodsType)
Returns the goods-image for a goods type.

Parameters:
goodsType - The type of the goods-image to return.
Returns:
The goods-image at the given index.

getScaledGoodsImageIcon

public javax.swing.ImageIcon getScaledGoodsImageIcon(GoodsType type,
                                                     float scale)
Returns the scaled goods-ImageIcon for a goods type.

Parameters:
type - The type of the goods-ImageIcon to return.
scale - The scale of the goods-ImageIcon to return.
Returns:
The goods-ImageIcon at the given index.

getColorChip

public java.awt.Image getColorChip(java.awt.Color color)
Returns the color chip with the given color.

Parameters:
color - The color of the color chip to return.
Returns:
The color chip with the given color.

getMissionChip

public java.awt.Image getMissionChip(java.awt.Color color,
                                     boolean expertMission)
Returns the mission chip with the given color.

Parameters:
color - The color of the color chip to return.
expertMission - Indicates whether or not the missionary is an expert.
Returns:
The color chip with the given color.

getAlarmChip

public java.awt.Image getAlarmChip(Tension.Level alarm,
                                   boolean visited)
Returns the alarm chip with the given color.

Parameters:
alarm - The alarm level.
Returns:
The alarm chip.

getTerrainImageWidth

public int getTerrainImageWidth(TileType type)
Returns the width of the terrain-image for a terrain type.

Parameters:
type - The type of the terrain-image.
Returns:
The width of the terrain-image at the given index.

getTerrainImageHeight

public int getTerrainImageHeight(TileType type)
Returns the height of the terrain-image for a terrain type.

Parameters:
type - The type of the terrain-image.
Returns:
The height of the terrain-image at the given index.

getCompoundTerrainImageHeight

public int getCompoundTerrainImageHeight(TileType type)
Returns the height of the terrain-image including overlays and forests for the given terrain type.

Parameters:
type - The type of the terrain-image.
Returns:
The height of the terrain-image at the given index.

getSettlementImage

public java.awt.Image getSettlementImage(Settlement.SettlementType settlementType)
Returns the graphics that will represent the given settlement.

Parameters:
settlementType - The type of settlement whose graphics type is needed.
Returns:
The graphics that will represent the given settlement.

getSettlementImage

public java.awt.Image getSettlementImage(Settlement settlement)
Returns the graphics that will represent the given settlement.

Parameters:
settlement - The settlement whose graphics type is needed.
Returns:
The graphics that will represent the given settlement.

getUnitImageIcon

public javax.swing.ImageIcon getUnitImageIcon(Unit unit)
Returns the ImageIcon that will represent the given unit.

Parameters:
unit - The unit whose graphics type is needed.
Returns:
an ImageIcon value

getUnitImageIcon

public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType)
Returns the ImageIcon that will represent a unit of the given type.

Parameters:
unitType - an UnitType value
Returns:
an ImageIcon value

getUnitImageIcon

public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType,
                                              Unit.Role role)
Returns the ImageIcon that will represent a unit of the given type and role.

Parameters:
unitType - an UnitType value
role - a Role value
Returns:
an ImageIcon value

getUnitImageIcon

public javax.swing.ImageIcon getUnitImageIcon(Unit unit,
                                              boolean grayscale)
Returns the ImageIcon that will represent the given unit.

Parameters:
unit - an Unit value
grayscale - a boolean value
Returns:
an ImageIcon value

getUnitImageIcon

public javax.swing.ImageIcon getUnitImageIcon(UnitType unitType,
                                              boolean grayscale)
Returns the ImageIcon that will represent a unit of the given type.

Parameters:
unitType - an UnitType value
grayscale - a boolean value
Returns:
an ImageIcon value

getUnitImageIcon

public 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.

Parameters:
unitType - an UnitType value
role - a Role value
grayscale - a boolean value
Returns:
an ImageIcon value

getScaledImageIcon

public javax.swing.ImageIcon getScaledImageIcon(javax.swing.ImageIcon inputIcon,
                                                float scale)
Returns the scaled ImageIcon.

Parameters:
inputIcon - an ImageIcon value
scale - The scale of the ImageIcon to return.
Returns:
The scaled ImageIcon.

getScaledImageIcon

public javax.swing.ImageIcon getScaledImageIcon(java.awt.Image image,
                                                float scale)
Returns the scaled ImageIcon.

Parameters:
image - an Image value
scale - The scale of the ImageIcon to return.
Returns:
The scaled ImageIcon.