Package net.sf.freecol.client.gui.panel
Class FreeColImageBorder
- java.lang.Object
-
- javax.swing.border.AbstractBorder
-
- net.sf.freecol.client.gui.panel.FreeColImageBorder
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.border.Border
public class FreeColImageBorder extends javax.swing.border.AbstractBorder
A border created from a set of images.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
baseKey
The key used for getting the image resources.private static java.util.List<FreeColImageBorder>
borders
private java.awt.image.BufferedImage
bottomImage
S-borderprivate java.awt.image.BufferedImage
bottomLeftCornerImage
SW-cornerprivate java.awt.image.BufferedImage
bottomRightCornerImage
SE-cornerstatic FreeColImageBorder
buttonBorder
private boolean
initialized
private java.awt.image.BufferedImage
leftImage
W-borderstatic FreeColImageBorder
menuBarBorder
private boolean
noScaling
If true, no scaling to the border is applied.static FreeColImageBorder
panelBorder
static FreeColImageBorder
panelWithoutShadowBorder
private java.awt.image.BufferedImage
rightImage
E-borderprivate static float
scaleFactor
static FreeColImageBorder
simpleButtonBorder
private java.awt.image.BufferedImage
topImage
N-borderprivate java.awt.image.BufferedImage
topLeftCornerImage
NW-cornerprivate java.awt.image.BufferedImage
topRightCornerImage
NE-corner
-
Constructor Summary
Constructors Modifier Constructor Description private
FreeColImageBorder(java.lang.String baseKey)
private
FreeColImageBorder(java.lang.String baseKey, boolean noScaling)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
ensureInitialized()
java.awt.Insets
getBorderInsets(java.awt.Component c)
Gets the insets of this border around the given component.java.awt.Insets
getBorderInsets(java.awt.Component c, java.awt.Insets insets)
Gets the insets of this border around the given component.private static int
getHeight(java.awt.Image im)
Get the height of an image.private java.awt.image.BufferedImage
getImage(java.lang.String key)
private static int
getWidth(java.awt.Image im)
Get the width of an image.private void
loadImages()
private void
loadImages(java.awt.image.BufferedImage topLeftCornerImage, java.awt.image.BufferedImage topImage, java.awt.image.BufferedImage topRightCornerImage, java.awt.image.BufferedImage rightImage, java.awt.image.BufferedImage bottomRightCornerImage, java.awt.image.BufferedImage bottomImage, java.awt.image.BufferedImage bottomLeftCornerImage, java.awt.image.BufferedImage leftImage)
Loads the images for the border.void
paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
Paints the border on the given component.private static void
reloadAllImages()
static void
setScaleFactor(float scaleFactor)
-
-
-
Field Detail
-
borders
private static final java.util.List<FreeColImageBorder> borders
-
panelWithoutShadowBorder
public static final FreeColImageBorder panelWithoutShadowBorder
-
panelBorder
public static final FreeColImageBorder panelBorder
-
buttonBorder
public static final FreeColImageBorder buttonBorder
-
simpleButtonBorder
public static final FreeColImageBorder simpleButtonBorder
-
menuBarBorder
public static final FreeColImageBorder menuBarBorder
-
scaleFactor
private static float scaleFactor
-
baseKey
private final java.lang.String baseKey
The key used for getting the image resources.
-
noScaling
private final boolean noScaling
If true, no scaling to the border is applied.
-
initialized
private boolean initialized
-
topLeftCornerImage
private java.awt.image.BufferedImage topLeftCornerImage
NW-corner
-
topImage
private java.awt.image.BufferedImage topImage
N-border
-
topRightCornerImage
private java.awt.image.BufferedImage topRightCornerImage
NE-corner
-
rightImage
private java.awt.image.BufferedImage rightImage
E-border
-
bottomRightCornerImage
private java.awt.image.BufferedImage bottomRightCornerImage
SE-corner
-
bottomImage
private java.awt.image.BufferedImage bottomImage
S-border
-
bottomLeftCornerImage
private java.awt.image.BufferedImage bottomLeftCornerImage
SW-corner
-
leftImage
private java.awt.image.BufferedImage leftImage
W-border
-
-
Method Detail
-
ensureInitialized
private void ensureInitialized()
-
loadImages
private void loadImages()
-
loadImages
private void loadImages(java.awt.image.BufferedImage topLeftCornerImage, java.awt.image.BufferedImage topImage, java.awt.image.BufferedImage topRightCornerImage, java.awt.image.BufferedImage rightImage, java.awt.image.BufferedImage bottomRightCornerImage, java.awt.image.BufferedImage bottomImage, java.awt.image.BufferedImage bottomLeftCornerImage, java.awt.image.BufferedImage leftImage)
Loads the images for the border.- Parameters:
topLeftCornerImage
- NW-cornertopImage
- N-bordertopRightCornerImage
- NE-cornerrightImage
- E-borderbottomRightCornerImage
- SE-cornerbottomImage
- S-borderbottomLeftCornerImage
- SW-cornerleftImage
- W-border
-
setScaleFactor
public static void setScaleFactor(float scaleFactor)
-
reloadAllImages
private static void reloadAllImages()
-
getImage
private java.awt.image.BufferedImage getImage(java.lang.String key)
-
getBorderInsets
public java.awt.Insets getBorderInsets(java.awt.Component c)
Gets the insets of this border around the given component.- Specified by:
getBorderInsets
in interfacejavax.swing.border.Border
- Overrides:
getBorderInsets
in classjavax.swing.border.AbstractBorder
- Parameters:
c
- TheComponent
having the border.- Returns:
- The
Insets
.
-
getBorderInsets
public java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets)
Gets the insets of this border around the given component.- Overrides:
getBorderInsets
in classjavax.swing.border.AbstractBorder
- Parameters:
c
- TheComponent
having the border.insets
- An instance ofInsets
to be updated.- Returns:
- The given instance of
Insets
if notnull
, or a new instance otherwise.
-
paintBorder
public void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
Paints the border on the given component.- Specified by:
paintBorder
in interfacejavax.swing.border.Border
- Overrides:
paintBorder
in classjavax.swing.border.AbstractBorder
- Parameters:
c
- TheComponent
to draw the border on.g
- TheGraphics
used for painting the border.x
- The x-component of the offset.y
- The y-component of the offset.width
- The width of the border.height
- The height of the border.
-
getHeight
private static int getHeight(java.awt.Image im)
Get the height of an image. If image is null, return 0.- Parameters:
im
- The image.- Returns:
- The height of the image.
-
getWidth
private static int getWidth(java.awt.Image im)
Get the width of an image. If image is null, return 0.- Parameters:
im
- The image.- Returns:
- The width of the image.
-
-