net.sf.freecol.client.gui.panel
Class FreeColImageBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by 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
static FreeColImageBorder imageBorder
           
 
Constructor Summary
FreeColImageBorder(java.awt.Image topImage, java.awt.Image leftImage, java.awt.Image bottomImage, java.awt.Image rightImage, java.awt.Image topLeftCornerImage, java.awt.Image topRightCornerImage, java.awt.Image bottomLeftCornerImage, java.awt.Image bottomRightCornerImage)
          Creates a border with the given set of images.
Converts the Image objects to BufferedImage, because the images will be used as Textures for the border.
 
Method Summary
 void fillTexture(java.awt.Graphics2D g2, java.awt.image.BufferedImage img, int x, int y, int width, int height)
          Fills a certain rectangle with the image texture.
 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.
 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.
 
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getInteriorRectangle, getInteriorRectangle, isBorderOpaque
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageBorder

public static final FreeColImageBorder imageBorder
Constructor Detail

FreeColImageBorder

public FreeColImageBorder(java.awt.Image topImage,
                          java.awt.Image leftImage,
                          java.awt.Image bottomImage,
                          java.awt.Image rightImage,
                          java.awt.Image topLeftCornerImage,
                          java.awt.Image topRightCornerImage,
                          java.awt.Image bottomLeftCornerImage,
                          java.awt.Image bottomRightCornerImage)
Creates a border with the given set of images.
Converts the Image objects to BufferedImage, because the images will be used as Textures for the border.

Method Detail

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c)
Gets the insets of this border around the given component.

Specified by:
getBorderInsets in interface javax.swing.border.Border
Overrides:
getBorderInsets in class javax.swing.border.AbstractBorder
Parameters:
c - The Component 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 class javax.swing.border.AbstractBorder
Parameters:
c - The Component having the border.
insets - An instance of Insets to be updated.
Returns:
The given instance of Insets if not null, 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 interface javax.swing.border.Border
Overrides:
paintBorder in class javax.swing.border.AbstractBorder
Parameters:
c - The Component to draw the border on.
g - The Graphics 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.

fillTexture

public void fillTexture(java.awt.Graphics2D g2,
                        java.awt.image.BufferedImage img,
                        int x,
                        int y,
                        int width,
                        int height)
Fills a certain rectangle with the image texture.

Parameters:
g2 - The Graphics used for painting the border.
img - The BufferedImage to fill the texture.
x - The x-component of the offset.
y - The y-component of the offset.
width - The width of the rectangle.
height - The height of the rectangle.