Jazz API Documentation

edu.umd.cs.jazz.component
Class ZCoordList

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZVisualComponent
              |
              +--edu.umd.cs.jazz.component.ZCoordList
All Implemented Interfaces:
java.io.Serializable, ZAppearance, ZPenColor, ZSerializable, ZStroke
Direct Known Subclasses:
ZPolygon, ZPolyline

public class ZCoordList
extends ZVisualComponent
implements ZStroke, ZPenColor, java.io.Serializable

ZCoordList is an abstract visual component that stores a sequence of coordinates, and the corresponding general path. This is intended to be sub-classed for specific objects that use coordinate lists.

See Also:
Serialized Form

Field Summary
protected  boolean closed
           
static boolean DEFAULT_CLOSED
           
static java.awt.Color DEFAULT_PEN_COLOR
           
static float DEFAULT_PEN_WIDTH
           
protected  boolean empty
           
protected  int np
           
protected  java.awt.geom.GeneralPath path
           
protected  java.awt.Color penColor
           
protected  float penWidth
           
protected  java.awt.Stroke stroke
           
protected  ZBounds tmpBounds
           
protected  float[] xp
           
protected  float[] yp
           
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, objRefTable, volatileBounds_DEFAULT
 
Constructor Summary
ZCoordList()
          Constructs a new ZCoordList with no points.
ZCoordList(float[] xp, float[] yp)
          Constructs a new ZCoordList.
ZCoordList(float x, float y)
          Constructs a new ZCoordList with a single point.
ZCoordList(float x1, float y1, float x2, float y2)
          Constructs a new ZCoordList with a two points
ZCoordList(java.awt.geom.Point2D pt)
          Constructs a new ZCoordList with a single point.
