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, undecorate
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isVisible, paint, setVisible
getParent, getTransformContext, repaint
public void add(Figure f)
public boolean contains(Figure f)
contains
in interface FigureContainer
contains
in interface FigureSet
contains
in class AbstractFigureContainer
public Iterator figures()
figures
in interface FigureSet
figures
in class AbstractFigureContainer
public Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
figuresFromBack
in class AbstractFigureContainer
public Iterator figuresFromFront()
figuresFromFront
in interface FigureSet
figuresFromFront
in class AbstractFigureContainer
public 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 Shape getShape()
getShape
in interface Figure
getShape
in class AbstractFigure
public boolean hit(Rectangle2D r)
hit
in interface Figure
hit
in class AbstractFigure
public abstract FigureDecorator newInstance(Figure f)
public void paint(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(AffineTransform at)
transform
in interface Figure
transform
in class AbstractFigureContainer
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.