edu.umd.cs.jazz
Class ZVisualGroup

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZNode
              |
              +--edu.umd.cs.jazz.ZGroup
                    |
                    +--edu.umd.cs.jazz.ZVisualGroup
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, ZSerializable
Direct Known Subclasses:
ZAnchorGroup, ZLayoutGroup, ZSelectionGroup

public class ZVisualGroup
extends ZGroup
implements ZSerializable, java.io.Serializable

ZVisualGroup is a group node that has a visual components that can be rendered. It has two visual components (either or both of which could be null) which get rendered before and after the node's children, respectively.

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:
Ben Bederson
See Also:
Serialized Form

Field Summary
static boolean visualComponentPickable_DEFAULT
           
 
Fields inherited from class edu.umd.cs.jazz.ZGroup
children, childrenFindable_DEFAULT, childrenPickable_DEFAULT, childrenVolatileBoundsCache, hasOneChild_DEFAULT
 
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
ZVisualGroup()
          Constructs a new empty visual group node.
ZVisualGroup(ZNode child)
          Constructs a new visual group node with the specified node as a child of the new group.
ZVisualGroup(ZNode child, ZVisualComponent newFrontVisualComponent, ZVisualComponent newBackVisualComponent)
          Constructs a new ZVisualGroup with the specified visual components, and specified node as a child of the new group.
ZVisualGroup(ZVisualComponent newFrontVisualComponent, ZVisualComponent newBackVisualComponent)
          Constructs a new ZVisualGroup with the specified visual components.
 
Method Summary
protected  void computeBounds()
          Recomputes and caches the bounds for this node.
protected  void computeVolatileBounds()
          Compute the volatileBoundsCache, taking into consideration the front and back visual components.
protected  java.lang.Object duplicateObject()
          Returns a clone of this object.
 ZVisualComponent getBackVisualComponent()
          Return the back visual component associated with this leaf, or null if none.
 ZBounds getBackVisualComponentBounds()
          Return a copy of the bounds of this node's back visual component in local coordinates.
 ZBounds getBackVisualComponentGlobalBounds()
          Return a copy of the bounds of this node's back visual component in global coordinates.
 ZVisualComponent getFrontVisualComponent()
          Return the front visual component associated with this leaf, or null if none.
 ZBounds getFrontVisualComponentBounds()
          Return a copy of the bounds of this node's front visual component in local coordinates.
 ZBounds getFrontVisualComponentGlobalBounds()
          Return a copy of the bounds of this node's front visual component in global coordinates.
 ZBounds getShallowBounds()
          Return the bounds of this ZGroup without taking the groups children into consideration.
 boolean isBackVisualComponentPickable()
          Determines if this node's back visual component is pickable.
 boolean isFrontVisualComponentPickable()
          Determines if this node's front visual component is pickable.
protected  void markInTransaction()
          Mark the scenegraph rooted at this node as being in a transaction.
protected  void markNotInTransaction()
          Mark the scenegraph rooted at this node as not being in a transaction.
 boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
          Returns the first object under the specified rectangle (if there is one) in the subtree rooted with this as searched in reverse (front-to-back) order.
 void render(ZRenderContext renderContext)
          Renders this node which results in the node's visual component getting rendered, followed by its children getting rendered.
 void setBackVisualComponent(ZVisualComponent newBackVisualComponent)
          Set the back visual component associated with this group node.
 void setBackVisualComponentPickable(boolean backVisualComponentPickable)
          Specifies whether this node's back visual component is pickable.
 void setFrontVisualComponent(ZVisualComponent newFrontVisualComponent)
          Set the front visual component associated with this group node.
 void setFrontVisualComponentPickable(boolean frontVisualComponentPickable)
          Specifies whether this node's front visual component is pickable.
 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.
 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.ZGroup
addChild, addChildImpl, addChildren, addChildren, addGroupListener, childAddedNotification, childRemovedNotification, dump, extract, findNodes, getChild, getChildren, getChildrenFindable, getChildrenIterator, getChildrenPickable, getChildrenReference, getNumChildren, getVolatileBounds, hasOneChild, indexOf, insertAbove, iterator, lower, lowerTo, raise, raiseTo, removeAllChildren, removeAllChildren, removeChild, removeChild, removeChild, removeChildImpl, removeGroupListener, removeNodeListener, setChildrenFindable, setChildrenPickable, setHasOneChild, trimToSize, updateHasNodeListener
 
Methods inherited from class edu.umd.cs.jazz.ZNode
addNodeListener, editor, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, raise, raiseTo, remove, 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, endTransaction, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getClientProperty, getHandles, getListenerList, hasLisenerOfType, hasListenerOfType, hasMouseListener, processMouseEvent, putClientProperty, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, startTransaction, updateObjectReferences
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visualComponentPickable_DEFAULT

public static final boolean visualComponentPickable_DEFAULT
See Also:
Constant Field Values
Constructor Detail

ZVisualGroup

public ZVisualGroup()
Constructs a new empty visual group node.


ZVisualGroup

public ZVisualGroup(ZNode child)
Constructs a new visual group node with the specified node as a child of the new group.

Parameters:
child - Child of the new group node.

ZVisualGroup

public ZVisualGroup(ZVisualComponent newFrontVisualComponent,
                    ZVisualComponent newBackVisualComponent)
Constructs a new ZVisualGroup with the specified visual components.

Parameters:
newFrontVisualComponent - The new front visual component that this group displays.
newBackVisualComponent - The new back visual component that this group displays.

ZVisualGroup

public ZVisualGroup(ZNode child,
                    ZVisualComponent newFrontVisualComponent,
                    ZVisualComponent newBackVisualComponent)
Constructs a new ZVisualGroup with the specified visual components, and specified node as a child of the new group.

Parameters:
child - Child of the new group node.
newFrontVisualComponent - The new front visual component that this group displays.
newBackVisualComponent - The new back visual component that this group displays.
Method Detail

duplicateObject

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

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

setFrontVisualComponent

public void setFrontVisualComponent(ZVisualComponent newFrontVisualComponent)
Set the front visual component associated with this group node. This visual component gets rendered after the group's children, thus appears visually in front. If this node previously had a front visual component associated with it, than that component will be replaced with the new one.

Parameters:
newFrontVisualComponent - The new front visual component for this node.
See Also:
setBackVisualComponent(edu.umd.cs.jazz.ZVisualComponent)

getFrontVisualComponent

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


setBackVisualComponent

public void setBackVisualComponent(ZVisualComponent newBackVisualComponent)
Set the back visual component associated with this group node. This visual component gets rendered before the group's children, thus appears visually in back. If this node previously had a back visual component associated with it, than that component will be replaced with the new one.

Parameters:
newBackVisualComponent - The new back visual component for this node.
See Also:
setFrontVisualComponent(edu.umd.cs.jazz.ZVisualComponent)

getBackVisualComponent

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


computeVolatileBounds

protected void computeVolatileBounds()
Compute the volatileBoundsCache, taking into consideration the front and back visual components.

Overrides:
computeVolatileBounds in class ZGroup

setFrontVisualComponentPickable

public void setFrontVisualComponentPickable(boolean frontVisualComponentPickable)
Specifies whether this node's front visual component is pickable. If false, then the pick methods will never pick this node based on its front visual component.


isFrontVisualComponentPickable

public final boolean isFrontVisualComponentPickable()
Determines if this node's front visual component is pickable. If false, then the pick methods will never pick this node based on its front visual component.

Returns:
True if this node's front visual component is pickable.

setBackVisualComponentPickable

public void setBackVisualComponentPickable(boolean backVisualComponentPickable)
Specifies whether this node's back visual component is pickable. If false, then the pick methods will never pick this node based on its back visual component.


isBackVisualComponentPickable

public final boolean isBackVisualComponentPickable()
Determines if this node's back visual component is pickable. If false, then the pick methods will never pick this node based on its back visual component.

Returns:
True if this node's back visual component is pickable.

render

public void render(ZRenderContext renderContext)
Renders this node which results in the node's visual component getting rendered, followed by its children getting rendered.

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 ZGroup
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 ZVisualGroup bounds is the bounds of its visual components and its children.

Overrides:
computeBounds in class ZGroup

markInTransaction

protected void markInTransaction()
Mark the scenegraph rooted at this node as being in a transaction.

Overrides:
markInTransaction in class ZGroup

markNotInTransaction

protected void markNotInTransaction()
Mark the scenegraph rooted at this node as not being in a transaction.

Overrides:
markNotInTransaction in class ZGroup

pick

public boolean pick(java.awt.geom.Rectangle2D rect,
                    ZSceneGraphPath path)
Returns the first object under the specified rectangle (if there is one) in the subtree rooted with this as searched in reverse (front-to-back) order. This performs a depth-first search, first picking children. Only returns a node if this is "pickable". If no nodes in the sub-tree are picked, then this node's visual component is picked.

This first checks the front visual component for picking, then the children, and then the back visual component. However, the visual components can be ignored for picking if they are set to not be pickable.

If childrenPickable is false, then this will never return a child as the picked node. Instead, this node will be returned if any children are picked, or one of this node's visual components is picked. Else, it will return null.

Overrides:
pick in class ZGroup
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)

getFrontVisualComponentBounds

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

Returns:
The front visual component's bounds in local coordinates (or null if no front visual component).

getFrontVisualComponentGlobalBounds

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

Returns:
The front visual component's bounds in global coordinates (or null if no front visual component).

getBackVisualComponentBounds

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

Returns:
The back visual component's bounds in local coordinates (or null if no back visual component).

getBackVisualComponentGlobalBounds

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

Returns:
The back visual component's bounds in global coordinates (or null if no back visual component).

getShallowBounds

public ZBounds getShallowBounds()
Return the bounds of this ZGroup without taking the groups children into consideration. For the class ZGroup this will always return an empty bounds. But for sublclasses such as ZVisualGroup it may return a non-empty bounds.

Overrides:
getShallowBounds in class ZGroup

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