public abstract class FigureDecorator extends AbstractFigureContainer
This class is a reasonable example of the Decorator design pattern, hence its name.
| Constructor and Description |
|---|
FigureDecorator() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Figure f)
Add a figure.
|
boolean |
contains(Figure f)
Test if the given figure is the one contained by this decorator.
|
Iterator |
figures()
Return an iteration containing the one child.
|
Iterator |
figuresFromBack()
Return an iteration containing the one child.
|
Iterator |
figuresFromFront()
Return an iteration containing the one child.
|
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.
|
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(Rectangle2D r)
Test if the child is hit.
|
abstract FigureDecorator |
newInstance(Figure f)
Create a new instance of this figure decorator, modelled
on this one.
|
void |
paint(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(AffineTransform at)
Transform the figure with the supplied transform.
|
decorate, pick, pick, repaint, translate, undecoratecontains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisVisible, paint, setVisiblegetParent, getTransformContext, repaintpublic void add(Figure f)
public boolean contains(Figure f)
contains in interface FigureContainercontains in interface FigureSetcontains in class AbstractFigureContainerpublic Iterator figures()
figures in interface FigureSetfigures in class AbstractFigureContainerpublic Iterator figuresFromBack()
figuresFromBack in interface FigureSetfiguresFromBack in class AbstractFigureContainerpublic Iterator figuresFromFront()
figuresFromFront in interface FigureSetfiguresFromFront in class AbstractFigureContainerpublic 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 Shape getShape()
getShape in interface FiguregetShape in class AbstractFigurepublic boolean hit(Rectangle2D r)
hit in interface Figurehit in class AbstractFigurepublic abstract FigureDecorator newInstance(Figure f)
public void paint(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(AffineTransform at)
transform in interface Figuretransform in class AbstractFigureContainerCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.