UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.satin.objects
Interface GraphicalObjectCollection

All Superinterfaces:
Cloneable, SatinConstants, Serializable, Watcher
All Known Subinterfaces:
GraphicalObjectGroup, Patch
All Known Implementing Classes:
GraphicalObjectCollectionImpl, GraphicalObjectGroupImpl, Sheet

public interface GraphicalObjectCollection
extends SatinConstants, Watcher, Cloneable, Serializable

A Graphical Object collection that implements the Watcher interface, listening for changes to the Graphical Objects contained.

A Graphical Object Collection simply contains a collection of Graphical Objects. It does not modify the Graphical Objects in any way.

If you're familiar with Collections in Java, you're probably wondering why this doesn't implement the collection interface correctly. Well, unfortunately, Java has some naming conflicts with methods, like size(). If the naming conflicts ever get resolved, then we'll straighten out the names here too.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Oct 09 1998, JH
               Created class
             - SATIN-v2.1-1.0.0, Aug 11 2000, JH
               Touched for SATIN release
 

Since:
JDK 1.2
Version:
SATIN-v2.1-1.0.0, Aug 11 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )

Inner classes inherited from class edu.berkeley.guir.lib.satin.SatinConstants
SatinConstants.ObjectPoolAffineTransform, SatinConstants.ObjectPoolPoint2D, SatinConstants.ObjectPoolPolygon2D, SatinConstants.ObjectPoolRectangle2D, SatinConstants.ObjectPoolStringBuffer, SatinConstants.UniqueAffineTransform, SatinConstants.UniquePoint2D, SatinConstants.UniquePolygon2D, SatinConstants.UniqueRectangle2D
 
Fields inherited from interface edu.berkeley.guir.lib.satin.SatinConstants
ABOVE, ALL, BAR, BELOW, clipboard, clprops, cmdqueue, cmdsubsys, CONTAINEDBY, CONTAINS, COORD_ABS, COORD_LOCAL, COORD_REL, DAMAGE_LATER, DAMAGE_NOW, DEBUG_GRAPHICS_OFFSET, DEBUG_STYLE_FILE, DEBUG_STYLE_GPROPERTY, DEEP, DEFAULT_POINT2D_POOL_SIZE, DEFAULT_POLYGON2D_POOL_SIZE, DEFAULT_RECTANGLE_POOL_SIZE, DEFAULT_REPAINT_THRESHOLD, DEFAULT_SELECT_THRESHOLD, DEFAULT_STRINGBUFFER_POOL_SIZE, DEFAULT_TRANSFORM_POOL_SIZE, DIR_CENTER, DIR_DOWN, DIR_DOWN_LEFT, DIR_DOWN_RIGHT, DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_UP_LEFT, DIR_UP_RIGHT, FILTER_THRESHOLD, FIRST, FLOATING_PT_TOLERANCE, glprops, INTERSECTS, KEY_STYLE_DASHARRAY, KEY_STYLE_DASHPHASE, KEY_STYLE_DRAWCOLOR, KEY_STYLE_DRAWFONT, KEY_STYLE_DRAWTRANSPARENCY, KEY_STYLE_ENDCAP, KEY_STYLE_FILLCOLOR, KEY_STYLE_FILLTRANSPARENCY, KEY_STYLE_LINEJOIN, KEY_STYLE_LINEWIDTH, KEY_STYLE_MITERLIMIT, NEAR, NOTIFY_BOUNDS, NOTIFY_LAYER, NOTIFY_LOCATION, NOTIFY_STYLE, NOTIFY_TRANSFORM, poolPoints, poolPolys, poolRects, poolStrbuf, poolTx, rand, SATIN_DATA_DIRECTORY_DEFAULT, SATIN_DATA_DIRECTORY_GPROPERTY, SATIN_PROPERTIES_FILENAME, SHALLOW
 
Method Summary
 GraphicalObject add(GraphicalObject gob)
          Same as addToFront.
 GraphicalObject add(int index, GraphicalObject gob)
          Add a Graphical Object to the specified location.
 GraphicalObject addToBack(GraphicalObject gob)
          Add a GraphicalObject to the back of the list.
 GraphicalObject addToFront(GraphicalObject gob)
          Add a GraphicalObject to the front of the list.
 void clear()
          Clear out all Graphical Objects in this collection.
 Object clone()
          Clone shallowly, one level only.
 boolean contains(GraphicalObject gob)
          See if this Graphical Object Collection contains the specified Graphical Object.
 Object deepClone()
          Clone deeply, recursing if necessary.
 GraphicalObject get(int index)
          Get the Graphical Object at the specified index.
 Rectangle2D getCollectionBounds2D(int cdsys)
          Get the union of the bounds of the GraphicalObjects contained in this collection.
 Rectangle2D getCollectionBounds2D(int cdsys, Rectangle2D rect)
          Get the bounds, put them in the specified Rectangle.
 GraphicalObject getFirst()
          Get the first Graphical Object.
 Iterator getForwardIterator()
          Get an iterator that goes forward thru the collection.
 GraphicalObject getID(int id)
          Retrieve the GraphicalObject with the specified unique ID.
 GraphicalObject getLast()
          Get the last Graphical Object.
 Iterator getReverseIterator()
          Get an iterator that goes backwards thru the collection.
 int indexOf(GraphicalObject gob)
          Find the index of the specified Graphical Object.
 boolean isEmpty()
          Is this collection empty?
 int numElements()
          Get the number of elements contained in this collection.
 GraphicalObject remove(GraphicalObject gob)
          Remove a Graphical Object from this collection.
 void sort(Comparator c)
          Sort the list given the specified comparator.
 
