|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
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 FigureContainer
contains
in interface FigureSet
contains
in class AbstractFigureContainer
public java.util.Iterator figures()
figures
in interface FigureSet
figures
in class AbstractFigureContainer
public java.util.Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
figuresFromBack
in class AbstractFigureContainer
public java.util.Iterator figuresFromFront()
figuresFromFront
in interface FigureSet
figuresFromFront
in class AbstractFigureContainer
public java.awt.geom.Rectangle2D getBounds()
getBounds
in interface Figure
getBounds
in class AbstractFigure
public Figure getChild()
public FigureContainer getContainer()
public Figure getDecoratedFigure()
public int getFigureCount()
getFigureCount
in interface FigureContainer
getFigureCount
in class AbstractFigureContainer
public java.awt.Shape getShape()
getShape
in interface Figure
getShape
in class AbstractFigure
public boolean hit(java.awt.geom.Rectangle2D r)
hit
in interface Figure
hit
in class AbstractFigure
public abstract FigureDecorator newInstance(Figure f)
public void paint(java.awt.Graphics2D g)
paint
in interface VisibleComponent
paint
in class AbstractFigureContainer
public void setChild(Figure f)
public void remove(Figure f)
protected void replaceChild(Figure child, Figure replacement)
replaceChild
in class AbstractFigureContainer
public void transform(java.awt.geom.AffineTransform at)
transform
in interface Figure
transform
in class AbstractFigureContainer
public void translate(double x, double y)
translate
in interface Figure
translate
in class AbstractFigureContainer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |