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.lang.Cloneable, java.io.Serializable, ZAppearance, ZFillColor, ZPenColor, ZSerializable, ZStroke

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

ZPolygon is a visual component for displaying a polygonal shape. It has both a pen color (used for the outline) and a fill color (used to fill the shape).

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.

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
absPenWidth, closed, DEFAULT_ABS_PEN_WIDTH, 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, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZPolygon()
          Constructs a new ZPolygon with no points.
ZPolygon(double[] xp, double[] yp)
          Constructs a new ZPolygon from an array of points.
ZPolygon(double x, double y)
          Constructs a new ZPolygon with a single point.
ZPolygon(double x1, double y1, double x2, double 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.awt.Color getFillColor()
          Get the fill color of 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, computeBounds, duplicateObject, ensureSpace, getAbsPenWidth, getNumberPoints, getPath, getPenColor, getPenWidth, getStroke, getXCoords, getYCoords, isClosed, setAbsPenWidth, setClosed, setCoords, setPenColor, setPenWidth, setStroke, trimToSize, updatePath
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
addParent, getParents, getRoot, paint, pickBounds, removeParent, repaint, repaint, updateBounds, updateObjectReferences, updateParentBounds, updateVolatility, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
clone, dump, getBounds, getBoundsReference, getVolatileBounds, reshape, setBounds, setVolatileBounds
 
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(double x,
                double y)
Constructs a new ZPolygon with a single point.
Parameters:
x,y - Initial point

ZPolygon

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

ZPolygon

public ZPolygon(double[] xp,
                double[] yp)
Constructs a new ZPolygon from an array of points. 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

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.

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.
path - The path through the scenegraph to the picked node. Modified by this call.
Returns:
True if rectangle overlaps object.
See Also:
ZDrawingSurface.pick(int, int)

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