|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdiva.canvas.AbstractFigure
diva.canvas.AbstractFigureContainer
diva.canvas.FigureDecorator
public abstract class FigureDecorator
A FigureDecorator is a figure container that contains a single child figure. The purpose of a FigureDecorator is to change or affect the way in which the child is rendered, and so this class behaves somewhat differently to other figures.
This class is a reasonable example of the Decorator design pattern, hence its name.
| Red |
| Field Summary | |
|---|---|
private Figure |
_child
The child |
| Constructor Summary | |
|---|---|
FigureDecorator()
|
|
| Method Summary | |
|---|---|
void |
add(Figure f)
Add a figure. |
boolean |
contains(Figure f)
Test if the given figure is the one contained by this decorator. |
java.util.Iterator |
figures()
Return an iteration containing the one child. |
java.util.Iterator |
figuresFromBack()
Return an iteration containing the one child. |
java.util.Iterator |
figuresFromFront()
Return an iteration containing the one child. |
java.awt.geom.Rectangle2D |
getBounds()
Get the bounds of this figure, which is by default the same as the child figure, if there is one, or a very small rectangle if there isn't. |
Figure |
getChild()
Get the child figure, or null if there isn't one. |
FigureContainer |
getContainer()
Get the container, which is defined as the lowest ancestor that is not a FigureDecorator. |
Figure |
getDecoratedFigure()
Get the decorated figure, which is defined as the highest descendent that is not a decorator. |
int |
getFigureCount()
Return zero if there is no child, or one if there is. |
java.awt.Shape |
getShape()
Get the outline shape of this figure, which is by default the same as the child figure, if there is one, or a very small rectangle if there isn't. |
boolean |
hit(java.awt.geom.Rectangle2D r)
Test if the child is hit. |
abstract FigureDecorator |
newInstance(Figure f)
Create a new instance of this figure decorator, modeled on this one. |
void |
paint(java.awt.Graphics2D g)
Paint the figure. |
void |
remove(Figure f)
Remove a figure. |
protected void |
replaceChild(Figure child,
Figure replacement)
Replace the first figure, which must be a child, with the second, which must not be a child. |
void |
setChild(Figure f)
Set the child figure. |
void |
transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform. |
void |
translate(double x,
double y)
Translate the figure by the given distance. |
| Methods inherited from class diva.canvas.AbstractFigureContainer |
|---|
decorate, pick, pick, repaint, undecorate |
| Methods inherited from class diva.canvas.AbstractFigure |
|---|
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface diva.canvas.VisibleComponent |
|---|
isVisible, paint, setVisible |
| Methods inherited from interface diva.canvas.CanvasComponent |
|---|
getParent, getTransformContext, repaint |
| Field Detail |
|---|
private Figure _child
| Constructor Detail |
|---|
public FigureDecorator()
| Method Detail |
|---|
public void add(Figure f)
public boolean contains(Figure f)
contains in interface FigureContainercontains in interface FigureSetcontains in class AbstractFigureContainerpublic java.util.Iterator figures()
figures in interface FigureSetfigures in class AbstractFigureContainerpublic java.util.Iterator figuresFromBack()
figuresFromBack in interface FigureSetfiguresFromBack in class AbstractFigureContainerpublic java.util.Iterator figuresFromFront()
figuresFromFront in interface FigureSetfiguresFromFront in class AbstractFigureContainerpublic java.awt.geom.Rectangle2D getBounds()
getBounds in interface FiguregetBounds in class AbstractFigurepublic Figure getChild()
public FigureContainer getContainer()
public Figure getDecoratedFigure()
public int getFigureCount()
getFigureCount in interface FigureContainergetFigureCount in class AbstractFigureContainerpublic java.awt.Shape getShape()
getShape in interface FiguregetShape in class AbstractFigurepublic boolean hit(java.awt.geom.Rectangle2D r)
hit in interface Figurehit in class AbstractFigurepublic abstract FigureDecorator newInstance(Figure f)
public void paint(java.awt.Graphics2D g)
paint in interface VisibleComponentpaint in class AbstractFigureContainerpublic void setChild(Figure f)
public void remove(Figure f)
protected void replaceChild(Figure child,
Figure replacement)
replaceChild in class AbstractFigureContainerpublic void transform(java.awt.geom.AffineTransform at)
transform in interface Figuretransform in class AbstractFigureContainer
public void translate(double x,
double y)
translate in interface Figuretranslate in class AbstractFigureContainer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||