|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.BasicZList
public class 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 |
Nested Class Summary | |
---|---|
private class |
BasicZList.EnclosedGSet
The figures with enclosed bounding boxes |
private class |
BasicZList.GSet
The abstract class of Geometric sets on a zlist. |
private class |
BasicZList.IntersectedGSet
The figures with intersecting bounding boxes |
Field Summary | |
---|---|
private java.util.ArrayList |
_elements
|
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 |
Field Detail |
---|
private java.util.ArrayList _elements
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 ZList
public void clear()
clear
in interface ZList
public java.awt.geom.Rectangle2D getBounds()
getBounds
in interface ZList
public 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 FigureSet
contains
in interface ZList
public java.util.Iterator figures()
figures
in interface FigureSet
public java.util.Iterator figuresFromBack()
figuresFromBack
in interface FigureSet
public java.util.Iterator figuresFromFront()
figuresFromFront
in interface FigureSet
public Figure get(int index)
get
in interface ZList
public int getFigureCount()
getFigureCount
in interface ZList
public GeometricSet getContainedFigures(java.awt.geom.Rectangle2D region)
getContainedFigures
in interface ZList
public GeometricSet getIntersectedFigures(java.awt.geom.Rectangle2D region)
getIntersectedFigures
in interface ZList
public int indexOf(Figure f)
indexOf
in interface ZList
public void remove(Figure f)
remove
in interface ZList
public 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 All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |