diva.canvas
Interface FigureContainer

All Superinterfaces:
CanvasComponent, FigureSet, VisibleComponent
All Known Implementing Classes:
AbstractFigureContainer, ArcManipulator, AttributeBoundsManipulator, BasicEdgeHighlighter, BasicHighlighter, BoundsManipulator, CircleManipulator, CompositeFigure, ConnectorManipulator, FigureDecorator, FigureLayer, Manipulator, PathManipulator, TypedDecorator

public interface FigureContainer
extends FigureSet, VisibleComponent

The FigureContainer interface is implemented by any visible component that can contain figures. It includes all of the methods in VisibleComponent and FigureSet, and adds methods related to containment of a known and finite set of figures.

Version:
$Id: FigureContainer.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie
Accepted Rating:
Yellow

Method Summary
 void add(Figure f)
          Add a figure to this container.
 boolean contains(Figure f)
          Test if this container contains the given figure.
 void decorate(Figure f, FigureDecorator d)
          Decorate a child figure, replacing the child figure with the decorator.
 int getFigureCount()
          Return the number of figures in this container.
 Figure pick(java.awt.geom.Rectangle2D region)
          Given a rectangle, return the top-most descendent figure that hits it.
 Figure pick(java.awt.geom.Rectangle2D region, Filter f)
          Given a rectangle, return the top-most descendent figure that hits it, and is accepted by the given filter.
 void remove(Figure f)
          Remove the given figure from this container.
 void undecorate(FigureDecorator d)
          Remove a figure from the given decorator and add it back into this container.
 
Methods inherited from interface diva.canvas.FigureSet
figures, figuresFromBack, figuresFromFront
 
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, paint, setVisible
 
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext, repaint, repaint
 

Method Detail

add

void add(Figure f)
Add a figure to this container. The figure should be added so that it always displays above existing figures.


contains

boolean contains(Figure f)
Test if this container contains the given figure. As a general rule, the implementation of this method is not required to be efficient -- O(n) in the length of the list is acceptable. Clients should note that, in general, a much better way of making this same test is to check if the parent of the figure is the same object as this container.

Specified by:
contains in interface FigureSet

decorate

void decorate(Figure f,
              FigureDecorator d)
Decorate a child figure, replacing the child figure with the decorator.


getFigureCount

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


pick

Figure pick(java.awt.geom.Rectangle2D region)
Given a rectangle, return the top-most descendent figure that hits it. Otherwise, return null. Implementors should not call their own hit() method, but only those of their children.

Note that a region is given instead of a point so that "pick halo" can be implemented. The region should not have zero size, or no figure will be hit.


pick

Figure pick(java.awt.geom.Rectangle2D region,
            Filter f)
Given a rectangle, return the top-most descendent figure that hits it, and is accepted by the given filter. Otherwise, return null. Implementors should not call their own hit() method, but only those of their children.

Note that a region is given instead of a point so that "pick halo" can be implemented. The region should not have zero size, or no figure will be hit.


remove

void remove(Figure f)
Remove the given figure from this container.


undecorate

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