|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbecker.robots.icons.Icon
becker.robots.icons.CompositeIcon
public class CompositeIcon
A CompositeIcon is composed of two or more icons which, taken
together, form the desired icon. An example is StreetlightIcon
which composes one icon for the streetlight's post with another for
the light.
Field Summary |
---|
Fields inherited from class becker.robots.icons.Icon |
---|
transparent |
Constructor Summary | |
---|---|
CompositeIcon(Icon[] icons)
Construct a new CompositeIcon out of an array of icons. |
|
CompositeIcon(Icon background,
Icon foreground)
Construct a new CompositeIcon out of two icons. |
Method Summary | |
---|---|
protected void |
applyTransforms(Graphics2D g2,
int width,
int height,
double rotation,
double relSize)
Apply translations, scaling and rotation to g2 in preparation for rendering the image. |
Icon |
componentIcon(int index)
Obtain a reference to one of the component icons, perhaps so it can be modified. |
Color |
getColor()
Returns null. |
boolean |
hasChanged()
Has this icon changed since it was last rendered? |
protected void |
markChanged()
Mark this icon as changed so it is rendered again. |
int |
numComponents()
Determine the number of component icons in this composite icon. |
protected void |
renderImage(Graphics2D g2,
int width,
int height)
Override either this method or Icon.paintIcon(java.awt.Graphics) to specify how the
icon looks. |
void |
setColor(Color c)
Has no effect. |
Methods inherited from class becker.robots.icons.Icon |
---|
getImage, getLabel, getRotation, getSize, getTransparency, paintIcon, setLabel, setSize, setTransparency |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompositeIcon(Icon background, Icon foreground)
background
- the icon to draw in the background.foreground
- the icon to draw in front of the background.public CompositeIcon(Icon[] icons)
icons
- the icons which compose this composite icon.
icons.length >= 1Method Detail |
---|
protected void renderImage(Graphics2D g2, int width, int height)
Icon
Icon.paintIcon(java.awt.Graphics)
to specify how the
icon looks. For this method, the upper left corner
of the icon has coordinates (0,0). The width and height are both 1.0.
renderImage
in class Icon
g2
- the graphics context where the icon should be drawn.width
- the number of pixels wide the image will beheight
- the number of pixels high the image will beprotected void applyTransforms(Graphics2D g2, int width, int height, double rotation, double relSize)
Icon
g2.translate(width/2.0, height/2.0); g2.scale(width*this.relSize, height*this.relSize); g2.rotate(rotation); g2.translate( - 0.5, - 0.5); g2.setStroke(new BasicStroke(1.0F / width));
applyTransforms
in class Icon
g2
- The graphics context to apply transformations towidth
- the width (in pixels) of the iconheight
- the height (in pixels) of the iconrotation
- the rotation of the icon, in radiansrelSize
- the relative size (0.0 < relSize <= 1.0) of the iconprotected void markChanged()
Icon
markChanged
in class Icon
public boolean hasChanged()
Icon
hasChanged
in class Icon
public Icon componentIcon(int index)
index
- which component icon to return.
0 <= index < this.numComponents().public int numComponents()
public Color getColor()
Color c = compositeIcon.componentIcon(0).getColor();
getColor
in class Icon
public void setColor(Color c)
Color c = compositeIcon.componentIcon(0).setColor(newColor);
setColor
in class Icon
c
- The new color.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |