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.lang.Cloneable, java.io.Serializable, ZSerializable

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

See Also:
Serialized Form

Field Summary
protected  ZList.ZVisualComponentList visualComponents
          The visual components associated with this leaf.
 
Fields inherited from class edu.umd.cs.jazz.ZNode
editorFactory, findable_DEFAULT, parent, pickable_DEFAULT, savable_DEFAULT, selectable_DEFAULT
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, inTransaction, invalidBounds, invalidVolatileBounds, listenerList, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZVisualLeaf()
          Constructs a new empty visual leaf node.
ZVisualLeaf(ZVisualComponent visualComponent)
          Constructs a new visual leaf node with the specified visual component.
 
Method Summary
 void addVisualComponent(ZVisualComponent visualComponent)
          Add a new visual component to this leaf node.
 void addVisualComponents(java.util.Collection aVisualComponentCollection)
          Add a collection of new visual components to this leaf node.
 void clearVisualComponents()
          Remove all visual components from this visual leaf.
protected  void computeBounds()
          Recomputes and caches the bounds for this node.
protected  void computeVolatileBounds()
          Compute volatileBoundsCache for visualComponents.
protected  java.lang.Object duplicateObject()
          Returns a clone of this object.
 ZVisualComponent getFirstVisualComponent()
          Return the first visual component associated with this leaf, or null if there are none.
 java.util.Collection getHandles()
          Return the handles associated with this leaf.
 int getNumVisualComponents()
          Return the number of visual components of this visual leaf.
 ZVisualComponent getVisualComponent(int i)
          Returns the i'th visual component of this node.
 ZBounds getVisualComponentBounds()
          Return a copy of the bounds of this node's visual components in local coordinates.
 ZBounds getVisualComponentGlobalBounds()
          Return a copy of the bounds of this node's visual components in global coordinates.
 ZVisualComponent[] getVisualComponents()
          Return the visual components associated with this visual leaf.
 boolean getVolatileBounds()
          Determines if this node is volatile.
 int indexOf(ZVisualComponent vis)
          Returns the index of the specified visual component or -1 if the visual component has not been added to this leaf
protected  void markInTransaction()
          Mark this object and all its visualComponents as being part of a transaction.
protected  void markNotInTransaction()
          Mark this object and all its visualComponents as not being part of a transaction.
 boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
          Returns true if any of this node's visual components are under the specified rectangle, and builds a ZSceneGraphPath to the node.
 void removeVisualComponent(ZVisualComponent visualComponent)
          Remove a visual component from this leaf node.
 void render(ZRenderContext renderContext)
          Renders this node which results its visual components 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(int i, ZVisualComponent visualComponent)
          Replace the i'th visual component associated with this leaf node.
 void setVisualComponent(ZVisualComponent visualComponent)
          Set the visual component associated with this leaf node.
 void trimToSize()
          Trims the capacity of the array that stores the visual components list to the actual number of points.
protected  void updateObjectReferences(ZObjectReferenceTable objRefTable)
          Called to update internal object references after a clone operation by ZSceneGraphObject.clone().
 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.ZNode
addNodeListener, editor, extract, findNodes, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, raise, raiseTo, remove, removeNodeListener, repaint, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, setSelectable, setVolatileBounds, updateBounds, updateVolatility, writeReplace
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addClientProperty, addMouseListener, addMouseMotionListener, clone, dump, endTransaction, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getClientProperty, getListenerList, hasLisenerOfType, hasListenerOfType, hasMouseListener, processMouseEvent, putClientProperty, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, startTransaction
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visualComponents

protected ZList.ZVisualComponentList visualComponents
The visual components associated with this leaf.

Constructor Detail

ZVisualLeaf

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


ZVisualLeaf

public ZVisualLeaf(ZVisualComponent visualComponent)
Constructs a new visual leaf node with the specified visual component.

Parameters:
visualComponent - The new visual component that this leaf displays.
Method Detail

addVisualComponent

public void addVisualComponent(ZVisualComponent visualComponent)
Add a new visual component to this leaf node. If this leaf already contains this component, then nothing happens.

Parameters:
visualComponent - The visual component to be added.

addVisualComponents

public void addVisualComponents(java.util.Collection aVisualComponentCollection)
Add a collection of new visual components to this leaf node. If you have a large group of visualComponents to add to a ZVisualLeaf this method will be much faster then repeatedly calling addVisualComponent.

Parameters:
aVisualComponentCollection - The collection to be added.

clearVisualComponents

public void clearVisualComponents()
Remove all visual components from this visual leaf.


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 the union of its visual components.

Overrides:
computeBounds in class ZSceneGraphObject

