Jazz API Documentation

edu.umd.cs.jazz.component
Class ZRectangle

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

public class ZRectangle
extends ZVisualComponent
implements ZPenColor, ZFillColor, ZStroke, java.io.Serializable

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

See Also:
Serialized Form

Field Summary
static java.awt.Color fillColor_DEFAULT
           
static java.awt.Color penColor_DEFAULT
           
static float penWidth_DEFAULT
           
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, objRefTable, volatileBounds_DEFAULT
 
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.
 
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(ZRectangle refRect)
          Copies all object information from the reference object into the current object.
 java.awt.Color getFillColor()
          Get the fill color of this rectangle.
 float getHeight()
          Return height of rectangle.
 java.awt.Color getPenColor()
          Get the pen color of this rectangle.
 float getPenWidth()
          Get the width of the pen used to draw the perimeter of this rectangle.
 java.awt.geom.Rectangle2D getRect()
          Return rectangle.
 java.awt.Stroke getStroke()
          Get the stroke used to draw the visual component.
 float getWidth()
          Return width of rectangle.
 float getX()
          Return x-coord of rectangle.
 float getY()
          Return y-coord of rectangle.
 boolean pick(java.awt.geom.Rectangle2D pickRect, ZSceneGraphPath path)
          Determines if the specified rectangle overlaps this rectangle.
 void render(ZRenderContext renderContext)
          Paints this object.
 void setFillColor(java.awt.Color color)
          Set the fill color of this rectangle.
 void setPenColor(java.awt.Color color)
          Set the pen color of this rectangle.
 void setPenWidth(float width)
          Set the width of the pen used to draw the perimeter of this rectangle.
 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 setStroke(java.awt.Stroke stroke)
          Set the stroke used to draw the visual component.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
boundsUpdated, duplicateObject, getParents, paint, pickBounds, repaint, repaint, trimToSize, 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

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
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
Method Detail

duplicateObject

public void duplicateObject(ZRectangle refRect)
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:
refRect - 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 ZVisualComponent
Returns:
A copy of this visual component.
See Also:
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

getPenWidth

public float getPenWidth()
Get the width of the pen used to draw the perimeter of this rectangle. The pen is drawn centered around the rectangle vertices, so if the pen width is thick, the bounds of the rectangle will grow.
Specified by:
getPenWidth in interface ZStroke
Returns:
the pen width.

setPenWidth

public void setPenWidth(float width)
Set the width of the pen used to draw the perimeter of this rectangle. The pen is drawn centered around the rectangle vertices, so if the pen width is thick, the bounds of the rectangle will grow.
Specified by:
setPenWidth in interface ZStroke
Parameters:
width - the pen width.

getStroke

public java.awt.Stroke getStroke()
Get the stroke used to draw the visual component.
Specified by:
getStroke in interface ZStroke
Returns:
the stroke.

setStroke

public void setStroke(java.awt.Stroke stroke)
Set the stroke used to draw the visual component.
Specified by:
setStroke in interface ZStroke
Parameters:
stroke - the stroke.

getPenColor

public java.awt.Color getPenColor()
Get the pen color of this rectangle.
Specified by:
getPenColor in interface ZPenColor
Returns:
the pen color.

setPenColor

public void setPenColor(java.awt.Color color)
Set the pen color of this rectangle.
Specified by:
setPenColor in interface ZPenColor
Parameters:
color - the pen color, or null if none.

getFillColor

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

setFillColor

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

pick

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

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 ZSceneGraphObject

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

Jazz API Documentation