diva.canvas
Class AbstractFigureContainer

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by 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: AbstractFigureContainer.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie
Accepted Rating:
Yellow

Constructor Summary
AbstractFigureContainer()
           
 
Method Summary
abstract  boolean contains(Figure f)
          Test if the given figure is a child of this composite.
 void decorate(Figure child, FigureDecorator decorator)
          Decorate a child figure, replacing the reference to the child figure with the decorator.
abstract  java.util.Iterator figures()
          Return an iteration of the children, in an undefined order.
abstract  java.util.Iterator figuresFromBack()
          Return an iteration of the children, from back to front.
abstract  java.util.Iterator figuresFromFront()
          Return an iteration of the children, from front to back.
abstract  int getFigureCount()
          Return the number of child figures in this container.
 void paint(java.awt.Graphics2D g)
          Paint this composite figure onto a 2D graphics object.
 Figure pick(java.awt.geom.Rectangle2D region)
          Given a rectangle, return the top-most descendent figure that it hits.
 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.
 void repaint(DamageRegion d)
          Accept notification that a repaint has occurred somewhere in the hierarchy below this container.
protected abstract  void replaceChild(Figure child, Figure replacement)
          Replace the first figure with the second.
 void transform(java.awt.geom.AffineTransform at)
          Transform this figure with the supplied transform.
 void translate(double x, double y)
          Translate this figure by the given distance.
 void undecorate(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.FigureContainer
add, remove
 
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
 
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext, repaint
 

Constructor Detail

AbstractFigureContainer

public AbstractFigureContainer()
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:
decorate in interface FigureContainer

contains

public abstract boolean contains(Figure f)
Test if the given figure is a child of this composite.

Specified by:
contains in interface FigureContainer
Specified by:
contains in interface FigureSet

figures

public abstract java.util.Iterator figures()
Return an iteration of the children, in an undefined order.

Specified by:
figures in interface FigureSet

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:
figuresFromBack in interface FigureSet

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:
figuresFromFront in interface FigureSet

getFigureCount

public abstract int getFigureCount()
Return the number of child figures in this container.

Specified by:
getFigureCount in interface FigureContainer

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:
paint in interface VisibleComponent
Specified by:
paint in class AbstractFigure

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:
pick in interface FigureContainer

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:
pick in interface FigureContainer

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:
repaint in interface CanvasComponent
Overrides:
repaint in class AbstractFigure

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.


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:
transform in interface Figure
Specified by:
transform in class AbstractFigure

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:
translate in interface Figure
Overrides:
translate in class AbstractFigure

undecorate

public void undecorate(FigureDecorator decorator)
Remove a figure from the given decorator and add it back into this container.

Specified by:
undecorate in interface FigureContainer