duplicateObject

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

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

getFirstVisualComponent

public final ZVisualComponent getFirstVisualComponent()
Return the first visual component associated with this leaf, or null if there are none.


getHandles

public java.util.Collection getHandles()
Return the handles associated with this leaf.

Overrides:
getHandles in class ZSceneGraphObject

getNumVisualComponents

public int getNumVisualComponents()
Return the number of visual components of this visual leaf.

Returns:
the number of visual components.

getVisualComponent

public ZVisualComponent getVisualComponent(int i)
Returns the i'th visual component of this node.

Returns:
the i'th visual component of this node.

getVisualComponentBounds

public ZBounds getVisualComponentBounds()
Return a copy of the bounds of this node's visual components in local coordinates. If this node does not have any visual components, then this returns null.

Returns:
The union of this node's visual component's bounds in local coordinates (or null if there are no visual components).

getVisualComponentGlobalBounds

public ZBounds getVisualComponentGlobalBounds()
Return a copy of the bounds of this node's visual components in global coordinates. If this node does not have any visual components, 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 there are no visual components).

getVisualComponents

public final ZVisualComponent[] getVisualComponents()
Return the visual components associated with this visual leaf.


getVolatileBounds

public boolean getVolatileBounds()
Determines if this node is volatile. A node is considered to be volatile if it is specifically set to be volatile with ZNode.setVolatileBounds(boolean). All parents of this node are also volatile when this is volatile.

Volatile objects are those objects that change regularly, such as an object that is animated, or one whose rendering depends on its context.

Overrides:
getVolatileBounds in class ZSceneGraphObject
Returns:
true if this node is volatile
See Also:
ZNode.setVolatileBounds(boolean)

computeVolatileBounds

protected void computeVolatileBounds()
Compute volatileBoundsCache for visualComponents. getVolatileBounds() returns this cache ored with this objects volatileBounds varriable.

Overrides:
computeVolatileBounds in class ZSceneGraphObject

indexOf

public int indexOf(ZVisualComponent vis)
Returns the index of the specified visual component or -1 if the visual component has not been added to this leaf

Returns:
The index of the specified visual component or -1

pick

public boolean pick(java.awt.geom.Rectangle2D rect,
                    ZSceneGraphPath path)
Returns true if any of this node's visual components are under the specified rectangle, and builds a ZSceneGraphPath to the node. Only returns "pickable" nodes.

Overrides:
pick in class ZNode
Parameters:
rect - Coordinates of pick rectangle in local coordinates
path - The path through the scenegraph to the picked node. Modified by this call.
Returns:
The picked node, or null if none
See Also:
ZDrawingSurface.pick(int, int)

removeVisualComponent

public void removeVisualComponent(ZVisualComponent visualComponent)
Remove a visual component from this leaf node. If this leaf didn't already contains this component, then nothing happens.

Parameters:
visualComponent - The visual component to be removed.

render

public void render(ZRenderContext renderContext)
Renders this node which results its visual components 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.

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

setVisualComponent

public void setVisualComponent(int i,
                               ZVisualComponent visualComponent)
Replace the i'th visual component associated with this leaf node. If this node does not already have an i'th visual component, then an IndexOutOfBoundsException is thrown.

Parameters:
i - The index of the visual component to replace
visualComponent - The new visual component for this node.

setVisualComponent

public void setVisualComponent(ZVisualComponent visualComponent)
Set the visual component associated with this leaf node. If this node previously had any visual components associated with it, then those components will be replaced with the new one.

Parameters:
visualComponent - The new visual component for this node.

trimToSize

public void trimToSize()
Trims the capacity of the array that stores the visual components list to the actual number of points. Normally, the visual components list array can be slightly larger than the number of points in the visual components list. An application can use this operation to minimize the storage of a visual components list.

Overrides:
trimToSize in class ZSceneGraphObject

updateObjectReferences

protected void updateObjectReferences(ZObjectReferenceTable objRefTable)
Called to update internal object references after a clone operation by ZSceneGraphObject.clone().

Overrides:
updateObjectReferences in class ZSceneGraphObject
Parameters:
objRefTable - Table mapping from uncloned objects to their cloned versions.
See Also:
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

markInTransaction

protected void markInTransaction()
Mark this object and all its visualComponents as being part of a transaction.

Overrides:
markInTransaction in class ZSceneGraphObject

markNotInTransaction

protected void markNotInTransaction()
Mark this object and all its visualComponents as not being part of a transaction.

Overrides:
markNotInTransaction in class ZSceneGraphObject

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
java.io.IOException

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 ZSceneGraphObject
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.