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.ZBasicVisualComponent
                    |
                    +--edu.umd.cs.jazz.component.ZShape
                          |
                          +--edu.umd.cs.jazz.component.ZCoordList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, ZAppearance, ZFillColor, ZFillPaint, ZPenColor, ZPenPaint, ZSerializable, ZStroke
Direct Known Subclasses:
ZPolygon, ZPolyline

public class ZCoordList
extends ZShape

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.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Benjamin B. Bederson
, Jesse Grosjean
See Also:
Serialized Form

Field Summary
protected  edu.umd.cs.jazz.component.ZCoordListShape coordListShape
          The shape representing this coordlist.
 
Fields inherited from class edu.umd.cs.jazz.component.ZBasicVisualComponent
absPenWidth, DEFAULT_ABS_PEN_WIDTH, DEFAULT_FILL_PAINT, DEFAULT_PEN_PAINT, DEFAULT_PEN_WIDTH, DEFAULT_STROKE, fillPaint, penPaint, penWidth, stroke
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, inTransaction, invalidBounds, invalidVolatileBounds, listenerList, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZCoordList()
          Constructs a new ZCoordList with no points.
ZCoordList(double[] xp, double[] yp)
          Constructs a new ZCoordList.
ZCoordList(double x, double y)
          Constructs a new ZCoordList with a single point.
ZCoordList(double x1, double y1, double x2, double 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(double x, double y)
          Add a point to the end of this coordinate list.
 void add(double x, double 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.
protected  java.lang.Object duplicateObject()
          Returns a clone of this object.
protected  edu.umd.cs.jazz.component.ZCoordListShape getCoordListShape()
          Get the shape defined by the coords.
 int getNumberPoints()
          Get the number of points in this coordinate list.
 java.awt.Shape getShape()
          Return the current shape.
 double getX(int index)
          Return the X-coord of the vertex located in the specified index.
 double[] getXCoords()
          Get an array of the X coordinates of the points in this coordinate list.
 double getY(int index)
          Return the Y-coord of the vertex located in the specified index.
 double[] 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 lineTo(double x, double y)
          Return the append the given vertex onto the end of the list of points that define this polygon.
 void moveTo(double x, double y)
          Set the first vertex in the polygon list to the specified point.
 void reset()
          Remove all coordinates from the list.
 void setClosed(boolean closed)
          Specify that this coordinate list is closed.
 void setCoords(double[] xp, double[] yp)
          Set the coords of this polygon.
 void setCoords(java.awt.geom.Point2D[] points)
          Set the coords of this polygon.
 void setCoords(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          Set the coords of this polygon.
 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 writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 
Methods inherited from class edu.umd.cs.jazz.component.ZShape
computeBounds, getFrame, getHeight, getStrokeTransformForAbsPenWidth, getWidth, getX, getY, pick, pickStroke, render
 
Methods inherited from class edu.umd.cs.jazz.component.ZBasicVisualComponent
getAbsPenWidth, getFillColor, getFillPaint, getPenColor, getPenPaint, getPenWidth, getPenWidthForCurrentContext, getStroke, setAbsPenWidth, setFillColor, setFillPaint, setPenColor, setPenPaint, setPenWidth, setStroke
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
addParent, getNumParents, getParents, getParentsReference, getRoot, paint, pickBounds, removeParent, repaint, repaint, trimToSize, updateBounds, updateObjectReferences, updateVolatility, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addClientProperty, addMouseListener, addMouseMotionListener, clone, computeVolatileBounds, dump, endTransaction, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getClientProperty, getHandles, getListenerList, getVolatileBounds, hasLisenerOfType, hasListenerOfType, hasMouseListener, markInTransaction, markNotInTransaction, processMouseEvent, putClientProperty, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds, startTransaction
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coordListShape

protected transient edu.umd.cs.jazz.component.ZCoordListShape coordListShape
The shape representing this coordlist.

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.


ZCoordList

public ZCoordList(java.awt.geom.Point2D pt1,
                  java.awt.geom.Point2D pt2)
Constructs a new ZCoordList with two points.


ZCoordList

public ZCoordList(double x,
                  double y)
Constructs a new ZCoordList with a single point.


ZCoordList

public ZCoordList(double x1,
                  double y1,
                  double x2,
                  double y2)
Constructs a new ZCoordList with a two points


ZCoordList

public ZCoordList(double[] xp,
                  double[] 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.

Method Detail

duplicateObject

protected java.lang.Object duplicateObject()
Returns a clone of this object.

Overrides:
duplicateObject in class ZBasicVisualComponent
See Also:
ZSceneGraphObject.duplicateObject()

getCoordListShape

protected edu.umd.cs.jazz.component.ZCoordListShape getCoordListShape()
Get the shape defined by the coords.


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:
true if the coodinate list is closed, false otherwise.

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:
closed - true if the coodinate list is closed, false otherwise.

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(double x,
                double y)
Add a point to the end of this coordinate list.


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(double x,
                double 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:
index - The index of the new point.

getNumberPoints

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

Returns:
the number of points in this coordinate list

getShape

public java.awt.Shape getShape()
Return the current shape.

Specified by:
getShape in class ZShape

getX

public double getX(int index)
Return the X-coord of the vertex located in the specified index.


getY

public double getY(int index)
Return the Y-coord of the vertex located in the specified index.


getXCoords

public double[] 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 double[] 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.

lineTo

public void lineTo(double x,
                   double y)
Return the append the given vertex onto the end of the list of points that define this polygon.


moveTo

public void moveTo(double x,
                   double y)
Set the first vertex in the polygon list to the specified point. This will throw an error of the polygon already has some points defined.


setCoords

public void setCoords(java.awt.geom.Point2D pt1,
                      java.awt.geom.Point2D pt2)
Set the coords of this polygon.


setCoords

public void setCoords(double[] xp,
                      double[] yp)
Set the coords of this polygon.


setCoords

public void setCoords(java.awt.geom.Point2D[] points)
Set the coords of this polygon.


reset

public void reset()
Remove all coordinates from the list.


writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.

Specified by:
writeObject in interface ZSerializable
Overrides:
writeObject in class ZBasicVisualComponent
Parameters:
out - The stream that this object writes into
java.io.IOException

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.

Specified by:
setState in interface ZSerializable
Overrides:
setState in class ZBasicVisualComponent
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field


Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.