edu.umd.cs.jazz.component
Class ZBasicVisualComponent

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

public class ZBasicVisualComponent
extends ZVisualComponent
implements ZStroke, ZPenPaint, ZFillPaint, ZPenColor, ZFillColor

This class is designed to be extended. It takes care of managing a fillPaint, a penPaint, and a stroke, but leaves picking, and rendering to its subclasses.

Author:
Jesse Grosjean
See Also:
Serialized Form

Field Summary
protected  boolean absPenWidth
          Current absolute pen width.
static boolean DEFAULT_ABS_PEN_WIDTH
          Default absolute pen width.
static java.awt.Paint DEFAULT_FILL_PAINT
          Default fill paint.
static java.awt.Paint DEFAULT_PEN_PAINT
          Default pen paint.
static double DEFAULT_PEN_WIDTH
          Default pen width.
static java.awt.Stroke DEFAULT_STROKE
          Default stroke.
protected  java.awt.Paint fillPaint
          Current fill paint.
protected  java.awt.Paint penPaint
          Current pen paint.
protected  double penWidth
          Current pen width.
protected  java.awt.BasicStroke stroke
          Current stroke.
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, inTransaction, invalidBounds, invalidVolatileBounds, listenerList, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZBasicVisualComponent()
          ZBasicVisualComponent constructor comment.
 
Method Summary
protected  java.lang.Object duplicateObject()
          Returns a clone of this object.
 double getAbsPenWidth()
          Get the absolute width of the pen used to draw the visual component.
 java.awt.Color getFillColor()
          Deprecated. As of Jazz version 1.1, replaced by ZFillPaint.getFillPaint().
 java.awt.Paint getFillPaint()
          Get the fill paint of this visual component.
 java.awt.Color getPenColor()
          Deprecated. As of Jazz version 1.1, replaced by ZPenPaint.getPenPaint().
 java.awt.Paint getPenPaint()
          Get the pen paint of this visual component.
 double getPenWidth()
          Get the width of the pen used to draw the visual component.
protected  double getPenWidthForCurrentContext()
          Get the width of the pen used to draw the visual component while taking the current render context into consideration.
 java.awt.Stroke getStroke()
          Get the stroke used to draw the visual component.
 void setAbsPenWidth(double width)
          Set the absolute width of the pen used to draw the perimeter of this shape.
 void setFillColor(java.awt.Color color)
          Deprecated. As of Jazz version 1.1, replaced by ZFillPaint.setFillPaint(Paint aPaint).
 void setFillPaint(java.awt.Paint aPaint)
          Set the fill paint of this visual component.
 void setPenColor(java.awt.Color color)
          Deprecated. As of Jazz version 1.1, replaced by ZPenPaint.setPenPaint(Paint aPaint).
 void setPenPaint(java.awt.Paint aPaint)
          Set the pen paint of this visual component.
 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 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
addParent, getNumParents, getParents, getParentsReference, getRoot, paint, pick, pickBounds, removeParent, render, repaint, repaint, trimToSize, updateBounds, updateObjectReferences, updateVolatility, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addClientProperty, addMouseListener, addMouseMotionListener, clone, computeBounds, 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

DEFAULT_PEN_WIDTH

public static final double DEFAULT_PEN_WIDTH
Default pen width.

See Also:
Constant Field Values

DEFAULT_ABS_PEN_WIDTH

public static final boolean DEFAULT_ABS_PEN_WIDTH
Default absolute pen width.

See Also:
Constant Field Values

DEFAULT_PEN_PAINT

public static final java.awt.Paint DEFAULT_PEN_PAINT
Default pen paint.


DEFAULT_FILL_PAINT

public static final java.awt.Paint DEFAULT_FILL_PAINT
Default fill paint.


DEFAULT_STROKE

public static final java.awt.Stroke DEFAULT_STROKE
Default stroke.


fillPaint

protected transient java.awt.Paint fillPaint
Current fill paint.


penPaint

protected transient java.awt.Paint penPaint
Current pen paint.


stroke

protected transient java.awt.BasicStroke stroke
Current stroke.


penWidth

protected double penWidth
Current pen width.


absPenWidth

protected boolean absPenWidth
Current absolute pen width.

Constructor Detail

ZBasicVisualComponent

public ZBasicVisualComponent()
ZBasicVisualComponent constructor comment.

Method Detail

duplicateObject

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

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

getAbsPenWidth

public double getAbsPenWidth()
Get the absolute width of the pen used to draw the visual component. If the pen width is not absolute (dependent on magnification), then this returns 0.

Specified by:
getAbsPenWidth in interface ZStroke
Returns:
the pen width.
See Also:
getPenWidth()

getFillColor

public java.awt.Color getFillColor()
Deprecated. As of Jazz version 1.1, replaced by ZFillPaint.getFillPaint().

Get the fill color of this visual component.

Specified by:
getFillColor in interface ZFillColor
Returns:
the fill color, or null if none.

getFillPaint

public java.awt.Paint getFillPaint()
Get the fill paint of this visual component.

Specified by:
getFillPaint in interface ZFillPaint
Returns:
the fill paint, or null if none.

getPenColor

public java.awt.Color getPenColor()
Deprecated. As of Jazz version 1.1, replaced by ZPenPaint.getPenPaint().

Get the pen color of this visual component.

Specified by:
getPenColor in interface ZPenColor
Returns:
the pen color, or null if none.

getPenPaint

public java.awt.Paint getPenPaint()
Get the pen paint of this visual component.

Specified by:
getPenPaint in interface ZPenPaint
Returns:
the pen paint, or null if none.

getPenWidth

public double getPenWidth()
Get the width of the pen used to draw the visual component. If the pen width is absolute (independent of magnification), then this returns 0.

Specified by:
getPenWidth in interface ZStroke
Returns:
the pen width.
See Also:
getAbsPenWidth()

getPenWidthForCurrentContext

protected double getPenWidthForCurrentContext()
Get the width of the pen used to draw the visual component while taking the current render context into consideration. If the pen width is absolute (independent of magnification) then the resulting width will be scaled appropriately for the current context.

Returns:
the pen width scale for current context.

getStroke

public java.awt.Stroke getStroke()
Get the stroke used to draw the visual component.

Specified by:
getStroke in interface ZStroke
Returns:
the stroke.

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
Parameters:
width - the pen width.
See Also:
ZStroke.setPenWidth(double)

setFillColor

public void setFillColor(java.awt.Color color)
Deprecated. As of Jazz version 1.1, replaced by ZFillPaint.setFillPaint(Paint aPaint).

Set the fill color of this visual component.

Specified by:
setFillColor in interface ZFillColor
Parameters:
color - the fill color, or null if none.

setFillPaint

public void setFillPaint(java.awt.Paint aPaint)
Set the fill paint of this visual component.

Specified by:
setFillPaint in interface ZFillPaint
Parameters:
aPaint - the fill paint, or null if none.

setPenColor

public void setPenColor(java.awt.Color color)
Deprecated. As of Jazz version 1.1, replaced by ZPenPaint.setPenPaint(Paint aPaint).

Set the pen color of this visual component.

Specified by:
setPenColor in interface ZPenColor
Parameters:
color - the pen color, or null if none.

setPenPaint

public void setPenPaint(java.awt.Paint aPaint)
Set the pen paint of this visual component.

Specified by:
setPenPaint in interface ZPenPaint
Parameters:
aPaint - the pen paint, or null if none.

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
Parameters:
width - the pen width.
See Also:
setAbsPenWidth(double)

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.

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

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 ZVisualComponent
Parameters:
out - The stream that this object writes into
java.io.IOException


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