|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.birosoft.liquid.skin.SkinElement
com.birosoft.liquid.skin.Skin
public class Skin
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.
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 |
---|
public Skin(java.lang.String fileName, int nrImages, int ulX, int ulY, int lrX, int lrY)
nrImages
. The scaling region of the image is given
by ulX,ulY,lrX,lrY
fileName
- the filename of the image filenrImages
- the number of subimages in the image fileulX
- the distance from the left edge to the scaling region of the skinulY
- the distance from the top edge to the scaling region of the skinlrX
- the distance from the right edge to the scaling region of the skinlrY
- the distance from the bottom edge to the scaling region of the skinpublic Skin(java.lang.String fileName, int nrImages, int roundedSize)
nrImages
. The size of the corners is given
by roundedSize.
fileName
- the filename of the image filenrImages
- the number of subimages in the image filerounded
- the distance from the each edge to the scaling region of the skinMethod Detail |
---|
public void draw(java.awt.Graphics g, int index, int sizeX, int sizeY)
g
- index
- index of the image in the skin filesizeX
- horizontal size of the componentsizeY
- vertical size of the componentpublic void draw(java.awt.Graphics g, int index, int x, int y, int sizeX, int sizeY)
g
- index
- index of the image in the skin filex
- x coordiante of the point where the skin is paintedy
- y coordiante of the point where the skin is paintedsizeX
- horizontal size of the componentsizeY
- vertical size of the componentpublic void drawCentered(java.awt.Graphics g, int index, int sizeX, int sizeY)
g
- index
- index of the image in the skin filesizeX
- horizontal size of the componentsizeY
- vertical size of the componentpublic void drawCentered(java.awt.Graphics g, int index, int x, int y, int sizeX, int sizeY)
g
- index
- index of the image in the skin filex
- x coordiante of the point where the skin is paintedy
- y coordiante of the point where the skin is paintedsizeX
- horizontal size of the componentsizeY
- vertical size of the componentpublic int getHsize()
public int getVsize()
public java.awt.Dimension getSize()
protected void calculateSizes()
public void colourImage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |