Jazz API Documentation

edu.umd.cs.jazz
Class ZVisualLeaf

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZNode
              |
              +--edu.umd.cs.jazz.ZLeaf
                    |
                    +--edu.umd.cs.jazz.ZVisualLeaf
All Implemented Interfaces:
java.io.Serializable, ZSerializable

public class ZVisualLeaf
extends ZLeaf
implements ZSerializable, java.io.Serializable

ZVisualLeaf is a leaf node that has a visual component that can be rendered.

See Also:
Serialized Form

Fields inherited from class edu.umd.cs.jazz.ZNode
findable_DEFAULT, listenerList, pickable_DEFAULT, savable_DEFAULT
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, objRefTable, volatileBounds_DEFAULT
 
Constructor Summary
ZVisualLeaf()
          Constructs a new empty visual leaf node.
ZVisualLeaf(ZVisualComponent newVisualComponent)
          Constructs a new visual leaf node with the specified visual component.
 
Method Summary
 java.lang.Object clone()
          Duplicates the current node by using the copy constructor.
protected  void computeBounds()
          Recomputes and caches the bounds for this node.
 void duplicateObject(ZVisualLeaf refNode)
          Copies all object information from the reference object into the current object.
 ZVisualComponent getVisualComponent()
          Return the visual component associated with this leaf, or null if none.
 ZBounds getVisualComponentBounds()
          Return a copy of the bounds of this node's visual component in local coordinates.
 ZBounds getVisualComponentGlobalBounds()
          Return a copy of the bounds of this node's visual component in global coordinates.
 boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
          Returns this node if the visual component referenced by this node is under the specified rectangle.
 void render(ZRenderContext renderContext)
          Renders this node which results in the node's visual component getting painted.
 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 setVisualComponent(ZVisualComponent newVisualComponent)
          Set the visual component associated with this leaf node.
protected  void updateVolatility()
          Internal method to compute and cache the volatility of a node, to recursively call the parents to compute volatility.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 void writeObjectRecurse(ZObjectOutputStream out)
          Specify which objects this object references in order to write out the scenegraph properly
 
Methods inherited from class edu.umd.cs.jazz.ZLeaf
duplicateObject
 
Methods inherited from class edu.umd.cs.jazz.ZNode
addClientProperty, addMouseListener, addMouseMotionListener, dump, duplicateObject, editor, fireMouseEvent, getClientProperty, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, hasMouseListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, localToGlobal, localToGlobal, lower, lowerTo, putClientProperty, raise, raiseTo, removeMouseListener, removeMouseMotionListener, repaint, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, trimToSize, updateBounds, updateObjectReferences, writeReplace
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
duplicateObject, getBounds, getVolatileBounds, reshape, setVolatileBounds
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZVisualLeaf

public ZVisualLeaf()
Constructs a new empty visual leaf node.

ZVisualLeaf

public ZVisualLeaf(ZVisualComponent newVisualComponent)
Constructs a new visual leaf node with the specified visual component.
Parameters:
newVisualComponent - The new visual component that this leaf displays.
Method Detail

duplicateObject

public void duplicateObject(ZVisualLeaf refNode)
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:
refNode - The reference node to copy

clone

public java.lang.Object clone()
Duplicates the current node by using the copy constructor. The portion of the reference node that is duplicated is that necessary to reuse the node in a new place within the scenegraph, but the new node is not inserted into any scenegraph. The node 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 ZLeaf
Returns:
A copy of this node.
See Also:
ZNode.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

setVisualComponent

public void setVisualComponent(ZVisualComponent newVisualComponent)
Set the visual component associated with this leaf node. If this node previously had a visual component associated with it, than that component will be replaced with the new one.
Parameters:
newVisualComponent - The new visual component for this node.

getVisualComponent

public final ZVisualComponent getVisualComponent()
Return the visual component associated with this leaf, or null if none.

updateVolatility

protected void updateVolatility()
Internal method to compute and cache the volatility of a node, to recursively call the parents to compute volatility. All parents of this node are also volatile when this is volatile. A leaf is volatile if either the node or it's visual component is volatile.
Overrides:
updateVolatility in class ZNode
See Also:
ZSceneGraphObject.setVolatileBounds(boolean), ZSceneGraphObject.getVolatileBounds()

render

public void render(ZRenderContext renderContext)
Renders this node which results in the node's visual component getting painted.

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 ZNode
Parameters:
renderContext - The graphics context to use for rendering.

computeBounds

protected void computeBounds()
Recomputes and caches the bounds for this node. Generally this method is called by reshape when the bounds have changed, and it should rarely directly elsewhere. A ZVisualLeaf bounds is the bounds of its visual component
Overrides:
computeBounds in class ZSceneGraphObject

pick

public boolean pick(java.awt.geom.Rectangle2D rect,
                    ZSceneGraphPath path)
Returns this node if the visual component referenced by this node is under the specified rectangle. Only returns "pickable" nodes.
Overrides:
pick in class ZNode
Parameters:
rect - Coordinates of pick rectangle in local coordinates
mag - The magnification of the camera being picked within.
Returns:
The picked node, or null if none
See Also:

getVisualComponentBounds

public ZBounds getVisualComponentBounds()
Return a copy of the bounds of this node's visual component in local coordinates. If this node does not have a visual component, then this returns null.
Returns:
The visual component's bounds in local coordinates (or null if no visual component).

getVisualComponentGlobalBounds

public ZBounds getVisualComponentGlobalBounds()
Return a copy of the bounds of this node's visual component in global coordinates. If this node does not have a visual component, then this returns null. Note that global bounds are not cached, and this method involves some computation.
Returns:
The visual component's bounds in global coordinates (or null if no visual component).

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 ZNode
Parameters:
out - The stream that this object writes into

writeObjectRecurse

public void writeObjectRecurse(ZObjectOutputStream out)
                        throws java.io.IOException
Specify which objects this object references in order to write out the scenegraph properly
Specified by:
writeObjectRecurse in interface ZSerializable
Overrides:
writeObjectRecurse in class ZNode
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.
Specified by:
setState in interface ZSerializable
Overrides:
setState in class ZNode
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field

Jazz API Documentation