|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.AbstractFigure
diva.canvas.AbstractFigureContainer
diva.canvas.CompositeFigure
public class CompositeFigure
A CompositeFigure is a figure that contains a set of child figures. It uses a ZList as the internal representation of its children, and implements wrappers for many of the z-list methods to provide flexible access to the contained figures. Note that this class exposes the ability to add and remove children by any client, and is thus intended for use in situations in which the number of child figures is either large or unpredictable. For applications in which the number of children is smaller and predictable, and more restricted access to the children is require, applications should implement a custom subclass of AbstractFigureContainer. For an example, see diva.canvas.toolbox.IconFigure.
Yellow |
Field Summary | |
---|---|
private Figure |
_background
The background figure |
private java.awt.geom.Rectangle2D |
_cachedBounds
The cached bounding box |
private ZList |
_children
The children. |
private TransformContext |
_transformContext
The transform context |
Constructor Summary | |
---|---|
CompositeFigure()
Create a new composite figure containing no figures. |
|
CompositeFigure(Figure background)
Construct a composite figure with the given figure as its background. |
|
CompositeFigure(ZList zlist)
Create a new composite figure containing no figures, that uses the given z-list for its storage. |
Method Summary | |
---|---|
void |
add(Figure f)
Add a child figure to this composite. |
void |
add(int index,
Figure f)
Insert a figure at the given position. |
boolean |
contains(Figure f)
Test if the given figure is a child of this composite. |
java.util.Iterator |
figures()
Return an iteration of the children, in an undefined order. |
java.util.Iterator |
figuresFromBack()
Return an iteration of the children, from back to front. |
java.util.Iterator |
figuresFromFront()
Return an iteration of the children, from front to back. |
Figure |
get(int index)
Return the figure at the given index. |
Figure |
getBackgroundFigure()
Get the background figure. |
java.awt.geom.Rectangle2D |
getBounds()
Get the bounding box of this figure. |
ZList |
getChildren()
Get the internal z-list. |
int |
getFigureCount()
Return the number of elements in this container. |
java.awt.geom.Point2D |
getOrigin()
Return the origin of the background figure in the enclosing transform context. |
java.awt.Shape |
getShape()
Get the shape of this figure. |
TransformContext |
getTransformContext()
Return the transform context of this figure. |
int |
indexOf(Figure f)
Return the index of the given figure in the Z-list, or -1 if the figure is not in this list. |
boolean |
intersects(java.awt.geom.Rectangle2D region)
Test if this figure intersects the given rectangle. |
protected void |
invalidateCachedBounds()
|
void |
paint(java.awt.Graphics2D g)
Paint this composite figure onto a 2D graphics object. |
void |
paint(java.awt.Graphics2D g,
java.awt.geom.Rectangle2D region)
Paint this composite figure onto a 2D graphics object, within the given region. |
Figure |
pick(java.awt.geom.Rectangle2D region)
Get the picked figure. |
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 |
remove(Figure f)
Remove the given child from this composite. |
void |
remove(int index)
Remove the figure at the given position in the list. |
void |
repaint(DamageRegion d)
Accept notification that a repaint has occurred somewhere in the hierarchy below this container. |
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 |
setBackgroundFigure(Figure background)
Set the background figure. |
void |
setIndex(int index,
Figure f)
Set the index of the given figure. |
java.lang.String |
toString()
Return a string description of this figure |
void |
transform(java.awt.geom.AffineTransform at)
Transform this figure with the supplied transform. |
void |
translate(double x,
double y)
Translate this figure the given distance. |
Methods inherited from class diva.canvas.AbstractFigureContainer |
---|
decorate, undecorate |
Methods inherited from class diva.canvas.AbstractFigure |
---|
contains, getInteractor, getLayer, getParent, getToolTipText, getUserObject, hit, isVisible, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface diva.canvas.VisibleComponent |
---|
isVisible, setVisible |
Methods inherited from interface diva.canvas.CanvasComponent |
---|
getParent, repaint |
Field Detail |
---|
private Figure _background
private java.awt.geom.Rectangle2D _cachedBounds
private ZList _children
private TransformContext _transformContext
Constructor Detail |
---|
public CompositeFigure()
public CompositeFigure(ZList zlist)
public CompositeFigure(Figure background)
Method Detail |
---|
public void add(Figure f)
public void add(int index, Figure f)
public boolean contains(Figure f)
contains
in interface FigureContainer
contains
in interface FigureSet
contains
in class AbstractFigureContainer
public java.util.Iterator figures()
figures
in interface FigureSet
figures
in class AbstractFigureContainer
public java.util.Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
figuresFromBack
in class AbstractFigureContainer
public java.util.Iterator figuresFromFront()
figuresFromFront
in interface FigureSet
figuresFromFront
in class AbstractFigureContainer
public Figure get(int index)
java.lang.IndexOutOfBoundsException
- The index is out of range.public Figure getBackgroundFigure()
figures()
,
setBackgroundFigure(Figure)
public java.awt.geom.Rectangle2D getBounds()
getBounds
in interface Figure
getBounds
in class AbstractFigure
public ZList getChildren()
public int getFigureCount()
getFigureCount
in interface FigureContainer
getFigureCount
in class AbstractFigureContainer
public java.awt.geom.Point2D getOrigin()
getOrigin
in interface Figure
getOrigin
in class AbstractFigure
AbstractFigure.getBounds()
public java.awt.Shape getShape()
getShape
in interface Figure
getShape
in class AbstractFigure
public TransformContext getTransformContext()
getTransformContext
in interface CanvasComponent
getTransformContext
in class AbstractFigure
public int indexOf(Figure f)
public boolean intersects(java.awt.geom.Rectangle2D region)
intersects
in interface Figure
intersects
in class AbstractFigure
protected void invalidateCachedBounds()
public void paint(java.awt.Graphics2D g)
paint
in interface VisibleComponent
paint
in class AbstractFigureContainer
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)
paint
in interface VisibleComponent
paint
in class AbstractFigure
public Figure pick(java.awt.geom.Rectangle2D region)
pick
in interface FigureContainer
pick
in class AbstractFigureContainer
public Figure pick(java.awt.geom.Rectangle2D region, Filter filter)
pick
in interface FigureContainer
pick
in class AbstractFigureContainer
public void remove(Figure f)
public void remove(int index)
java.lang.IndexOutOfBoundsException
- The index is out of range.public void repaint(DamageRegion d)
repaint
in interface CanvasComponent
repaint
in class AbstractFigureContainer
public void setBackgroundFigure(Figure background)
figures()
,
getBackgroundFigure()
public void setIndex(int index, Figure f)
java.lang.IndexOutOfBoundsException
- The new index is out of range.protected void replaceChild(Figure child, Figure replacement)
replaceChild
in class AbstractFigureContainer
public java.lang.String toString()
toString
in class java.lang.Object
public void transform(java.awt.geom.AffineTransform at)
transform
in interface Figure
transform
in class AbstractFigureContainer
public void translate(double x, double y)
translate
in interface Figure
translate
in class AbstractFigureContainer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |