edu.umd.cs.jazz.component
Class ZLine

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZVisualComponent
              |
              +--edu.umd.cs.jazz.component.ZBasicVisualComponent
                    |
                    +--edu.umd.cs.jazz.component.ZShape
                          |
                          +--edu.umd.cs.jazz.component.ZLine
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, ZAppearance, ZFillColor, ZFillPaint, ZPenColor, ZPenPaint, ZSerializable, ZStroke

public class ZLine
extends ZShape

ZLine is a simple ZShape implementation that uses a Line2D as the underlying shape model.

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.

Author:
Jesse Grosjean
See Also:
Serialized Form

Field Summary
protected  java.awt.geom.Line2D line
           
 
Fields inherited from class edu.umd.cs.jazz.component.ZBasicVisualComponent
absPenWidth, DEFAULT_ABS_PEN_WIDTH, DEFAULT_FILL_PAINT, DEFAULT_PEN_PAINT, DEFAULT_PEN_WIDTH, DEFAULT_STROKE, fillPaint, penPaint, penWidth, stroke
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, inTransaction, invalidBounds, invalidVolatileBounds, listenerList, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZLine()
          ZLine constructor.
ZLine(double x1, double y1, double x2, double y2)
          ZLine constructor.
ZLine(java.awt.geom.Line2D aLine)
          ZLine constructor.
ZLine(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          ZLine constructor.
 
Method Summary
protected  void computeBounds()
          Notifies this object that it has changed and that it should update its notion of its bounding box.
protected  java.lang.Object duplicateObject()
          Returns a clone of this object.
 java.awt.geom.Line2D getLine()
          Return the line.
 java.awt.Shape getShape()
          Return the current shape.
 void render(ZRenderContext renderContext)
          Paints this object.
 void setAbsPenWidth(double width)
          Set the absolute width of the pen used to draw the perimeter of this shape.
 void setLine(double x1, double y1, double x2, double y2)
          Set the line.
 void setLine(java.awt.geom.Line2D aLine)
          Set the line.
 void setLine(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          Set the line.
 void setPenWidth(double width)
          Set the width of the pen used to draw the visual component.
 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.ZShape
getFrame, getHeight, getStrokeTransformForAbsPenWidth, getWidth, getX, getY, pick, pickStroke
 
Methods inherited from class edu.umd.cs.jazz.component.ZBasicVisualComponent
getAbsPenWidth, getFillColor, getFillPaint, getPenColor, getPenPaint, getPenWidth, getPenWidthForCurrentContext, getStroke, setFillColor, setFillPaint, setPenColor, setPenPaint, setStroke
 
Methods inherited from class edu.umd.cs.jazz.ZVisualComponent
addParent, getNumParents, getParents, getParentsReference, getRoot, paint, pickBounds, removeParent, repaint, repaint, trimToSize, updateBounds, updateObjectReferences, updateVolatility, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addClientProperty, addMouseListener, addMouseMotionListener, clone, computeVolatileBounds, dump, endTransaction, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getClientProperty, getHandles, getListenerList, getVolatileBounds, hasLisenerOfType, hasListenerOfType, hasMouseListener, markInTransaction, markNotInTransaction, processMouseEvent, putClientProperty, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds, startTransaction
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line

protected transient java.awt.geom.Line2D line
Constructor Detail

ZLine

public ZLine()
ZLine constructor.


ZLine

public ZLine(java.awt.geom.Line2D aLine)
ZLine constructor.


ZLine

public ZLine(java.awt.geom.Point2D pt1,
             java.awt.geom.Point2D pt2)
ZLine constructor.


ZLine

public ZLine(double x1,
             double y1,
             double x2,
             double y2)
ZLine constructor.

Method Detail

duplicateObject

protected java.lang.Object duplicateObject()
Returns a clone of this object.

Overrides:
duplicateObject in class ZBasicVisualComponent
See Also:
ZSceneGraphObject.duplicateObject()

getLine

public java.awt.geom.Line2D getLine()
Return the line.


setAbsPenWidth

public void setAbsPenWidth(double width)
Set the absolute width of the pen used to draw the perimeter of this shape. Absolute pen width means that the stroke of this shape will always be drawn to the screen at the same size no matter what the camera magnification is.

When drawing with an abs pen width the component is stroked on the inside of its bounds, not along the center as is the standard method for Java and Jazz. This is done so that the global bounds of the shape do not need to change when the camera zooms.

A consequence of stroking on the inside of the component is that components with zero width or height will not get drawn even if they have a non zero pen width, since there is no interior space for the pen width to expand into. This could happen for instance if a ZPolyline is drawn with all its points in a line along the same axis. SO BE WARNED!

ZLine presents an extreme case of this, since whenever it is drawn along the x or y axis it will not get drawn. Because of this ZLine implements abs pen width differently. ZLines are always stroked along the center of the line, so as the camera moves a ZLines global bounds will change if it has abs pen width.

Specified by:
setAbsPenWidth in interface ZStroke
Overrides:
setAbsPenWidth in class ZBasicVisualComponent
Parameters:
width - the pen width.

setPenWidth

public void setPenWidth(double width)
Set the width of the pen used to draw the visual component. If the pen width is set here, then the stroke is set to solid (un-dashed), with a "butt" cap style, and a "bevel" join style. The pen width will be dependent on the camera magnification.

Specified by:
setPenWidth in interface ZStroke
Overrides:
setPenWidth in class ZBasicVisualComponent
Parameters:
width - the pen width.
See Also:
setAbsPenWidth(double)

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 ZShape

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 ZShape

getShape

public java.awt.Shape getShape()
Return the current shape.

Specified by:
getShape in class ZShape

setLine

public void setLine(java.awt.geom.Line2D aLine)
Set the line.


setLine

public void setLine(java.awt.geom.Point2D pt1,
                    java.awt.geom.Point2D pt2)
Set the line.


setLine

public void setLine(double x1,
                    double y1,
                    double x2,
                    double y2)
Set the line.


writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.

Specified by:
writeObject in interface ZSerializable
Overrides:
writeObject in class ZBasicVisualComponent
Parameters:
out - The stream that this object writes into
java.io.IOException

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.

Specified by:
setState in interface ZSerializable
Overrides:
setState in class ZBasicVisualComponent
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field


Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.