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
private  java.awt.image.BufferedImage bottomImage
           
private  java.awt.image.BufferedImage bottomLeftCornerImage
           
private  java.awt.image.BufferedImage bottomRightCornerImage
           
static FreeColImageBorder imageBorder
           
private  java.awt.image.BufferedImage leftImage
           
private  java.awt.image.BufferedImage rightImage
           
private  java.awt.image.BufferedImage topImage
           
private  java.awt.image.BufferedImage topLeftCornerImage
           
private  java.awt.image.BufferedImage topRightCornerImage
           
 
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
private  java.awt.image.BufferedImage createBufferedImage(java.awt.Image img)
          Creates a buffered image out of a given Image object.
 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.
private  int getHeight(java.awt.Image im)
          Get the height of an image.
private  int getWidth(java.awt.Image im)
          Get the width of an image.
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topImage

private java.awt.image.BufferedImage topImage

leftImage

private java.awt.image.BufferedImage leftImage

bottomImage

private java.awt.image.BufferedImage bottomImage

rightImage

private java.awt.image.BufferedImage rightImage

topLeftCornerImage

private java.awt.image.BufferedImage topLeftCornerImage

topRightCornerImage

private java.awt.image.BufferedImage topRightCornerImage

bottomLeftCornerImage

private java.awt.image.BufferedImage bottomLeftCornerImage

bottomRightCornerImage

private java.awt.image.BufferedImage bottomRightCornerImage

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

createBufferedImage

private java.awt.image.BufferedImage createBufferedImage(java.awt.Image img)
Creates a buffered image out of a given Image object.

Parameters:
img - The Image object.
Returns:
The created BufferedImage object.

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.

getHeight

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

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.