edu.umd.cs.jazz.component
Class ZPolygon

java.lang.Object
  |
  +--edu.umd.cs.jazz.scenegraph.ZVisualComponent
        |
        +--edu.umd.cs.jazz.component.ZCoordList
              |
              +--edu.umd.cs.jazz.component.ZPolygon

public class ZPolygon
extends ZCoordList

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


Field Summary
static java.awt.Color DEFAULT_FILL_COLOR
           
static java.awt.Color DEFAULT_PEN_COLOR
           
static float DEFAULT_PEN_WIDTH
           
protected  java.awt.Color fillColor
           
protected  int join
           
protected  java.awt.Color penColor
           
protected  float penWidth
           
protected  java.awt.BasicStroke stroke
           
 
Fields inherited from class edu.umd.cs.jazz.component.ZCoordList
ARRAY_INC, closed, DEFAULT_CLOSED, empty, np, path, xp, yp
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
cacheVolatile, findable, findable_DEFAULT, isVolatile, localBounds, localBoundsDirty, parent, pickable, pickable_DEFAULT, selected
 
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.
ZPolygon(ZPolygon poly)
          Constructs a new ZPolygon that is a duplicate of the reference polygon, i.e., a "copy constructor"
 
Method Summary
 java.lang.Object clone()
          Duplicates the current ZPolygon by using the copy constructor.
protected  void computeLocalBounds()
          Notifies this object that it has changed and that it should update its notion of its bounding box.
 java.awt.Color getFillColor()
          Get the fill color of this polygon.
 java.awt.Color getPenColor()
          Get the pen color of this polygon.
 float getPenWidth()
          Get the width of the pen used to draw the line around the edge 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.
 void paint(ZRenderContext renderContext)
          Paints this object.
 boolean pick(java.awt.geom.Rectangle2D rect)
          Returns true if the specified rectangle is on the polygon.
 void setFillColor(java.awt.Color color)
          Set the fill color of this polygon.
 void setPenColor(java.awt.Color color)
          Set the pen color of this polygon.
 void setPenWidth(float width)
          Set the width of the pen used to draw the line around the edge 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, ensureSpace, getNumberPoints, getPath, getXCoords, getYCoords, isClosed, setClosed, setCoords, trimToSize, updatePath
 
Methods inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
damage, damage, findNode, findVisualComponent, getLocalBounds, getParent, isFindable, isPickable, isSelected, isVolatile, pickBounds, select, select, setFindable, setParent, setPickable, setSelected, setVisualComponent, setVolatile, toString, transformChanged, unselect, updateBounds, updateChildBounds, updateLocalBounds, updateVolatility, writeObjectRecurse
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PEN_COLOR

public static final java.awt.Color DEFAULT_PEN_COLOR

DEFAULT_FILL_COLOR

public static final java.awt.Color DEFAULT_FILL_COLOR

DEFAULT_PEN_WIDTH

public static final float DEFAULT_PEN_WIDTH

penColor

protected java.awt.Color penColor

fillColor

protected java.awt.Color fillColor

penWidth

protected float penWidth

join

protected int join

stroke

protected java.awt.BasicStroke stroke
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

ZPolygon

public ZPolygon(ZPolygon poly)
Constructs a new ZPolygon that is a duplicate of the reference polygon, i.e., a "copy constructor"
Parameters:
poly - Reference polygon
Method Detail

clone

public java.lang.Object clone()
Duplicates the current ZPolygon by using the copy constructor. See the copy constructor comments for complete information about what is duplicated.
Overrides:
clone in class ZCoordList
See Also:
ZPolygon(ZPolygon)

getPenWidth

public float getPenWidth()
Get the width of the pen used to draw the line around the edge of this polygon. The pen is drawn centered around the polygon vertices, so if the pen width is thick, the bounds of the polygon will grow.
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 polygon. The pen is drawn centered around the polygon vertices, so if the pen width is thick, the bounds of the polyline will grow.
Parameters:
width - the pen width.

getPenColor

public java.awt.Color getPenColor()
Get the pen color of this polygon.
Returns:
the pen color.

setPenColor

public void setPenColor(java.awt.Color color)
Set the pen color of this polygon.
Parameters:
color - the pen color, or null if none.

getFillColor

public java.awt.Color getFillColor()
Get the fill color of this polygon.
Returns:
the fill color.

setFillColor

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

paint

public void paint(ZRenderContext renderContext)
Paints this object.
Parameters:
g2 - The graphics context to paint into.
Overrides:
paint in class ZVisualComponent

computeLocalBounds

protected void computeLocalBounds()
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:
computeLocalBounds in class ZCoordList
See Also:
ZNode.getGlobalBounds()

pick

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

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.
Parameters:
out - The stream that this object writes into
Overrides:
writeObject in class ZCoordList

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.
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field
Overrides:
setState in class ZCoordList