edu.umd.cs.jazz.component
Class ZRectangle

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

public class ZRectangle
extends ZVisualComponent
implements java.lang.Cloneable

ZRectangle is a graphic object that represents a hard-cornered or rounded rectangle.


Field Summary
protected  java.awt.Color fillColor
           
static java.awt.Color fillColor_DEFAULT
           
protected  java.awt.Color penColor
           
static java.awt.Color penColor_DEFAULT
           
protected  float penWidth
           
static float penWidth_DEFAULT
           
protected  java.awt.geom.Rectangle2D rect
           
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
cacheVolatile, findable, findable_DEFAULT, isVolatile, localBounds, localBoundsDirty, parent, pickable, pickable_DEFAULT, selected
 
Constructor Summary
ZRectangle()
          Constructs a new Rectangle.
ZRectangle(float x, float y)
          Constructs a new Rectangle.
ZRectangle(float x, float y, float width, float height)
          Constructs a new Rectangle.
ZRectangle(java.awt.geom.Rectangle2D r)
          Constructs a new Rectangle based on the geometry of the one passed in.
ZRectangle(ZRectangle r)
          Constructs a new ZRectangle based on the one passed in (i.e., a "copy constructor").
 
Method Summary
 java.lang.Object clone()
          Duplicates the current ZRectangle by using the copy constructor.
protected  void computeLocalBounds()
           
 java.awt.Color getFillColor()
           
 float getHeight()
          Return height of rectangle.
 java.awt.Color getPenColor()
           
 float getPenWidth()
           
 java.awt.geom.Rectangle2D getRect()
          Return rectangle.
 float getWidth()
          Return width of rectangle.
 float getX()
          Return x-coord of rectangle.
 float getY()
          Return y-coord of rectangle.
 void paint(ZRenderContext renderContext)
          Paints this object.
 boolean pick(java.awt.geom.Rectangle2D pickRect)
          Determines if the specified rectangle overlaps this rectangle.
 void setFillColor(java.awt.Color color)
           
 void setPenColor(java.awt.Color color)
           
 void setPenWidth(float width)
           
 void setRect(float x, float y, float width, float height)
          Sets coords of rectangle
 void setRect(java.awt.geom.Rectangle2D r)
          Sets coords of rectangle
 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.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

penColor_DEFAULT

public static final java.awt.Color penColor_DEFAULT

fillColor_DEFAULT

public static final java.awt.Color fillColor_DEFAULT

penWidth_DEFAULT

public static final float penWidth_DEFAULT

penColor

protected java.awt.Color penColor

penWidth

protected float penWidth

fillColor

protected java.awt.Color fillColor

rect

protected java.awt.geom.Rectangle2D rect
Constructor Detail

ZRectangle

public ZRectangle()
Constructs a new Rectangle.

ZRectangle

public ZRectangle(float x,
                  float y)
Constructs a new Rectangle.
Parameters:
x - X-coord of top-left corner
y - Y-coord of top-left corner

ZRectangle

public ZRectangle(float x,
                  float y,
                  float width,
                  float height)
Constructs a new Rectangle.
Parameters:
x - X-coord of top-left corner
y - Y-coord of top-left corner
width - Width of rectangle
height - Height of rectangle

ZRectangle

public ZRectangle(java.awt.geom.Rectangle2D r)
Constructs a new Rectangle based on the geometry of the one passed in.
Parameters:
r - A rectangle to get the geometry from

ZRectangle

public ZRectangle(ZRectangle r)
Constructs a new ZRectangle based on the one passed in (i.e., a "copy constructor").
Parameters:
r - A rectangle to duplicate
Method Detail

clone

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

getPenWidth

public float getPenWidth()

setPenWidth

public void setPenWidth(float width)

getPenColor

public java.awt.Color getPenColor()

setPenColor

public void setPenColor(java.awt.Color color)

getFillColor

public java.awt.Color getFillColor()

setFillColor

public void setFillColor(java.awt.Color color)

pick

public boolean pick(java.awt.geom.Rectangle2D pickRect)
Determines if the specified rectangle overlaps this rectangle.
Parameters:
pickRect - The rectangle that is picking this rectangle
Returns:
true if the rectangle picks this visual component
Overrides:
pick in class ZVisualComponent

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()
Overrides:
computeLocalBounds in class ZVisualComponent

getX

public float getX()
Return x-coord of rectangle.
Returns:
x-coord.

getY

public float getY()
Return y-coord of rectangle.
Returns:
y-coord.

getWidth

public float getWidth()
Return width of rectangle.
Returns:
width.

getHeight

public float getHeight()
Return height of rectangle.
Returns:
height.

getRect

public java.awt.geom.Rectangle2D getRect()
Return rectangle.
Returns:
rectangle.

setRect

public void setRect(float x,
                    float y,
                    float width,
                    float height)
Sets coords of rectangle
Parameters:
x - X-coord of top-left corner
y - Y-coord of top-left corner
width - Width of rectangle
height - Height of rectangle

setRect

public void setRect(java.awt.geom.Rectangle2D r)
Sets coords of rectangle
Parameters:
r - The new rectangle coordinates

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 ZVisualComponent

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 ZVisualComponent