com.birosoft.liquid.skin
Class Skin

java.lang.Object
  extended by com.birosoft.liquid.skin.SkinElement
      extended by com.birosoft.liquid.skin.Skin

public class Skin
extends SkinElement

This class is for a skin that can be used to "skin" a component. It's most important feature is to draw an image that can be scaled to fit onto the component. All in all there are nine regions that are treated differently. These regions can be grouped in three cases: 1. The corners are not stretched at all, but take the space as described by the members ulX,ulY,lrX and lrY. They denote the distance from the corner of the image to the rectangle that will be scaled to fit the component. This means that the rectangle (0,0)-(ulX,ulY) will not be scaled at all, the rectangle (ulX,0)-(sizeX-lrX-1,ulY) is scaled only horizontally and (sizeX-lrX,ulY) will not be scaled again. For the upper left corner this means that the Rectangle (0,0) - (ulX,ulY) is painted with the same rectangle from the skin image. 2. The edges of the component. These are the rectangles that fit in between the corners. They will be stretched but only either horizontally or vertically. 3. The center. This is the remaining space of the skin. It will be scaled both horizontally and vertically. Note that if ulX,ulY,lrX and lrY are set to zero there will be a optimization to improve speed for components that have a fixed size (The skin should be as big as the component in this case). Each skin file consists of several images that are place next to each other. The constructor for Skin takes the number of images as an argument. When the skin is painted there's an argument for the index of the subimage to be used. The index starts with 0.

See Also:
com.stefankrause.xplookandfeel.skin.SkinSimpleButtonIndexModel, com.stefankrause.xplookandfeel.skin.SkinToggleButtonIndexModel

Constructor Summary
Skin(java.lang.String fileName, int nrImages, int roundedSize)
          Creates a new skin from the image file with fileName fileName and the number of images passed in nrImages.
Skin(java.lang.String fileName, int nrImages, int ulX, int ulY, int lrX, int lrY)
          Creates a new skin from the image file with fileName fileName and the number of images passed in nrImages.
 
Method Summary
protected  void calculateSizes()
          Calculates the size for each subimage
 void colourImage()
           
 void draw(java.awt.Graphics g, int index, int sizeX, int sizeY)
          Use the image with index index to paint the component with size sizeX, sizeY
 void draw(java.awt.Graphics g, int index, int x, int y, int sizeX, int sizeY)
          Use the image with index index to paint the component at point x, y with dimension sizeX, sizeY
 void drawCentered(java.awt.Graphics g, int index, int sizeX, int sizeY)
          Use the image with index index to paint the component with its natural size centred in a rectangle with dimension sizeX, sizeY
 void drawCentered(java.awt.Graphics g, int index, int x, int y, int sizeX, int sizeY)
          Use the image with index index to paint the component with its natural size centred in a rectangle with dimension sizeX, sizeY
 int getHsize()
          Returns the horizontal size of the skin, this is the width of each subimage
 java.awt.Dimension getSize()
          Returns the size of the skin, this is the height of each subimage
 int getVsize()
          Returns the vertical size of the skin, this is the height of each subimage
 
Methods inherited from class com.birosoft.liquid.skin.SkinElement
getFilename, getImage, setFilename, setImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Skin

public Skin(java.lang.String fileName,
            int nrImages,
            int ulX,
            int ulY,
            int lrX,
            int lrY)
Creates a new skin from the image file with fileName fileName and the number of images passed in nrImages. The scaling region of the image is given by ulX,ulY,lrX,lrY

Parameters:
fileName - the filename of the image file
nrImages - the number of subimages in the image file
ulX - the distance from the left edge to the scaling region of the skin
ulY - the distance from the top edge to the scaling region of the skin
lrX - the distance from the right edge to the scaling region of the skin
lrY - the distance from the bottom edge to the scaling region of the skin

Skin

public Skin(java.lang.String fileName,
            int nrImages,
            int roundedSize)
Creates a new skin from the image file with fileName fileName and the number of images passed in nrImages. The size of the corners is given by roundedSize.

Parameters:
fileName - the filename of the image file
nrImages - the number of subimages in the image file
rounded - the distance from the each edge to the scaling region of the skin
Method Detail

draw

public void draw(java.awt.Graphics g,
                 int index,
                 int sizeX,
                 int sizeY)
Use the image with index index to paint the component with size sizeX, sizeY

Parameters:
g -
index - index of the image in the skin file
sizeX - horizontal size of the component
sizeY - vertical size of the component

draw

public void draw(java.awt.Graphics g,
                 int index,
                 int x,
                 int y,
                 int sizeX,
                 int sizeY)
Use the image with index index to paint the component at point x, y with dimension sizeX, sizeY

Parameters:
g -
index - index of the image in the skin file
x - x coordiante of the point where the skin is painted
y - y coordiante of the point where the skin is painted
sizeX - horizontal size of the component
sizeY - vertical size of the component

drawCentered

public void drawCentered(java.awt.Graphics g,
                         int index,
                         int sizeX,
                         int sizeY)
Use the image with index index to paint the component with its natural size centred in a rectangle with dimension sizeX, sizeY

Parameters:
g -
index - index of the image in the skin file
sizeX - horizontal size of the component
sizeY - vertical size of the component

drawCentered

public void drawCentered(java.awt.Graphics g,
                         int index,
                         int x,
                         int y,
                         int sizeX,
                         int sizeY)
Use the image with index index to paint the component with its natural size centred in a rectangle with dimension sizeX, sizeY

Parameters:
g -
index - index of the image in the skin file
x - x coordiante of the point where the skin is painted
y - y coordiante of the point where the skin is painted
sizeX - horizontal size of the component
sizeY - vertical size of the component

getHsize

public int getHsize()
Returns the horizontal size of the skin, this is the width of each subimage

Returns:
int

getVsize

public int getVsize()
Returns the vertical size of the skin, this is the height of each subimage

Returns:
int

getSize

public java.awt.Dimension getSize()
Returns the size of the skin, this is the height of each subimage

Returns:
Dimension

calculateSizes

protected void calculateSizes()
Calculates the size for each subimage


colourImage

public void colourImage()