Package net.sf.freecol.client.gui
Class ImageLibrary
- java.lang.Object
-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImageLibrary.PathType
Helper to distinguish different types of paths.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BELLS
static java.awt.Dimension
BUILDING_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have.private static java.util.List<java.lang.String>
buttonKeys
The action button key prefixes.static java.lang.String
DARKNESS
static java.lang.String
DELETE
static java.lang.String
ICON_COIN
static java.lang.String
ICON_LOCK
static java.awt.Dimension
ICON_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have.private ImageCache
imageCache
Cache for images.private static java.util.logging.Logger
logger
static java.lang.String
LOST_CITY_RUMOUR
static float
MAX_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.static float
MIN_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.static float
NORMAL_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.static java.lang.String
PLOWED
private static java.lang.String
RIVER_STYLE_PREFIX
static float
SCALE_STEP
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.private float
scaleFactor
The scale factor used when creating this library.static float
SMALL_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.static float
SMALLER_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.private java.util.Map<java.lang.String,java.awt.image.BufferedImage>
stringImageCache
Cache for the string images.static java.awt.Dimension
TILE_FOREST_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have.static java.awt.Dimension
TILE_OVERLAY_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have.static java.lang.String
TILE_OWNED_BY_INDIANS
static java.awt.Dimension
TILE_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have.static java.lang.String
TILE_TAKEN
private java.awt.Dimension
tileForestSize
Fixed tile dimensions.private java.awt.Dimension
tileOverlaySize
Fixed tile dimensions.private java.awt.Dimension
tileSize
Fixed tile dimensions.static float
TINY_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.static java.lang.String
UNIT_SELECT
-
Constructor Summary
Constructors Constructor Description ImageLibrary(float scaleFactor, ImageCache imageCache)
The constructor to use for a scaledImageLibrary
.ImageLibrary(ImageCache imageCache)
The constructor to use for an unscaledImageLibrary
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeScaleFactor(float scaleFactor)
Change the scale factor for this image library.private java.awt.image.BufferedImage
createChip(java.awt.Graphics2D g, java.lang.String text, java.awt.Color border, java.awt.Color background, double amount, java.awt.Color fill, java.awt.Color foreground, boolean filled)
Create a "chip" with the given text and colors.private java.awt.image.BufferedImage
createStringImage(java.lang.String text, java.awt.Color color, java.awt.Font font, java.awt.FontMetrics fm)
Create a string image.private java.lang.String
determineDirectionCombinationKey(java.util.List<Direction> directions)
Returns a string representing thedirections
given.private java.lang.String
determineInformationPanelSkinKey(Player player)
private java.awt.image.BufferedImage
getAboveTileImageInternal(TileType type, int seed, java.awt.Dimension size)
Get the overlay-image for the given type and scale.java.awt.image.BufferedImage
getAlarmChip(java.awt.Graphics2D g, IndianSettlement is, Player player)
Gets a chip image for the alarm at an Indian settlement.java.awt.image.BufferedImage
getAnimatedScaledTerrainImage(TileType type, long ticks)
java.awt.image.BufferedImage
getAnimatedScaledWaterAndBeachTerrainImage(TileType type, java.util.List<Direction> directionsWithLand, long ticks)
Gets the combined animated image for ocean and beach.java.awt.image.BufferedImage
getBaseTileTransitionImage(Tile tile, Direction direction)
Returns a transparent image for making a transition between the given tiles.private ImageResource
getBeachCenterImageResource()
java.awt.image.BufferedImage
getBeachCornerImage(int index, int x, int y)
Returns the beach corner image at the given index.java.awt.image.BufferedImage
getBeachEdgeImage(int index, int x, int y)
Returns the beach edge image at the given index.java.awt.image.BufferedImage
getBorderImage(TileType type, Direction direction, int x, int y)
Returns the border terrain-image for the given type.static java.awt.image.BufferedImage
getBrightPanelBackground()
java.awt.image.BufferedImage
getBuildableTypeImage(BuildableType buildable, java.awt.Dimension size)
java.awt.image.BufferedImage
getBuildingTypeImage(BuildingType buildingType, java.awt.Dimension size)
private static java.lang.String
getBuildingTypeKey(BuildingType buildingType)
static java.awt.image.BufferedImage
getButtonBackground()
java.util.List<java.awt.image.BufferedImage>
getButtonImages(java.lang.String key)
Get the button images for a given key.static java.awt.image.BufferedImage
getCanvasBackgroundImage()
java.awt.image.BufferedImage
getColopediaCellImage(boolean expanded)
java.awt.image.BufferedImage
getColopediaConceptImage()
static java.awt.Color
getColor(java.lang.String key)
Get a color.static java.awt.Color
getColor(java.lang.String key, java.awt.Color replacement)
Get a color.static java.awt.image.BufferedImage
getColorCellRendererBackground()
javax.swing.JLabel
getCompassRose()
static java.awt.Cursor
getCursor()
Get the standard cursor.java.awt.Dimension
getForestedTileSize()
Get the scaled size of a forested tile.java.awt.image.BufferedImage
getForestImage(TileType type, java.awt.Dimension size)
private java.awt.image.BufferedImage
getForestImageInternal(TileType type, TileImprovementStyle riverStyle, java.awt.Dimension size)
Get the forest image for a terrain type.java.awt.image.BufferedImage
getFoundingFatherImage(FoundingFather father, boolean grayscale)
Returns the portrait of this Founding Father.static java.awt.Color
getGoodsColor(GoodsType goodsType, int amount, Location location)
Get a foreground color for a given goods type and amount in a given location.java.awt.image.BufferedImage
getGoodsTypeImage(GoodsType gt, java.awt.Dimension size)
private static java.lang.String
getGoodsTypeKey(GoodsType gt)
java.awt.image.BufferedImage
getIndianSettlementChip(java.awt.Graphics2D g, IndianSettlement is)
Gets the owner chip for the settlement.java.awt.image.BufferedImage
getInformationPanelSkin(Player player)
int
getInformationPanelSkinTopInset(Player player)
java.awt.image.BufferedImage
getLCRImage(java.awt.Dimension size)
java.awt.image.BufferedImage
getLibertyImage()
static java.awt.image.BufferedImage
getListBackground()
javax.swing.JLabel
getLockLabel()
static java.awt.image.BufferedImage
getMeetingImage(Player meet)
static java.awt.image.BufferedImage
getMenuBackground()
private static java.lang.String
getMercenaryLeaderKey(int n)
static java.awt.image.BufferedImage
getMiniMapBackground()
static java.awt.Color
getMinimapBackgroundColor()
static java.awt.Color
getMinimapBorderColor()
static java.awt.Color
getMinimapEconomicColor(TileType type)
static java.awt.Color
getMinimapPoliticsColor(TileType type)
java.awt.image.BufferedImage
getMiniMapSkin()
java.awt.image.BufferedImage
getMissionChip(java.awt.Graphics2D g, Player owner, boolean expert)
Gets the mission chip for a native settlement.static java.awt.image.BufferedImage
getMonarchImage(java.lang.String monarchKey)
Get the "monarch" image from a key.static java.awt.image.BufferedImage
getMonarchImage(Nation nation)
Returns the monarch-image for the given tile.private static java.lang.String
getMonarchKey(java.lang.String nationId)
java.awt.image.BufferedImage
getNationImage(Nation nation, float scale)
java.awt.image.BufferedImage
getNationImage(Nation nation, java.awt.Dimension size)
static java.lang.String
getNationKey(Nation nation)
java.awt.image.BufferedImage
getObjectImage(FreeColObject display)
Get the appropriate BufferedImage for a FreeColObject.java.awt.image.BufferedImage
getObjectImage(FreeColObject display, java.awt.Dimension size)
Get the appropriate BufferedImage for a FreeColObject.javax.swing.ImageIcon
getObjectImageIcon(FreeColObject display)
Get an ImageIcon for a FreeColObject.private java.awt.image.BufferedImage
getObjectImageInternal(FreeColObject display, java.awt.Dimension size)
Get the appropriate BufferedImage for a FreeColObject.java.awt.image.BufferedImage
getOccupationIndicatorChip(java.awt.Graphics2D g, Unit unit, java.lang.String text)
Gets a chip for an occupation indicator, i.e.static java.awt.image.BufferedImage
getOptionPaneBackground()
private java.awt.image.BufferedImage
getOverlayImageInternal(TileType type, int seed, java.awt.Dimension size)
Get the overlay-image for the given type and scale.static java.awt.image.BufferedImage
getPanelBackground()
Gets the default background for panels (dialogs/windows).static java.awt.image.BufferedImage
getPanelBackground(java.lang.Class<?> clazz)
Gets the background for the given panel.static java.awt.image.BufferedImage
getPathImage(ImageLibrary.PathType pt)
Gets an image to represent the path of given path type.static java.awt.image.BufferedImage
getPathImage(Unit u)
Gets an image to represent the path of the givenUnit
.private static java.awt.image.BufferedImage
getPathNextTurnImage(ImageLibrary.PathType pt)
Gets an image to represent the path of the givenUnit
.static java.awt.image.BufferedImage
getPathNextTurnImage(Unit u)
Gets an image to represent the path of the givenUnit
.java.awt.image.BufferedImage
getPlaceholderImage()
Get the generic placeholder image.static java.awt.image.BufferedImage
getPopupMenuBackground()
static java.awt.image.BufferedImage
getProgressBarBackground()
private java.awt.image.BufferedImage
getResourceTypeImage(ResourceType rt, float scale, boolean grayscale)
java.awt.image.BufferedImage
getResourceTypeImage(ResourceType rt, java.awt.Dimension size, boolean grayscale)
private static java.lang.String
getResourceTypeKey(ResourceType rt)
java.awt.image.BufferedImage
getRiverImage(java.lang.String style, java.awt.Dimension size)
private java.awt.image.BufferedImage
getRiverImageInternal(java.lang.String style, java.awt.Dimension size)
Returns the river image with the given style.java.awt.image.BufferedImage
getRiverMouthImage(Direction direction, int magnitude, int x, int y)
Returns the river mouth terrain-image for the direction and magnitude.private static java.lang.String
getRiverStyleKey(java.lang.String style)
static java.util.List<java.lang.String>
getRiverStyleKeys(boolean all)
Get a list of river style image keys.static java.awt.Color
getRoadColor()
Get the road color.java.awt.image.BufferedImage
getScaledAboveTileImage(Tile tile)
java.awt.image.BufferedImage
getScaledBuildingImage(Building building)
java.awt.image.BufferedImage
getScaledBuildingTypeImage(BuildingType buildingType, float scale)
private java.awt.image.BufferedImage
getScaledBuildingTypeImage(BuildingType buildingType, Player player, float scale)
java.awt.Font
getScaledFont(java.lang.String spec, java.lang.String text)
Get a scaled font with a simple text specification.java.awt.image.BufferedImage
getScaledForestImage(TileType type)
java.awt.image.BufferedImage
getScaledForestImage(TileType type, TileImprovementStyle riverStyle)
java.awt.image.BufferedImage
getScaledGoodsTypeImage(GoodsType gt)
java.awt.image.BufferedImage
getScaledImage(java.lang.String key)
Get the image for the given identifier, using the current scaling.java.awt.image.BufferedImage
getScaledNationImage(Nation nation)
java.awt.image.BufferedImage
getScaledOverlayImage(Tile tile)
java.awt.image.BufferedImage
getScaledResourceImage(Resource resource)
java.awt.image.BufferedImage
getScaledResourceTypeImage(ResourceType rt)
java.awt.image.BufferedImage
getScaledRiverImage(java.lang.String style)
private java.awt.image.BufferedImage
getScaledRiverImage(java.lang.String style, float scale)
Returns the river image with the given style and scale.java.awt.image.BufferedImage
getScaledRiverImage(TileImprovementStyle style)
Returns the river image with the given style.java.awt.image.BufferedImage
getScaledSettlementImage(Settlement settlement)
Returns the graphics that will represent the given settlement.java.awt.image.BufferedImage
getScaledSettlementTypeImage(SettlementType settlementType)
Returns the graphics that will represent the given settlement.java.awt.image.BufferedImage
getScaledTerrainImage(TileType type, int x, int y)
java.awt.image.BufferedImage
getScaledUnitImage(Unit unit)
java.awt.image.BufferedImage
getScaledUnitImage(Unit unit, boolean grayscale)
java.awt.image.BufferedImage
getScaledUnitTypeImage(UnitType unitType)
float
getScaleFactor()
Get the scaling factor used when creating thisImageLibrary
.java.awt.image.BufferedImage
getSettlementImage(Settlement settlement, float scale)
Returns the graphics that will represent the given settlement.java.awt.image.BufferedImage
getSettlementImage(Settlement settlement, java.awt.Dimension size)
static java.lang.String
getSettlementKey(Settlement settlement)
Get an image key for a settlement.private java.awt.image.BufferedImage
getSettlementTypeImage(SettlementType settlementType, float scale)
java.awt.image.BufferedImage
getSettlementTypeImage(SettlementType settlementType, java.awt.Dimension size)
private static java.lang.String
getSettlementTypeKey(SettlementType settlementType)
java.awt.image.BufferedImage
getSizedImage(java.lang.String key, java.awt.Dimension size)
Get the image for the given identifier, using a given size.java.awt.image.BufferedImage
getSizedOverlayImage(TileType type, java.awt.Dimension size)
java.awt.image.BufferedImage
getSmallBuildableTypeImage(BuildableType buildable, Player player)
java.awt.image.BufferedImage
getSmallBuildingImage(Building building)
java.awt.image.BufferedImage
getSmallerGoodsTypeImage(GoodsType gt)
java.awt.image.BufferedImage
getSmallerNationImage(Nation nation)
java.awt.image.BufferedImage
getSmallerRiverImage(java.lang.String style)
java.awt.image.BufferedImage
getSmallerSettlementImage(Settlement settlement)
java.awt.image.BufferedImage
getSmallerSettlementTypeImage(SettlementType settlementType)
java.awt.image.BufferedImage
getSmallerUnitImage(Unit unit)
java.awt.image.BufferedImage
getSmallerUnitTypeImage(UnitType unitType)
java.awt.image.BufferedImage
getSmallGoodsTypeImage(GoodsType gt)
java.awt.image.BufferedImage
getSmallNationImage(Nation nation)
java.awt.image.BufferedImage
getSmallResourceTypeImage(ResourceType rt)
java.awt.image.BufferedImage
getSmallSettlementImage(Settlement settlement)
java.awt.image.BufferedImage
getSmallUnitImage(Unit unit)
java.awt.image.BufferedImage
getSmallUnitImage(Unit unit, boolean grayscale)
java.awt.image.BufferedImage
getSmallUnitTypeImage(UnitType unitType)
java.awt.image.BufferedImage
getSmallUnitTypeImage(UnitType unitType, boolean grayscale)
java.awt.image.BufferedImage
getSmallUnitTypeImage(UnitType unitType, java.lang.String roleId, boolean grayscale)
java.awt.image.BufferedImage
getStringImage(java.awt.Graphics g, java.lang.String text, java.awt.Color color, java.awt.Font font)
Gets an image with a string of a given color and with a black border around the glyphs.static SimpleZippedAnimation
getSZA(java.lang.String key, float scale)
java.awt.image.BufferedImage
getTerrainImage(TileType type, int x, int y, java.awt.Dimension size)
private java.awt.image.BufferedImage
getTerrainImageInternal(TileType type, int x, int y, java.awt.Dimension size)
Gets the terrain-image for the given type.static java.lang.String
getTerrainImageKey(TileType type)
java.awt.image.BufferedImage
getTerrainMask(Direction direction)
static java.awt.image.BufferedImage
getTextAreaBackground()
static java.awt.image.BufferedImage
getTextFieldBackground()
java.awt.image.BufferedImage
getTileImageWithOverlayAndForest(TileType type, java.awt.Dimension size)
Get a scaled terrain-image for a terrain type (and position 0, 0).java.awt.image.BufferedImage
getTileImprovementImage(java.lang.String id)
Get the tile improvement image with for a given identifier.java.awt.Dimension
getTileSize()
Get the scaled size of a tile.java.awt.image.BufferedImage
getTinyUnitImage(Unit unit)
java.awt.image.BufferedImage
getTinyUnitTypeImage(UnitType unitType)
java.awt.image.BufferedImage
getTinyUnitTypeImage(UnitType unitType, boolean grayscale)
static java.awt.image.BufferedImage
getToolTipBackground()
private java.awt.image.BufferedImage
getUnitImage(Unit unit, boolean grayscale, float scale)
private java.awt.image.BufferedImage
getUnitTypeImage(UnitType unitType, float scale)
private java.awt.image.BufferedImage
getUnitTypeImage(UnitType unitType, java.awt.Dimension size)
private java.awt.image.BufferedImage
getUnitTypeImage(UnitType unitType, java.lang.String roleId, boolean nativeEthnicity, java.awt.Dimension size)
private java.awt.image.BufferedImage
getUnitTypeImage(UnitType unitType, Player owner, java.lang.String roleId, boolean nativeEthnicity, boolean grayscale, float scale)
Fundamental unit image accessor.private static java.lang.String
getUnitTypeImageKey(UnitType unitType, Player owner, java.lang.String roleId, boolean nativeEthnicity)
Get the unit image key for the given parameters.static java.awt.image.BufferedImage
getUnscaledImage(java.lang.String key)
Just get an image without any scaling.java.awt.image.BufferedImage
getUnscaledSmallerNationImage(Nation nation)
static Video
getVideo(java.lang.String key)
static java.awt.Color
makeForegroundColor(java.awt.Color background)
Derive a suitable foreground color from a background color.private static java.awt.Color
makeStringBorderColor(java.awt.Color color)
Derive a string border color from the string color.java.awt.Dimension
scale(java.awt.Dimension size)
Scale a dimension with the current internal scale.java.awt.Dimension
scale(java.awt.Dimension size, float extraFactor)
Scale a dimension with the current internal scale and an extra override.static java.awt.Dimension
scaleDimension(java.awt.Dimension size, float scaleFactor)
Absolute dimenion scaling helper routine.int
scaleInt(int n)
Scale a pixel distance the current internal scale.private static int
variationSeedUsing(int x, int y)
Calculates a seed for reliably generating the same "random" number.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
ICON_SIZE
public static final java.awt.Dimension ICON_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have. ICON_SIZE, TILE_SIZE, TILE_OVERLAY_SIZE and TILE_FOREST_SIZE constants are used in this way already, allowing them to tolerate changing sizes in the files. Most other images are currently still shown in a size of image size times scaling factor times requested size.
-
BUILDING_SIZE
public static final java.awt.Dimension BUILDING_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have. ICON_SIZE, TILE_SIZE, TILE_OVERLAY_SIZE and TILE_FOREST_SIZE constants are used in this way already, allowing them to tolerate changing sizes in the files. Most other images are currently still shown in a size of image size times scaling factor times requested size.
-
TILE_SIZE
public static final java.awt.Dimension TILE_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have. ICON_SIZE, TILE_SIZE, TILE_OVERLAY_SIZE and TILE_FOREST_SIZE constants are used in this way already, allowing them to tolerate changing sizes in the files. Most other images are currently still shown in a size of image size times scaling factor times requested size.
-
TILE_OVERLAY_SIZE
public static final java.awt.Dimension TILE_OVERLAY_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have. ICON_SIZE, TILE_SIZE, TILE_OVERLAY_SIZE and TILE_FOREST_SIZE constants are used in this way already, allowing them to tolerate changing sizes in the files. Most other images are currently still shown in a size of image size times scaling factor times requested size.
-
TILE_FOREST_SIZE
public static final java.awt.Dimension TILE_FOREST_SIZE
Canonical sizes of images GUI elements and map are expecting and current image files have. ICON_SIZE, TILE_SIZE, TILE_OVERLAY_SIZE and TILE_FOREST_SIZE constants are used in this way already, allowing them to tolerate changing sizes in the files. Most other images are currently still shown in a size of image size times scaling factor times requested size.
-
TINY_SCALE
public static final float TINY_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
SMALLER_SCALE
public static final float SMALLER_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
SMALL_SCALE
public static final float SMALL_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
NORMAL_SCALE
public static final float NORMAL_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
MIN_SCALE
public static final float MIN_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
MAX_SCALE
public static final float MAX_SCALE
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- See Also:
- Constant Field Values
-
SCALE_STEP
public static final float SCALE_STEP
Constants for the current "named" scales (tiny, smaller, small) plus a trivial value for unscaled.- 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
-
UNIT_SELECT
public static final java.lang.String UNIT_SELECT
- 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
-
ICON_LOCK
public static final java.lang.String ICON_LOCK
- See Also:
- Constant Field Values
-
ICON_COIN
public static final java.lang.String ICON_COIN
- See Also:
- Constant Field Values
-
BELLS
public static final java.lang.String BELLS
- See Also:
- Constant Field Values
-
RIVER_STYLE_PREFIX
private static java.lang.String RIVER_STYLE_PREFIX
-
buttonKeys
private static final java.util.List<java.lang.String> buttonKeys
The action button key prefixes.
-
scaleFactor
private float scaleFactor
The scale factor used when creating this library. The value1
is used if this object is not a result of a scaling operation.
-
tileSize
private java.awt.Dimension tileSize
Fixed tile dimensions.
-
tileOverlaySize
private java.awt.Dimension tileOverlaySize
Fixed tile dimensions.
-
tileForestSize
private java.awt.Dimension tileForestSize
Fixed tile dimensions.
-
imageCache
private final ImageCache imageCache
Cache for images.
-
stringImageCache
private java.util.Map<java.lang.String,java.awt.image.BufferedImage> stringImageCache
Cache for the string images.
-
-
Constructor Detail
-
ImageLibrary
public ImageLibrary(ImageCache imageCache)
The constructor to use for an unscaledImageLibrary
.- Parameters:
imageCache
- AnImageCache
to hold images..
-
ImageLibrary
public ImageLibrary(float scaleFactor, ImageCache imageCache)
The constructor to use for a scaledImageLibrary
. Please avoid using too many different scaling factors, as this will lead to wasted memory for caching images in ResourceManager! Currently, 0.25, 0.5, ..., 2.0 are used for the map. Colony tiles and the GUI use 1.0 here (maybe also 1.25, 1.5, 1.75 and 2.0 in future), but this gets multiplied for tiny 0.25(rarely, candidate for removal), smaller 0.5, small 0.75 and normal 1.0 image retrieval methods.- Parameters:
scaleFactor
- The factor used when scaling. 2 is twice the size of the original images and 0.5 is halfimageCache
- AnImageCache
to hold images..
-
-
Method Detail
-
getScaleFactor
public float getScaleFactor()
Get the scaling factor used when creating thisImageLibrary
. It is 1f if the constructor without scaling factor was used to create this object.- Returns:
- The scaling factor of this ImageLibrary.
-
changeScaleFactor
public void changeScaleFactor(float scaleFactor)
Change the scale factor for this image library. All the other variables depend on the scale factor.- Parameters:
scaleFactor
- The factor used when scaling. 2 is twice
-
scaleInt
public int scaleInt(int n)
Scale a pixel distance the current internal scale.- Parameters:
n
- The pixels to scale.- Returns:
- The scaled pixels.
-
scale
public java.awt.Dimension scale(java.awt.Dimension size)
Scale a dimension with the current internal scale.- Parameters:
size
- TheDimension
to scale.- Returns:
- The scaled
Dimension
.
-
scale
public java.awt.Dimension scale(java.awt.Dimension size, float extraFactor)
Scale a dimension with the current internal scale and an extra override.- Parameters:
size
- TheDimension
to scale.extraFactor
- An extra scaling.- Returns:
- The scaled
Dimension
.
-
scaleDimension
public static java.awt.Dimension scaleDimension(java.awt.Dimension size, float scaleFactor)
Absolute dimenion scaling helper routine.- Parameters:
size
- TheDimension
to scale.scaleFactor
- The scale to use.- Returns:
- The scaled
Dimension
.
-
getTileSize
public java.awt.Dimension getTileSize()
Get the scaled size of a tile.- Returns:
- The tile size.
-
getForestedTileSize
public java.awt.Dimension getForestedTileSize()
Get the scaled size of a forested tile.- Returns:
- The forested tile size.
-
variationSeedUsing
private static int variationSeedUsing(int x, int y)
Calculates a seed for reliably generating the same "random" number. This is useful to select different images for the same tile type in order to prevent big stripes or a checker-board effect.- Parameters:
x
- The tile x coordinate.y
- The tile y coordinate.- Returns:
- The seed.
-
getSZA
public static SimpleZippedAnimation getSZA(java.lang.String key, float scale)
-
makeForegroundColor
public static java.awt.Color makeForegroundColor(java.awt.Color background)
Derive a suitable foreground color from a background color. Our eyes have different sensitivity towards red, green and blue. We want a foreground color with the inverse brightness.- Parameters:
background
- The backgroundColor
to complement.- Returns:
- A suitable foreground
Color
.
-
makeStringBorderColor
private static java.awt.Color makeStringBorderColor(java.awt.Color color)
Derive a string border color from the string color. Black unless the color of the string is really dark.- Parameters:
color
- TheColor
to complement.- Returns:
- A suitable border
Color
.
-
getColor
public static java.awt.Color getColor(java.lang.String key)
Get a color.- Parameters:
key
- The color name.- Returns:
- The
Color
found by the resource manager.
-
getColor
public static java.awt.Color getColor(java.lang.String key, java.awt.Color replacement)
Get a color.- Parameters:
key
- The color name.replacement
- A replacementColor
to use if the named color can not be found by the resource manager.- Returns:
- The
Color
found by the resource manager.
-
getGoodsColor
public static java.awt.Color getGoodsColor(GoodsType goodsType, int amount, Location location)
Get a foreground color for a given goods type and amount in a given location.- Parameters:
goodsType
- TheGoodsType
to use.amount
- The amount of goods.location
- TheLocation
for the goods.- Returns:
- A suitable
Color
.
-
getMinimapBackgroundColor
public static java.awt.Color getMinimapBackgroundColor()
-
getMinimapBorderColor
public static java.awt.Color getMinimapBorderColor()
-
getMinimapEconomicColor
public static java.awt.Color getMinimapEconomicColor(TileType type)
-
getMinimapPoliticsColor
public static java.awt.Color getMinimapPoliticsColor(TileType type)
-
getRoadColor
public static java.awt.Color getRoadColor()
Get the road color.- Returns:
- The road color.
-
getScaledFont
public java.awt.Font getScaledFont(java.lang.String spec, java.lang.String text)
Get a scaled font with a simple text specification. TheFont
is scaled with the scaleFactor from thisImageLibrary
instead of the global scaleFactor inFontLibrary
. This method is meant to be used for font that should scale perfectly with the graphics, for example text on the map.- Parameters:
spec
- The font specification.text
- Optional text that the font must be able to represent.- Returns:
- The
Font
found.
-
getUnscaledImage
public static java.awt.image.BufferedImage getUnscaledImage(java.lang.String key)
Just get an image without any scaling. Note, that this routine and its callers can be static, but anything that is scaled or sized goes through the image cache and thus can not be static.- Parameters:
key
- The image key.- Returns:
- The image found.
-
getScaledImage
public java.awt.image.BufferedImage getScaledImage(java.lang.String key)
Get the image for the given identifier, using the current scaling.- Parameters:
key
- The image key.- Returns:
- The
BufferedImage
found by theResourceManager
.
-
getSizedImage
public java.awt.image.BufferedImage getSizedImage(java.lang.String key, java.awt.Dimension size)
Get the image for the given identifier, using a given size.- Parameters:
key
- The image key.size
- The image size required.- Returns:
- The
BufferedImage
found by theResourceManager
.
-
getButtonBackground
public static java.awt.image.BufferedImage getButtonBackground()
-
getButtonImages
public java.util.List<java.awt.image.BufferedImage> getButtonImages(java.lang.String key)
Get the button images for a given key.- Parameters:
key
- The key to look up.- Returns:
- The list of button images found.
-
getBrightPanelBackground
public static java.awt.image.BufferedImage getBrightPanelBackground()
-
getCanvasBackgroundImage
public static java.awt.image.BufferedImage getCanvasBackgroundImage()
-
getColopediaCellImage
public java.awt.image.BufferedImage getColopediaCellImage(boolean expanded)
-
getColopediaConceptImage
public java.awt.image.BufferedImage getColopediaConceptImage()
-
getColorCellRendererBackground
public static java.awt.image.BufferedImage getColorCellRendererBackground()
-
getCompassRose
public javax.swing.JLabel getCompassRose()
-
getCursor
public static java.awt.Cursor getCursor()
Get the standard cursor.- Returns:
- A suitable default
Cursor
.
-
getFoundingFatherImage
public java.awt.image.BufferedImage getFoundingFatherImage(FoundingFather father, boolean grayscale)
Returns the portrait of this Founding Father.- Parameters:
father
- TheFoundingFather
to look for.grayscale
- True if the image should be grayscale.- Returns:
- The
BufferedImage
found.
-
getInformationPanelSkin
public java.awt.image.BufferedImage getInformationPanelSkin(Player player)
-
determineInformationPanelSkinKey
private java.lang.String determineInformationPanelSkinKey(Player player)
-
getInformationPanelSkinTopInset
public int getInformationPanelSkinTopInset(Player player)
-
getLCRImage
public java.awt.image.BufferedImage getLCRImage(java.awt.Dimension size)
-
getLibertyImage
public java.awt.image.BufferedImage getLibertyImage()
-
getListBackground
public static java.awt.image.BufferedImage getListBackground()
-
getLockLabel
public javax.swing.JLabel getLockLabel()
-
getMeetingImage
public static java.awt.image.BufferedImage getMeetingImage(Player meet)
-
getMenuBackground
public static java.awt.image.BufferedImage getMenuBackground()
-
getMiniMapBackground
public static java.awt.image.BufferedImage getMiniMapBackground()
-
getMiniMapSkin
public java.awt.image.BufferedImage getMiniMapSkin()
-
getObjectImageInternal
private java.awt.image.BufferedImage getObjectImageInternal(FreeColObject display, java.awt.Dimension size)
Get the appropriate BufferedImage for a FreeColObject.- Parameters:
display
- TheFreeColObject
to display.size
- The image size.- Returns:
- The appropriate
BufferedImage
.
-
getObjectImage
public java.awt.image.BufferedImage getObjectImage(FreeColObject display)
Get the appropriate BufferedImage for a FreeColObject. Please use a more specific method!- Parameters:
display
- TheFreeColObject
to display.- Returns:
- The appropriate
BufferedImage
.
-
getObjectImage
public java.awt.image.BufferedImage getObjectImage(FreeColObject display, java.awt.Dimension size)
Get the appropriate BufferedImage for a FreeColObject. Please use a more specific method!- Parameters:
display
- TheFreeColObject
to display.size
- The image size.- Returns:
- The appropriate
BufferedImage
.
-
getObjectImageIcon
public javax.swing.ImageIcon getObjectImageIcon(FreeColObject display)
Get an ImageIcon for a FreeColObject.- Parameters:
display
- TheFreeColObject
to find an icon for.- Returns:
- The
ImageIcon
found.
-
getOptionPaneBackground
public static java.awt.image.BufferedImage getOptionPaneBackground()
-
getPanelBackground
public static java.awt.image.BufferedImage getPanelBackground()
Gets the default background for panels (dialogs/windows).- Returns:
- The default background image.
- See Also:
getPanelBackground(Class)
-
getPanelBackground
public static java.awt.image.BufferedImage getPanelBackground(java.lang.Class<?> clazz)
Gets the background for the given panel.- Parameters:
clazz
- TheClass
of the panel.- Returns:
- The background for the given panel, or the first matching superclass.
-
getPlaceholderImage
public java.awt.image.BufferedImage getPlaceholderImage()
Get the generic placeholder image.- Returns:
- The placeholder
BufferedImage
.
-
getPopupMenuBackground
public static java.awt.image.BufferedImage getPopupMenuBackground()
-
getProgressBarBackground
public static java.awt.image.BufferedImage getProgressBarBackground()
-
getTextAreaBackground
public static java.awt.image.BufferedImage getTextAreaBackground()
-
getTextFieldBackground
public static java.awt.image.BufferedImage getTextFieldBackground()
-
getToolTipBackground
public static java.awt.image.BufferedImage getToolTipBackground()
-
getBuildingTypeKey
private static java.lang.String getBuildingTypeKey(BuildingType buildingType)
-
getBuildableTypeImage
public java.awt.image.BufferedImage getBuildableTypeImage(BuildableType buildable, java.awt.Dimension size)
-
getSmallBuildableTypeImage
public java.awt.image.BufferedImage getSmallBuildableTypeImage(BuildableType buildable, Player player)
-
getBuildingTypeImage
public java.awt.image.BufferedImage getBuildingTypeImage(BuildingType buildingType, java.awt.Dimension size)
-
getScaledBuildingTypeImage
public java.awt.image.BufferedImage getScaledBuildingTypeImage(BuildingType buildingType, float scale)
-
getScaledBuildingTypeImage
private java.awt.image.BufferedImage getScaledBuildingTypeImage(BuildingType buildingType, Player player, float scale)
-
getScaledBuildingImage
public java.awt.image.BufferedImage getScaledBuildingImage(Building building)
-
getSmallBuildingImage
public java.awt.image.BufferedImage getSmallBuildingImage(Building building)
-
getGoodsTypeKey
private static java.lang.String getGoodsTypeKey(GoodsType gt)
-
getGoodsTypeImage
public java.awt.image.BufferedImage getGoodsTypeImage(GoodsType gt, java.awt.Dimension size)
-
getScaledGoodsTypeImage
public java.awt.image.BufferedImage getScaledGoodsTypeImage(GoodsType gt)
-
getSmallGoodsTypeImage
public java.awt.image.BufferedImage getSmallGoodsTypeImage(GoodsType gt)
-
getSmallerGoodsTypeImage
public java.awt.image.BufferedImage getSmallerGoodsTypeImage(GoodsType gt)
-
getMercenaryLeaderKey
private static java.lang.String getMercenaryLeaderKey(int n)
-
getMonarchKey
private static java.lang.String getMonarchKey(java.lang.String nationId)
-
getMonarchImage
public static java.awt.image.BufferedImage 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.
-
getMonarchImage
public static java.awt.image.BufferedImage getMonarchImage(java.lang.String monarchKey)
Get the "monarch" image from a key. The key may be a nation identifier, or if an integer it is a mercenary leader.- Parameters:
monarchKey
- The key to examine.- Returns:
- A suitable
BufferedImage
.
-
getNationKey
public static java.lang.String getNationKey(Nation nation)
-
getNationImage
public java.awt.image.BufferedImage getNationImage(Nation nation, java.awt.Dimension size)
-
getNationImage
public java.awt.image.BufferedImage getNationImage(Nation nation, float scale)
-
getScaledNationImage
public java.awt.image.BufferedImage getScaledNationImage(Nation nation)
-
getSmallNationImage
public java.awt.image.BufferedImage getSmallNationImage(Nation nation)
-
getSmallerNationImage
public java.awt.image.BufferedImage getSmallerNationImage(Nation nation)
-
getUnscaledSmallerNationImage
public java.awt.image.BufferedImage getUnscaledSmallerNationImage(Nation nation)
-
getPathImage
public static java.awt.image.BufferedImage getPathImage(ImageLibrary.PathType pt)
Gets an image to represent the path of given path type.- Parameters:
pt
- ThePathType
- Returns:
- The
BufferedImage
.
-
getPathImage
public static java.awt.image.BufferedImage getPathImage(Unit u)
Gets an image to represent the path of the givenUnit
.- Parameters:
u
- TheUnit
- Returns:
- The
BufferedImage
.
-
getPathNextTurnImage
private static java.awt.image.BufferedImage getPathNextTurnImage(ImageLibrary.PathType pt)
Gets an image to represent the path of the givenUnit
.- Parameters:
pt
- ThePathType
- Returns:
- The
BufferedImage
.
-
getPathNextTurnImage
public static java.awt.image.BufferedImage getPathNextTurnImage(Unit u)
Gets an image to represent the path of the givenUnit
.- Parameters:
u
- TheUnit
- Returns:
- The
BufferedImage
.
-
getBeachCornerImage
public java.awt.image.BufferedImage getBeachCornerImage(int index, int x, int y)
Returns the beach corner image at the given index.- Parameters:
index
- The index of the image to return.x
- anint
valuey
- anint
value- Returns:
- The image at the given index.
-
getBeachEdgeImage
public java.awt.image.BufferedImage getBeachEdgeImage(int index, int x, int y)
Returns the beach edge image at the given index.- Parameters:
index
- The index of the image to return.x
- anint
valuey
- anint
value- Returns:
- The image at the given index.
-
getBeachCenterImageResource
private ImageResource getBeachCenterImageResource()
-
getBaseTileTransitionImage
public java.awt.image.BufferedImage getBaseTileTransitionImage(Tile tile, Direction direction)
Returns a transparent image for making a transition between the given tiles.- Parameters:
tile
- The tile that should get a transition.direction
- The direction to get the bordering tile from..- Returns:
- The image, or
null
if there is no transition that should be drawn.
-
getBorderImage
public java.awt.image.BufferedImage getBorderImage(TileType type, 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
- aDirection
valuex
- The x-coordinate of the tile that is being drawn.y
- The x-coordinate of the tile that is being drawn.- Returns:
- The terrain-image at the given index.
-
getForestImageInternal
private java.awt.image.BufferedImage getForestImageInternal(TileType type, TileImprovementStyle riverStyle, java.awt.Dimension size)
Get the forest image for a terrain type.- Parameters:
type
- The type of the terrain-image to return.riverStyle
- An optional river style to apply.size
- The image size.- Returns:
- The image at the given index.
-
getForestImage
public java.awt.image.BufferedImage getForestImage(TileType type, java.awt.Dimension size)
-
getScaledForestImage
public java.awt.image.BufferedImage getScaledForestImage(TileType type)
-
getScaledForestImage
public java.awt.image.BufferedImage getScaledForestImage(TileType type, TileImprovementStyle riverStyle)
-
getOverlayImageInternal
private java.awt.image.BufferedImage getOverlayImageInternal(TileType type, int seed, java.awt.Dimension size)
Get the overlay-image for the given type and scale.- Parameters:
type
- The type of the terrain-image to return.seed
- A seed for the tile instance that needs a random image.size
- The size of the image to return.- Returns:
- A stable (with respect to id) random overlay image.
-
getAboveTileImageInternal
private java.awt.image.BufferedImage getAboveTileImageInternal(TileType type, int seed, java.awt.Dimension size)
Get the overlay-image for the given type and scale. To be placed above units.- Parameters:
type
- The type of the terrain-image to return.seed
- A seed for the tile instance that needs a random image.size
- The size of the image to return.- Returns:
- A stable (with respect to id) random overlay image.
-
getScaledOverlayImage
public java.awt.image.BufferedImage getScaledOverlayImage(Tile tile)
-
getScaledAboveTileImage
public java.awt.image.BufferedImage getScaledAboveTileImage(Tile tile)
-
getSizedOverlayImage
public java.awt.image.BufferedImage getSizedOverlayImage(TileType type, java.awt.Dimension size)
-
getResourceTypeKey
private static java.lang.String getResourceTypeKey(ResourceType rt)
-
getResourceTypeImage
public java.awt.image.BufferedImage getResourceTypeImage(ResourceType rt, java.awt.Dimension size, boolean grayscale)
-
getResourceTypeImage
private java.awt.image.BufferedImage getResourceTypeImage(ResourceType rt, float scale, boolean grayscale)
-
getScaledResourceTypeImage
public java.awt.image.BufferedImage getScaledResourceTypeImage(ResourceType rt)
-
getSmallResourceTypeImage
public java.awt.image.BufferedImage getSmallResourceTypeImage(ResourceType rt)
-
getScaledResourceImage
public java.awt.image.BufferedImage getScaledResourceImage(Resource resource)
-
getRiverStyleKey
private static java.lang.String getRiverStyleKey(java.lang.String style)
-
getRiverImageInternal
private java.awt.image.BufferedImage getRiverImageInternal(java.lang.String style, java.awt.Dimension size)
Returns the river image with the given style.- Parameters:
style
- the style codesize
- the image size- Returns:
- The image with the given style.
-
getRiverImage
public java.awt.image.BufferedImage getRiverImage(java.lang.String style, java.awt.Dimension size)
-
getScaledRiverImage
private java.awt.image.BufferedImage getScaledRiverImage(java.lang.String style, float scale)
Returns the river image with the given style and scale.- Parameters:
style
- The improvement style identifier.scale
- A scale factor.- Returns:
- The image with the given style.
-
getScaledRiverImage
public java.awt.image.BufferedImage getScaledRiverImage(TileImprovementStyle style)
Returns the river image with the given style.- Parameters:
style
- aTileImprovementStyle
value- Returns:
- The image with the given style.
-
getScaledRiverImage
public java.awt.image.BufferedImage getScaledRiverImage(java.lang.String style)
-
getSmallerRiverImage
public java.awt.image.BufferedImage getSmallerRiverImage(java.lang.String style)
-
getRiverMouthImage
public java.awt.image.BufferedImage getRiverMouthImage(Direction direction, int magnitude, int x, int y)
Returns the river mouth terrain-image for the direction and magnitude.- Parameters:
direction
- aDirection
valuemagnitude
- anint
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).- Returns:
- The terrain-image at the given index.
-
getRiverStyleKeys
public static java.util.List<java.lang.String> getRiverStyleKeys(boolean all)
Get a list of river style image keys.- Parameters:
all
- If true accept all non-0000 keys.- Returns:
- A list of river style image keys.
-
getSettlementTypeKey
private static java.lang.String getSettlementTypeKey(SettlementType settlementType)
-
getSettlementTypeImage
private java.awt.image.BufferedImage getSettlementTypeImage(SettlementType settlementType, float scale)
-
getSettlementTypeImage
public java.awt.image.BufferedImage getSettlementTypeImage(SettlementType settlementType, java.awt.Dimension size)
-
getScaledSettlementTypeImage
public java.awt.image.BufferedImage getScaledSettlementTypeImage(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.
-
getSmallerSettlementTypeImage
public java.awt.image.BufferedImage getSmallerSettlementTypeImage(SettlementType settlementType)
-
getSettlementKey
public static java.lang.String getSettlementKey(Settlement settlement)
Get an image key for a settlement.- Parameters:
settlement
- TheSettlement
to examine.- Returns:
- An image key.
-
getSettlementImage
public java.awt.image.BufferedImage getSettlementImage(Settlement settlement, float scale)
Returns the graphics that will represent the given settlement.- Parameters:
settlement
- The settlement whose graphics type is needed.scale
- adouble
value- Returns:
- The graphics that will represent the given settlement.
-
getSettlementImage
public java.awt.image.BufferedImage getSettlementImage(Settlement settlement, java.awt.Dimension size)
-
getScaledSettlementImage
public java.awt.image.BufferedImage getScaledSettlementImage(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.
-
getSmallSettlementImage
public java.awt.image.BufferedImage getSmallSettlementImage(Settlement settlement)
-
getSmallerSettlementImage
public java.awt.image.BufferedImage getSmallerSettlementImage(Settlement settlement)
-
getTerrainImageKey
public static java.lang.String getTerrainImageKey(TileType type)
-
getTerrainImageInternal
private java.awt.image.BufferedImage getTerrainImageInternal(TileType type, int x, int y, java.awt.Dimension size)
Gets 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.size
- The image size.- Returns:
- The terrain-image at the given index.
-
getTerrainMask
public java.awt.image.BufferedImage getTerrainMask(Direction direction)
-
getTerrainImage
public java.awt.image.BufferedImage getTerrainImage(TileType type, int x, int y, java.awt.Dimension size)
-
getScaledTerrainImage
public java.awt.image.BufferedImage getScaledTerrainImage(TileType type, int x, int y)
-
getAnimatedScaledTerrainImage
public java.awt.image.BufferedImage getAnimatedScaledTerrainImage(TileType type, long ticks)
-
getAnimatedScaledWaterAndBeachTerrainImage
public java.awt.image.BufferedImage getAnimatedScaledWaterAndBeachTerrainImage(TileType type, java.util.List<Direction> directionsWithLand, long ticks)
Gets the combined animated image for ocean and beach.- Parameters:
type
- The tile type.directionsWithLand
- All directions where there are neighbouring land tiles.ticks
- The number of ticks to get the correct animation frame.- Returns:
- A cached, genereated image.
-
determineDirectionCombinationKey
private java.lang.String determineDirectionCombinationKey(java.util.List<Direction> directions)
Returns a string representing thedirections
given.- Parameters:
directions
- The directions that should be included- Returns:
- The directions in lowercase, ordered alphabetically and
combined with "_". Corners that are a part of a longSide is
not included in the returned
String
.
-
getTileImprovementImage
public java.awt.image.BufferedImage getTileImprovementImage(java.lang.String id)
Get the tile improvement image with for a given identifier.- Parameters:
id
- The tile improvement identifier.- Returns:
- The image found, or null if it does not exist.
-
getTileImageWithOverlayAndForest
public java.awt.image.BufferedImage getTileImageWithOverlayAndForest(TileType type, java.awt.Dimension size)
Get a scaled terrain-image for a terrain type (and position 0, 0). Called from MapeEditorTransformPanel.buildList- Parameters:
type
- The type of the terrain-image to return.size
- The maximum size of the terrain image to return.- Returns:
- The terrain-image
-
getUnitTypeImageKey
private static java.lang.String getUnitTypeImageKey(UnitType unitType, Player owner, java.lang.String roleId, boolean nativeEthnicity)
Get the unit image key for the given parameters.- Parameters:
unitType
- The type of unit to be represented.owner
- An optional owningPlayer
.roleId
- The id of the unit role.nativeEthnicity
- If true the unit is a former native.- Returns:
- A suitable key.
-
getUnitTypeImage
private java.awt.image.BufferedImage getUnitTypeImage(UnitType unitType, Player owner, java.lang.String roleId, boolean nativeEthnicity, boolean grayscale, float scale)
Fundamental unit image accessor.- Parameters:
unitType
- The type of unit to be represented.owner
- An optional owningPlayer
.roleId
- The id of the unit role.nativeEthnicity
- If true the unit is a former native.grayscale
- If true draw in inactive/disabled-looking state.scale
- How much the image is scaled.- Returns:
- A suitable
BufferedImage
.
-
getUnitTypeImage
private java.awt.image.BufferedImage getUnitTypeImage(UnitType unitType, float scale)
-
getUnitTypeImage
private java.awt.image.BufferedImage getUnitTypeImage(UnitType unitType, java.lang.String roleId, boolean nativeEthnicity, java.awt.Dimension size)
-
getUnitTypeImage
private java.awt.image.BufferedImage getUnitTypeImage(UnitType unitType, java.awt.Dimension size)
-
getScaledUnitTypeImage
public java.awt.image.BufferedImage getScaledUnitTypeImage(UnitType unitType)
-
getSmallUnitTypeImage
public java.awt.image.BufferedImage getSmallUnitTypeImage(UnitType unitType, java.lang.String roleId, boolean grayscale)
-
getSmallUnitTypeImage
public java.awt.image.BufferedImage getSmallUnitTypeImage(UnitType unitType, boolean grayscale)
-
getSmallUnitTypeImage
public java.awt.image.BufferedImage getSmallUnitTypeImage(UnitType unitType)
-
getSmallerUnitTypeImage
public java.awt.image.BufferedImage getSmallerUnitTypeImage(UnitType unitType)
-
getTinyUnitTypeImage
public java.awt.image.BufferedImage getTinyUnitTypeImage(UnitType unitType, boolean grayscale)
-
getTinyUnitTypeImage
public java.awt.image.BufferedImage getTinyUnitTypeImage(UnitType unitType)
-
getUnitImage
private java.awt.image.BufferedImage getUnitImage(Unit unit, boolean grayscale, float scale)
-
getScaledUnitImage
public java.awt.image.BufferedImage getScaledUnitImage(Unit unit, boolean grayscale)
-
getScaledUnitImage
public java.awt.image.BufferedImage getScaledUnitImage(Unit unit)
-
getSmallUnitImage
public java.awt.image.BufferedImage getSmallUnitImage(Unit unit, boolean grayscale)
-
getSmallUnitImage
public java.awt.image.BufferedImage getSmallUnitImage(Unit unit)
-
getSmallerUnitImage
public java.awt.image.BufferedImage getSmallerUnitImage(Unit unit)
-
getTinyUnitImage
public java.awt.image.BufferedImage getTinyUnitImage(Unit unit)
-
getAlarmChip
public java.awt.image.BufferedImage getAlarmChip(java.awt.Graphics2D g, IndianSettlement is, Player player)
Gets a chip image for the alarm at an Indian settlement. The background is either the native owner's, or that of the most-hatednation, if any.- Parameters:
g
- Graphics2D for getting the FontMetrics.is
- TheIndianSettlement
to check.player
- The observingPlayer
.- Returns:
- An alarm chip, or null if none suitable.
-
getIndianSettlementChip
public java.awt.image.BufferedImage getIndianSettlementChip(java.awt.Graphics2D g, IndianSettlement is)
Gets the owner chip for the settlement.- Parameters:
g
- Graphics2D for getting the FontMetrics.is
- TheIndianSettlement
to check.- Returns:
- A chip.
-
getMissionChip
public java.awt.image.BufferedImage getMissionChip(java.awt.Graphics2D g, Player owner, boolean expert)
Gets the mission chip for a native settlement.- Parameters:
g
- Graphics2D for getting the FontMetrics.owner
- The player that owns the mission.expert
- True if the unit is an expert.- Returns:
- A suitable chip, or null if no mission is present.
-
getOccupationIndicatorChip
public java.awt.image.BufferedImage getOccupationIndicatorChip(java.awt.Graphics2D g, Unit unit, java.lang.String text)
Gets a chip for an occupation indicator, i.e. a small image with a single letter or symbol that indicates the Unit's state.- Parameters:
g
- Graphics2D for getting the FontMetrics.unit
- TheUnit
with the occupation.text
- The text for the chip.- Returns:
- A suitable chip.
-
createChip
private java.awt.image.BufferedImage createChip(java.awt.Graphics2D g, java.lang.String text, java.awt.Color border, java.awt.Color background, double amount, java.awt.Color fill, java.awt.Color foreground, boolean filled)
Create a "chip" with the given text and colors.- Parameters:
g
- Graphics2D for getting the FontMetrics.text
- The text to display.border
- The borderColor
.background
- The backgroundColor
.amount
- How much to fill the chip with the fill colorfill
- The fillColor
.foreground
- The foregroundColor
.filled
- Whether the chip is filled or not- Returns:
- A chip.
-
getStringImage
public java.awt.image.BufferedImage getStringImage(java.awt.Graphics g, java.lang.String text, java.awt.Color color, java.awt.Font font)
Gets an image with a string of a given color and with a black border around the glyphs.- Parameters:
g
- AGraphics
-object for getting the font metrics.text
- TheString
to make an image of.color
- TheColor
to use for the text.font
- TheFont
to display the text with.- Returns:
- The
BufferedImage
found or created.
-
createStringImage
private java.awt.image.BufferedImage createStringImage(java.lang.String text, java.awt.Color color, java.awt.Font font, java.awt.FontMetrics fm)
Create a string image.- Parameters:
text
- TheString
to make an image of.color
- TheColor
to use for the text.font
- TheFont
to display the text with.fm
- TheFontMetrics
to use with the font.- Returns:
- The image that was created.
-
getVideo
public static Video getVideo(java.lang.String key)
-
-