Methods inherited from interface edu.berkeley.guir.lib.satin.watch.Watcher
onDelete, onNotify, onUpdate, onUpdate
 

Method Detail

add

public GraphicalObject add(GraphicalObject gob)
Same as addToFront.
Parameters:
gob - is the GraphicalObject to add.
Returns:
a reference to the GraphicalObject added.

addToFront

public GraphicalObject addToFront(GraphicalObject gob)
Add a GraphicalObject to the front of the list.
Parameters:
gob - is the Graphical Object to add.
Returns:
a reference to the GraphicalObject added.

addToBack

public GraphicalObject addToBack(GraphicalObject gob)
Add a GraphicalObject to the back of the list.
Parameters:
gob - is the Graphical Object to add.
Returns:
a reference to the GraphicalObject added.

add

public GraphicalObject add(int index,
                           GraphicalObject gob)
Add a Graphical Object to the specified location.
Parameters:
index - is the location to add to (zero-based). It is up to the programmer to ensure that this is a valid value.
gob - is the Graphical Object to add.

clear

public void clear()
Clear out all Graphical Objects in this collection.

contains

public boolean contains(GraphicalObject gob)
See if this Graphical Object Collection contains the specified Graphical Object. Please note that this is NOT the same as calling GraphicalObject.shapeContains(GraphicalObject).
Returns:
true if it contains the specified Graphical Object, false otherwise.

get

public GraphicalObject get(int index)
Get the Graphical Object at the specified index.
Parameters:
index - is the location to look at (zero-based). It is up to the programmer to ensure that this is a valid value.
Returns:
the Graphical Object at the specified index.

getFirst

public GraphicalObject getFirst()
Get the first Graphical Object.
Returns:
null if nothing is there.

getLast

public GraphicalObject getLast()
Get the last Graphical Object.
Returns:
null if nothing is there.

getID

public GraphicalObject getID(int id)
Retrieve the GraphicalObject with the specified unique ID.
Parameters:
id - is the unique ID of the GraphicalObject to retrieve.
Returns:
the GraphicalObject with that ID, or null if it isn't here.

getCollectionBounds2D

public Rectangle2D getCollectionBounds2D(int cdsys)
Get the union of the bounds of the GraphicalObjects contained in this collection. Asking for local bounds is useless.
Asking for relative bounds is useful only if all of the GraphicalObjects have the same parent.
Asking for absolute bounds will always work.
Parameters:
cdsys - is the coordinate system to use.
Returns:
Rectangle representing the union of bounds.

getCollectionBounds2D

public Rectangle2D getCollectionBounds2D(int cdsys,
                                         Rectangle2D rect)
Get the bounds, put them in the specified Rectangle.

indexOf

public int indexOf(GraphicalObject gob)
Find the index of the specified Graphical Object.
Parameters:
gob - is the Graphical Object to look for.
Returns:
the index of the Graphical Object in this collection (zero-based) or -1 if it is not here.

isEmpty

public boolean isEmpty()
Is this collection empty?
Returns:
true if empty, false otherwise.

numElements

public int numElements()
Get the number of elements contained in this collection.

I realize that this should have been called size(), but there already exists a deprecated method in Component named size().

Returns:
the number of elements contained.

remove

public GraphicalObject remove(GraphicalObject gob)
Remove a Graphical Object from this collection.
Parameters:
gob - is the Graphical Object ot remove.

getForwardIterator

public Iterator getForwardIterator()
Get an iterator that goes forward thru the collection.
Returns:
an Iterator.

getReverseIterator

public Iterator getReverseIterator()
Get an iterator that goes backwards thru the collection.
Returns:
an Iterator.

sort

public void sort(Comparator c)
Sort the list given the specified comparator. One useful one is the LayerComparator, which sorts by layers.

clone

public Object clone()
Clone shallowly, one level only.
Specified by:
clone in interface Watcher
Overrides:
clone in class Object

deepClone

public Object deepClone()
Clone deeply, recursing if necessary.

Copyright Information