|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdiva.canvas.BasicZList
A basic implementation of the figure z-list, provided for initial implementations of figure containers. This implementation uses java.util.ArrayList internally. In the internal implementation, the order of indexes is reversed, so that low-index elements in the external interface are high-index elements in the internal ArrayList. This is done on grounds of "performance": the redraw iterator is more important than the event-handling iterator.
| Yellow |
| Constructor Summary | |
BasicZList()
|
|
| Method Summary | |
void |
add(Figure f)
Add a figure to the container. |
void |
add(int index,
Figure f)
Insert a figure at the given position. |
void |
clear()
Removes all of the figures from this list. |
boolean |
contains(Figure f)
Test if the z-list contains the given figure. |
java.util.Iterator |
figures()
Return an iteration of the figures in this container. |
java.util.Iterator |
figuresFromBack()
Return an iteration of the figures in this container, from highest index to lowest index. |
java.util.Iterator |
figuresFromFront()
Return an iteration of the figures in this container, from lowest index to highest index. |
Figure |
get(int index)
Get the figure at the given index. |
java.awt.geom.Rectangle2D |
getBounds()
Get the bounding box of all the figures in this list. |
GeometricSet |
getContainedFigures(java.awt.geom.Rectangle2D region)
Get the figures that are entirely contained by the given region. |
int |
getFigureCount()
Return the number of figures in this list. |
GeometricSet |
getIntersectedFigures(java.awt.geom.Rectangle2D region)
Get the figures with bounding boxes that intersect the given region. |
int |
indexOf(Figure f)
Return the index of the given figure in the Z-list. |
void |
remove(Figure f)
Remove the given figure from this container. |
void |
remove(int index)
Remove the figure at the given position in the list. |
void |
set(int index,
Figure f)
Replace the figure at the given index with the passed-in figure. |
void |
setIndex(int index,
Figure f)
Set the index of the given figure. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BasicZList()
| Method Detail |
public void add(Figure f)
add in interface ZList
public void add(int index,
Figure f)
add in interface ZListpublic void clear()
clear in interface ZListpublic java.awt.geom.Rectangle2D getBounds()
getBounds in interface ZListpublic boolean contains(Figure f)
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.
contains in interface ZListpublic java.util.Iterator figures()
figures in interface FigureSetpublic java.util.Iterator figuresFromBack()
figuresFromBack in interface FigureSetpublic java.util.Iterator figuresFromFront()
figuresFromFront in interface FigureSetpublic Figure get(int index)
get in interface ZListpublic int getFigureCount()
getFigureCount in interface ZListpublic GeometricSet getContainedFigures(java.awt.geom.Rectangle2D region)
getContainedFigures in interface ZListpublic GeometricSet getIntersectedFigures(java.awt.geom.Rectangle2D region)
getIntersectedFigures in interface ZListpublic int indexOf(Figure f)
indexOf in interface ZListpublic void remove(Figure f)
remove in interface ZListpublic void remove(int index)
remove in interface ZList
public void set(int index,
Figure f)
set in interface ZList
public void setIndex(int index,
Figure f)
setIndex in interface ZList
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||