Package diva.canvas
Class AbstractFigureContainer
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.AbstractFigureContainer
-
- All Implemented Interfaces:
CanvasComponent,Figure,FigureContainer,FigureSet,VisibleComponent,UserObjectContainer
- Direct Known Subclasses:
CompositeFigure,FigureDecorator
public abstract class AbstractFigureContainer extends AbstractFigure implements FigureContainer
AbstractFigureContainer is an abstract class that roots the tree of figure-containing classes.- Version:
- $Id$
- Author:
- John Reekie
- Pt.AcceptedRating:
- Yellow
-
-
Constructor Summary
Constructors Constructor Description AbstractFigureContainer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleancontains(Figure f)Test if the given figure is a child of this composite.voiddecorate(Figure child, FigureDecorator decorator)Decorate a child figure, replacing the reference to the child figure with the decorator.abstract java.util.Iteratorfigures()Return an iteration of the children, in an undefined order.abstract java.util.IteratorfiguresFromBack()Return an iteration of the children, from back to front.abstract java.util.IteratorfiguresFromFront()Return an iteration of the children, from front to back.abstract intgetFigureCount()Return the number of child figures in this container.voidpaint(java.awt.Graphics2D g)Paint this composite figure onto a 2D graphics object.Figurepick(java.awt.geom.Rectangle2D region)Given a rectangle, return the top-most descendent figure that it hits.Figurepick(java.awt.geom.Rectangle2D region, Filter filter)Given a rectangle, return the top-most descendent figure that it hits that is accepted by the given filter.voidrepaint(DamageRegion d)Accept notification that a repaint has occurred somewhere in the hierarchy below this container.protected abstract voidreplaceChild(Figure child, Figure replacement)Replace the first figure with the second.voidtransform(java.awt.geom.AffineTransform at)Transform this figure with the supplied transform.voidtranslate(double x, double y)Translate this figure by the given distance.voidundecorate(FigureDecorator decorator)Remove a figure from the given decorator and add it back into this container.-
Methods inherited from class diva.canvas.AbstractFigure
contains, getBounds, getInteractor, getLayer, getOrigin, getParent, getShape, getToolTipText, getTransformContext, getUserObject, hit, 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.CanvasComponent
getTransformContext, repaint
-
Methods inherited from interface diva.canvas.FigureContainer
add, remove
-
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
-
-
-
-
Method Detail
-
decorate
public void decorate(Figure child, FigureDecorator decorator)
Decorate a child figure, replacing the reference to the child figure with the decorator.- Specified by:
decoratein interfaceFigureContainer- Parameters:
child- The child figure.decorator- The decorator.
-
contains
public abstract boolean contains(Figure f)
Test if the given figure is a child of this composite.- Specified by:
containsin interfaceFigureContainer- Specified by:
containsin interfaceFigureSet- Parameters:
f- The figure to be searched for- Returns:
- true if the figure is contained.
-
figures
public abstract java.util.Iterator figures()
Return an iteration of the children, in an undefined order.
-
figuresFromBack
public abstract java.util.Iterator figuresFromBack()
Return an iteration of the children, from back to front. This is the order in which the children are painted.- Specified by:
figuresFromBackin interfaceFigureSet- Returns:
- The iterator
-
figuresFromFront
public abstract java.util.Iterator figuresFromFront()
Return an iteration of the children, from front to back. This is the order in which events are intercepted.- Specified by:
figuresFromFrontin interfaceFigureSet- Returns:
- The iterator
-
getFigureCount
public abstract int getFigureCount()
Return the number of child figures in this container.- Specified by:
getFigureCountin interfaceFigureContainer- Returns:
- The number of figures.
-
paint
public void paint(java.awt.Graphics2D g)
Paint this composite figure onto a 2D graphics object. If the layer is not visible, return immediately. Otherwise paint all children from back to front.- Specified by:
paintin interfaceVisibleComponent- Specified by:
paintin classAbstractFigure- Parameters:
g- The 2D graphics object that this object it to be painted upon.
-
pick
public Figure pick(java.awt.geom.Rectangle2D region)
Given a rectangle, return the top-most descendent figure that it hits. If none does, return null.- Specified by:
pickin interfaceFigureContainer- Parameters:
region- The rectangle- Returns:
- The figure
-
pick
public Figure pick(java.awt.geom.Rectangle2D region, Filter filter)
Given a rectangle, return the top-most descendent figure that it hits that is accepted by the given filter. If none does, return null.- Specified by:
pickin interfaceFigureContainer- Parameters:
region- The rectanglefilter- The filter- Returns:
- the Figure or null.
-
repaint
public void repaint(DamageRegion d)
Accept notification that a repaint has occurred somewhere in the hierarchy below this container. This default implementation simply forwards the notification to its parent.- Specified by:
repaintin interfaceCanvasComponent- Overrides:
repaintin classAbstractFigure- Parameters:
d- The region where a repaint has occurred.
-
replaceChild
protected abstract void replaceChild(Figure child, Figure replacement)
Replace the first figure with the second. This is a hook method for the decorate() and undecorate() methods, and should not be called by other methods. Implementors can assume that the first figure is a child of this container, and that the second is not.- Parameters:
child- The figure to be replaced.replacement- The replacement figure.
-
transform
public void transform(java.awt.geom.AffineTransform at)
Transform this figure with the supplied transform. This default implementation simply forwards the transform call to each child.- Specified by:
transformin interfaceFigure- Specified by:
transformin classAbstractFigure- Parameters:
at- The transform to be used.
-
translate
public void translate(double x, double y)Translate this figure by the given distance. This default implementation simply forwards the translate call to each child.- Specified by:
translatein interfaceFigure- Overrides:
translatein classAbstractFigure- Parameters:
x- The x value to be moved.y- The y value to be moved.
-
undecorate
public void undecorate(FigureDecorator decorator)
Remove a figure from the given decorator and add it back into this container.- Specified by:
undecoratein interfaceFigureContainer- Parameters:
decorator- The decorator
-
-