Jazz API Documentation

edu.umd.cs.jazz.component
Class ZPolygon

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

public class ZPolygon
extends ZCoordList
implements ZFillColor, java.io.Serializable

ZPolygon is a visual component that represents a line with one or more segments.

See Also:
Serialized Form

Field Summary
static java.awt.Color DEFAULT_FILL_COLOR
           
protected  java.awt.Color fillColor
           
 
Fields inherited from class edu.umd.cs.jazz.component.ZCoordList
closed, DEFAULT_CLOSED, DEFAULT_PEN_COLOR, DEFAULT_PEN_WIDTH, empty, np, path, penColor, penWidth, stroke, tmpBounds, xp, yp
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, objRefTable, volatileBounds_DEFAULT
 
Constructor Summary
ZPolygon()
          Constructs a new ZPolygon with no points.
ZPolygon(float[] xp, float[] yp)
          Constructs a new ZPolygon.
ZPolygon(float x, float y)
          Constructs a new ZPolygon with a single point.
ZPolygon(float x1, float y1, float x2, float y2)
          Constructs a new ZPolygon with a two points
ZPolygon(java.awt.geom.Point2D pt)
          Constructs a new ZPolygon with a single point.
ZPolygon(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          Constructs a new ZPolygon with two points.
 
Method Summary
 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(ZPolygon refPoly)
          Copies all object information from the reference object into the current object.
 java.awt.Color getFillColor()
          Get the fill color of this polygon.
protected  boolean intersectsPolygon(java.awt.geom.Rectangle2D rect)
          Determines if any part of the rectangle is inside this polygon.
protected  boolean isInsidePolygon(java.awt.geom.Point2D pt)
          Determines if point is inside this polygon.
 boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
          Returns true if the specified rectangle is on the polygon.
 void render(ZRenderContext renderContext)
          Paints this object.
 void setFillColor(java.awt.Color color)
          Set the fill color 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.ZCoordList
add, add, add, add, duplicateObject, ensureSpace, getNumberPoints, getPath, getPenColor, getPenWidth, getStroke, getXCoords, getYCoords, isClosed, setClosed, setCoords, setPenColor, setPenWidth, setStroke, trimToSize, updatePath
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
boundsUpdated, duplicateObject, getParents, paint, pickBounds, 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_FILL_COLOR

public static final java.awt.Color DEFAULT_FILL_COLOR

fillColor

protected java.awt.Color fillColor
Constructor Detail

ZPolygon

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

ZPolygon

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

ZPolygon

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

ZPolygon

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

ZPolygon

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

ZPolygon

public ZPolygon(float[] xp,
                float[] yp)
Constructs a new ZPolygon. The xp, yp parameters are stored within this polygon, 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(ZPolygon refPoly)
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:
refPoly - 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 ZCoordList
Returns:
A copy of this visual component.
See Also:
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

getFillColor

public java.awt.Color getFillColor()
Get the fill color of this polygon.
Specified by:
getFillColor in interface ZFillColor
Returns:
the fill color.

setFillColor

public void setFillColor(java.awt.Color color)
Set the fill color of this polygon.
Specified by:
setFillColor in interface ZFillColor
Parameters:
color - the fill color, or null if none.

render

public void render(ZRenderContext renderContext)
Paints this object.

The transform, clip, and composite will be set appropriately when this object is rendered. It is up to this object to restore the transform, clip, and composite of the Graphics2D if this node changes any of them. However, the color, font, and stroke are unspecified by Jazz. This object should set those things if they are used, but they do not need to be restored.

Overrides:
render in class ZVisualComponent
Parameters:
renderContext - The graphics context to paint into.

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 ZCoordList

pick

public boolean pick(java.awt.geom.Rectangle2D rect,
                    ZSceneGraphPath path)
Returns true if the specified rectangle is on the polygon.
Overrides:
pick in class ZVisualComponent
Parameters:
rect - Pick rectangle of object coordinates.
Returns:
True if rectangle overlaps object.
See Also:
ZDrawingSurface.pick(int, int)

intersectsPolygon

protected boolean intersectsPolygon(java.awt.geom.Rectangle2D rect)
Determines if any part of the rectangle is inside this polygon.
Parameters:
rect - The rectangle being tested for intersecting this polygon
Returns:
true if the rectangle intersects the polygon

isInsidePolygon

protected boolean isInsidePolygon(java.awt.geom.Point2D pt)
Determines if point is inside this polygon.
Parameters:
pt - The point being tested for containment within polygon
Returns:
true if the point is inside the polygon

writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.
Overrides:
writeObject in class ZCoordList
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 ZCoordList
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field

Jazz API Documentation