public class CompositeFigure extends AbstractFigureContainer
Yellow |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
decorate, undecorate
contains, getInteractor, getLayer, getParent, getToolTipText, getUserObject, hit, isVisible, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isVisible, setVisible
getParent, repaint
public CompositeFigure()
public CompositeFigure(ZList zlist)
public CompositeFigure(Figure background)
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
region
- The rectangle to be checked.protected void invalidateCachedBounds()
public void paint(java.awt.Graphics2D g)
paint
in interface VisibleComponent
paint
in class AbstractFigureContainer
g
- The 2D graphics object that this object
it to be painted upon.public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D region)
paint
in interface VisibleComponent
paint
in class AbstractFigure
g
- The 2D graphics object that this object
it to be painted upon.region
- The region.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
d
- The region where a repaint has occurred.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
at
- The transform to be used.public void translate(double x, double y)
translate
in interface Figure
translate
in class AbstractFigureContainer
x
- The x value to be moved.y
- The y value to be moved.