ZCoordList(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          Constructs a new ZCoordList with two points.
 
Method Summary
 void add(float x, float y)
          Add a point to the end of this coordinate list.
 void add(float x, float y, int index)
          Add a point to the specified part of this coordinate list.
 void add(java.awt.geom.Point2D pt)
          Add a point to the end of this coordinate list.
 void add(java.awt.geom.Point2D pt, int index)
          Add a point to the specified part of this coordinate list.
 java.lang.Object clone()
          Duplicates the current object by using the copy constructor.
protected  void computeBounds()
          Notifies this object that it has changed and that it should update its notion of its bounding box.
 void duplicateObject(ZCoordList refCoordList)
          Copies all object information from the reference object into the current object.
protected  void ensureSpace(int n)
          Ensure that there is space for at least n points in the data structures that hold the list of points for this coordinate list.
 int getNumberPoints()
          Get the number of points in this coordinate list.
 java.awt.geom.GeneralPath getPath()
          Get the GeneralPath object used by this coordinate list.
 java.awt.Color getPenColor()
          Get the pen color of this polyline.
 float getPenWidth()
          Get the width of the pen used to draw the line around the edge of this polyline.
 java.awt.Stroke getStroke()
          Get the stroke used to draw the visual component.
 float[] getXCoords()
          Get an array of the X coordinates of the points in this coordinate list.
 float[] getYCoords()
          Get an array of the Y coordinates of the points in this coordinate list.
 boolean isClosed()
          Determine if this coordinate list is closed.
 void setClosed(boolean closed)
          Specify that this coordinate list is closed.
 void setCoords(float[] xp, float[] yp)
          Set the coordinates of this coordinate list.
 void setPenColor(java.awt.Color color)
          Set the pen color of this polyline.
 void setPenWidth(float width)
          Set the width of the pen used to draw the line around the edge of this polyline.
 void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
          Set some state of this object as it gets read back in.
 void setStroke(java.awt.Stroke stroke)
          Set the stroke used to draw the visual component.
 void trimToSize()
          Trims the capacity of the arrays that store the coordinate list points to the actual number of points.
protected  void updatePath()
          Internal method to update the path within the coordinate list.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
boundsUpdated, duplicateObject, getParents, paint, pick, pickBounds, render, repaint, repaint, updateBounds, updateVolatility, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
dump, duplicateObject, getBounds, getVolatileBounds, reshape, setVolatileBounds, updateObjectReferences
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CLOSED

public static final boolean DEFAULT_CLOSED

DEFAULT_PEN_WIDTH

public static final float DEFAULT_PEN_WIDTH

DEFAULT_PEN_COLOR

public static final java.awt.Color DEFAULT_PEN_COLOR

penColor

protected java.awt.Color penColor

stroke

protected transient java.awt.Stroke stroke

penWidth

protected float penWidth

closed

protected boolean closed

empty

protected boolean empty

path

protected transient java.awt.geom.GeneralPath path

xp

protected float[] xp

yp

protected float[] yp

np

protected int np

tmpBounds

protected ZBounds tmpBounds
Constructor Detail

ZCoordList

public ZCoordList()
Constructs a new ZCoordList with no points.

ZCoordList

public ZCoordList(java.awt.geom.Point2D pt)
Constructs a new ZCoordList with a single point.
Parameters:
pt - Initial point

ZCoordList

public ZCoordList(java.awt.geom.Point2D pt1,
                  java.awt.geom.Point2D pt2)
Constructs a new ZCoordList with two points.
Parameters:
pt1 - First point
pt2 - Second point

ZCoordList

public ZCoordList(float x,
                  float y)
Constructs a new ZCoordList with a single point.
Parameters:
x,y - Initial point

ZCoordList

public ZCoordList(float x1,
                  float y1,
                  float x2,
                  float y2)
Constructs a new ZCoordList with a two points
Parameters:
x,y - First point
x,y - Second point

ZCoordList

public ZCoordList(float[] xp,
                  float[] yp)
Constructs a new ZCoordList. The xp, yp parameters are stored within this coordinate list, so the caller must not modify them after passing them in.
Parameters:
xp - Array of X points
yp - Array of Y points
Method Detail

duplicateObject

public void duplicateObject(ZCoordList refCoordList)
Copies all object information from the reference object into the current object. This method is called from the clone method. All ZSceneGraphObjects objects contained by the object being duplicated are duplicated, except parents which are set to null. This results in the sub-tree rooted at this object being duplicated.
Parameters:
refCoordList - The reference visual component to copy

clone

public java.lang.Object clone()
Duplicates the current object by using the copy constructor. The portion of the reference object that is duplicated is that necessary to reuse the object in a new place within the scenegraph, but the new object is not inserted into any scenegraph. The object must be attached to a live scenegraph (a scenegraph that is currently visible) or be registered with a camera directly in order for it to be visible.
Overrides:
clone in class ZVisualComponent
Returns:
A copy of this visual component.
See Also:
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

isClosed

public boolean isClosed()
Determine if this coordinate list is closed. A closed coordinate list means that the last point is always the same as the first point in the path that is used for painting. The actual coordinates are not affected by this.
Returns:
the closed value.

setClosed

public void setClosed(boolean closed)
Specify that this coordinate list is closed. A closed coordinate list means that the last point is always the same as the first point in the path that is used for painting. The actual coordinates are not affected by this.
Parameters:
the - closed value.

getPenWidth

public float getPenWidth()
Get the width of the pen used to draw the line around the edge of this polyline. The pen is drawn centered around the polyline vertices, so if the pen width is thick, the bounds of the polyline will grow.
Specified by:
getPenWidth in interface ZStroke
Returns:
the pen width.

setPenWidth

public void setPenWidth(float width)
Set the width of the pen used to draw the line around the edge of this polyline. The pen is drawn centered around the polyline vertices, so if the pen width is thick, the bounds of the polyline will grow.
Specified by:
setPenWidth in interface ZStroke
Parameters:
width - the pen width.

getStroke

public java.awt.Stroke getStroke()
Get the stroke used to draw the visual component.
Specified by:
getStroke in interface ZStroke
Returns:
the stroke.

setStroke

public void setStroke(java.awt.Stroke stroke)
Set the stroke used to draw the visual component.
Specified by:
setStroke in interface ZStroke
Parameters:
stroke - the stroke.

getPenColor

public java.awt.Color getPenColor()
Get the pen color of this polyline.
Specified by:
getPenColor in interface ZPenColor
Returns:
the pen color.

setPenColor

public void setPenColor(java.awt.Color color)
Set the pen color of this polyline.
Specified by:
setPenColor in interface ZPenColor
Parameters:
color - the pen color, or null if none.

add

public void add(java.awt.geom.Point2D pt)
Add a point to the end of this coordinate list.
Parameters:
pt - The new point

add

public void add(float x,
                float y)
Add a point to the end of this coordinate list.
Parameters:
x,y - The new point

add

public void add(java.awt.geom.Point2D pt,
                int index)
Add a point to the specified part of this coordinate list. Specifying an index of 0 puts the point at the beginning of the list. Specifying an index greater than the number of points in the coordinate list puts the point at the end of the list of points.
Parameters:
pt - The new point
index - The index of the new point.

add

public void add(float x,
                float y,
                int index)
Add a point to the specified part of this coordinate list. Specifying an index of 0 puts the point at the beginning of the list. Specifying an index greater than the number of points in the coordinate list puts the point at the end of the list of points.
Parameters:
x,y - The new point
index - The index of the new point.

ensureSpace

protected void ensureSpace(int n)
Ensure that there is space for at least n points in the data structures that hold the list of points for this coordinate list.
Parameters:
n - The number of points that this coordinate list should be able to hold.

setCoords

public void setCoords(float[] xp,
                      float[] yp)
Set the coordinates of this coordinate list. The specified points completely replace the previous points in this coordinate list.
Parameters:
xp - An array of the X coordinates of the new points.
yp - An array of the Y coordinates of the new points.

updatePath

protected void updatePath()
Internal method to update the path within the coordinate list.

getXCoords

public float[] getXCoords()
Get an array of the X coordinates of the points in this coordinate list. These are the original coordinates of this list, and must not be modified by the caller.
Returns:
Array of X coordinates of points.

getYCoords

public float[] getYCoords()
Get an array of the Y coordinates of the points in this coordinate list. These are the original coordinates of this list, and must not be modified by the caller.
Returns:
Array of Y coordinates of points.

getNumberPoints

public int getNumberPoints()
Get the number of points in this coordinate list.
Returns:
the number of points in this coordinate list

getPath

public java.awt.geom.GeneralPath getPath()
Get the GeneralPath object used by this coordinate list. These are the original coordinates of this list, and must not be modified by the caller.
Returns:
GeneralPath object used by this coordinate list.

trimToSize

public void trimToSize()
Trims the capacity of the arrays that store the coordinate list points to the actual number of points. Normally, the coordinate list arrays can be slightly larger than the number of points in the coordinate list. An application can use this operation to minimize the storage of a coordinate list.
Overrides:
trimToSize in class ZVisualComponent
See Also:
getXCoords(), getYCoords(), getNumberPoints()

computeBounds

protected void computeBounds()
Notifies this object that it has changed and that it should update its notion of its bounding box. Note that this should not be called directly. Instead, it is called by updateBounds when needed.
Overrides:
computeBounds in class ZSceneGraphObject

writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.
Overrides:
writeObject in class ZVisualComponent
Parameters:
out - The stream that this object writes into

setState

public void setState(java.lang.String fieldType,
                     java.lang.String fieldName,
                     java.lang.Object fieldValue)
Set some state of this object as it gets read back in. After the object is created with its default no-arg constructor, this method will be called on the object once for each bit of state that was written out through calls to ZObjectOutputStream.writeState() within the writeObject method.
Overrides:
setState in class ZVisualComponent
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field

Jazz API Documentation