Jazz API Documentation

edu.umd.cs.jazz.util
Class ZSceneGraphEditor

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZSceneGraphEditor
All Implemented Interfaces:
java.io.Serializable

public class ZSceneGraphEditor
extends java.lang.Object
implements java.io.Serializable

ZSceneGraphEditor provides a convenience mechanism used to locate and create instances of the following types of group nodes:

ZSceneGraphEditor uses lazy evaluation to automatically create these group nodes in a scene graph as they are needed.

For example, you can use a graph editor to obtain a ZTransformGroup for a leaf node. The first time you do this, a new ZTransformGroup is inserted above the leaf. Subsequently, that ZTransformGroup is reused. e.g.

    ZTransformGroup t = node.editor().getTransformGroup();
    t.translate(1, 0);
 
will translate node by 1, 0. Repeatedly executing this code will cause the node to move horizontally across the screen.

If multiple group types are created for a given node in the scene graph, they are ordered as shown in the list above - so custom groups will be inserted at the top (closest to the root), whereas spatialIndex groups will be inserted at the bottom (closest to the node being edited.)

Group nodes inserted into the scene graph by ZSceneGraphEditor have their hasOneChild flag set to true - such group nodes are referred to as "edit groups", and can only act on the single node immediately beneath them in the scene graph. This guarantees that translations or scalings applied to a ZTransformGroup node created by ZSceneGraphEditor effect only the node being edited. ZSceneGraphEditor uses the hasOneChild flag to identify edit groups that it has created in the scene graph, to avoid creating the same group nodes twice.

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.

See Also:
ZNode.editor(), Serialized Form

Field Summary
protected static int ANCHOR
          A bit representing an anchor node type (ZAnchorGroup) and order.
protected static int CUSTOM
          A bit representing an application-defined custom node type and order.
protected  java.util.ArrayList editGroups
           
protected  ZNode editNode
           
protected static int FADE
          A bit representing a fade node type (ZFadeGroup) and order.
protected  int groupTypes
           
protected static int INDEX
          A bit representing an index node type (ZSpatialIndexGroup) and order.
protected static int INVISIBLE
          A bit representing an invisible node type (ZInvisibleGroup) and order.
protected static int LAYOUT
          A bit representing a layout node type (ZLayoutGroup) and order.
protected static int NAME
          A bit representing an name node type (ZNameGroup) and order.
protected static int SELECTION
          A bit representing a selection node type (ZSelectionGroup) and order.
protected static int STICKY
          A bit representing a sticky node type (ZStickyGroup) and order.
protected static int TRANSFORM
          A bit representing a transform node type (ZTransformGroup) and order.
protected static int UNKNOWN
          A value representing an unknown node type.
 
Constructor Summary
ZSceneGraphEditor(ZNode node)
          Given a node, constructs an "editor" for the node.
 
Method Summary
protected static int editGroupType(ZNode node)
          Returns the type number for a given instance.
 ZAnchorGroup getAnchorGroup()
          Returns a ZAnchorGroup to use for a node, or inserts one above the node if none exists.
protected  ZGroup getEditGroup(int type)
          Returns the specified edit group type for this editor, if there is one, or null otherwise.
 ZFadeGroup getFadeGroup()
          Returns a ZFadeGroup to use for a node, or inserts one above the node if none exists.
 java.util.ArrayList getGroups()
          Returns an array representing the list of "edit" groups above the node - groups above the node whose hasOneChild flag is set to true.
 ZInvisibleGroup getInvisibleGroup()
          Returns a ZInvisibleGroup to use for a node, or inserts one above the node if none exists.
 ZLayoutGroup getLayoutGroup()
          Returns a ZLayoutGroup to use for a node, or inserts one above the node if none exists.
 ZNameGroup getNameGroup()
          Returns a ZNameGroup to use for a node, or inserts one above the node if none exists.
 ZNode getNode()
          Returns the node being edited.
 ZSelectionGroup getSelectionGroup()
          Returns a ZSelectionGroup to use for a node, or inserts one above the node if none exists.
 ZSpatialIndexGroup getSpatialIndexGroup()
          Returns a ZSpatialIndexGroup to use for a node, or inserts one above the node if none exists.
 ZStickyGroup getStickyGroup()
          Returns a ZStickyGroup to use for a node, or inserts one above the node if none exists.
 ZNode getTop()
          If ZSceneGraphEditor has inserted groups above a node, this returns the topmost of those groups (the group nearest the root of the scene graph).
 ZTransformGroup getTransformGroup()
          Returns a ZTransformGroup to use for a node, inserting one above the edited node if none exists.
 boolean hasAnchorGroup()
          Returns true if this node has a ZAnchorGroup above it as an edit group, false otherwise.
protected  boolean hasEditGroup(int type)
          Determines if this editor has an edit group of the specified type.
 boolean hasFadeGroup()
          Returns true if this node has a ZFadeGroup above it as an edit group, false otherwise.
 boolean hasInvisibleGroup()
          Returns true if this node has a ZInvisibleGroup above it as an edit group, false otherwise.
 boolean hasLayoutGroup()
          Returns true if this node has a ZLayoutGroup above it as an edit group, false otherwise.
 boolean hasNameGroup()
          Returns true if this node has a ZNameGroup above it as an edit group, false otherwise.
 boolean hasSelectionGroup()
          Returns true if this node has a ZSelectionGroup above it as an edit group, false otherwise.
 boolean hasSpatialIndexGroup()
          Returns true if this node has a ZSpatialIndexGroup above it as an edit group, false otherwise.
 boolean hasStickyGroup()
          Returns true if this node has a ZStickyGroup above it as an edit group, false otherwise.
 boolean hasTransformGroup()
          Returns true if this node has a ZTransformGroup above it as an edit group, false otherwise.
protected static boolean isEditGroup(ZNode node)
          Determines if node is an edit group node.
 boolean removeAnchorGroup()
          Removes a ZAnchorGroup edit group for above a node.
protected  boolean removeEditGroup(int type)
          Removes the specified edit group from this editor if there is one, or does nothing otherwise.
 boolean removeFadeGroup()
          Removes a ZFadeGroup edit group for above a node.
 boolean removeInvisibleGroup()
          Removes a ZInvisibleGroup edit group for above a node.
 boolean removeLayoutGroup()
          Removes a ZLayoutGroup edit group for above a node.
 boolean removeNameGroup()
          Removes a ZNameGroup edit group for above a node.
 boolean removeSelectionGroup()
          Removes a ZSelectionGroup edit group for above a node.
 boolean removeSpatialIndexGroup()
          Removes a ZSpatialIndexGroup edit group for above a node.
 boolean removeStickyGroup()
          Removes a ZStickyGroup edit group for above a node.
 boolean removeTransformGroup()
          Removes a TransformGroup edit group from above a node.
protected  void setEditGroup(int type, ZGroup editGroup)
          Adds a ZGroup as an "editGroup", preserving the order listed by the numbering for the various editGroup types.
 java.lang.String toString()
          Generate a string that represents this object for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CUSTOM

protected static final int CUSTOM
A bit representing an application-defined custom node type and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

NAME

protected static final int NAME
A bit representing an name node type (ZNameGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

INVISIBLE

protected static final int INVISIBLE
A bit representing an invisible node type (ZInvisibleGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

LAYOUT

protected static final int LAYOUT
A bit representing a layout node type (ZLayoutGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

ANCHOR

protected static final int ANCHOR
A bit representing an anchor node type (ZAnchorGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

TRANSFORM

protected static final int TRANSFORM
A bit representing a transform node type (ZTransformGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

STICKY

protected static final int STICKY
A bit representing a sticky node type (ZStickyGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

SELECTION

protected static final int SELECTION
A bit representing a selection node type (ZSelectionGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

FADE

protected static final int FADE
A bit representing a fade node type (ZFadeGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

INDEX

protected static final int INDEX
A bit representing an index node type (ZSpatialIndexGroup) and order. Bigger numbers appear higher in the editor chain. This is the value returned by #editGroupType.

UNKNOWN

protected static final int UNKNOWN
A value representing an unknown node type. This is the value returned by #editGroupType.

editGroups

protected java.util.ArrayList editGroups

editNode

protected ZNode editNode

groupTypes

protected int groupTypes
Constructor Detail

ZSceneGraphEditor

public ZSceneGraphEditor(ZNode node)
Given a node, constructs an "editor" for the node. Editors are used to locate and create parent groups above the node.
Method Detail

editGroupType

protected static int editGroupType(ZNode node)
Returns the type number for a given instance.
Parameters:
node - The node being checked
Returns:
The node type

isEditGroup

protected static boolean isEditGroup(ZNode node)
Determines if node is an edit group node.
Returns:
true if node is an edit group node, false otherwise.

setEditGroup

protected void setEditGroup(int type,
                            ZGroup editGroup)
Adds a ZGroup as an "editGroup", preserving the order listed by the numbering for the various editGroup types. If group already in list, then do nothing.
Parameters:
type - The type of the new group
editGroup - The new group

hasEditGroup

protected boolean hasEditGroup(int type)
Determines if this editor has an edit group of the specified type.
Returns:
True if this editor has the specified edit group.

getEditGroup

protected ZGroup getEditGroup(int type)
Returns the specified edit group type for this editor, if there is one, or null otherwise.
Parameters:
type - The type of edit group to return
Returns:
The edit group

removeEditGroup

protected boolean removeEditGroup(int type)
Removes the specified edit group from this editor if there is one, or does nothing otherwise.
Parameters:
type - The type of edit group to return
Returns:
True if the edit group existed and was removed

getTop

public ZNode getTop()
If ZSceneGraphEditor has inserted groups above a node, this returns the topmost of those groups (the group nearest the root of the scene graph). If no edit groups have been inserted above a node, this returns the node itself. This method is useful if you want to remove a node and also its associated edit groups from a scene graph.

getNode

public ZNode getNode()
Returns the node being edited. This is the node that is the bottom-most node of an edit group. It is defined as being this node, or the first descendant that does not have 'hasOneChild' set.

getGroups

public java.util.ArrayList getGroups()
Returns an array representing the list of "edit" groups above the node - groups above the node whose hasOneChild flag is set to true. The groups are listed in bottom-top order.

getTransformGroup

public ZTransformGroup getTransformGroup()
Returns a ZTransformGroup to use for a node, inserting one above the edited node if none exists.

hasTransformGroup

public boolean hasTransformGroup()
Returns true if this node has a ZTransformGroup above it as an edit group, false otherwise.

removeTransformGroup

public boolean removeTransformGroup()
Removes a TransformGroup edit group from above a node. Returns true if the ZTransformGroup could be removed, false otherwise.

getFadeGroup

public ZFadeGroup getFadeGroup()
Returns a ZFadeGroup to use for a node, or inserts one above the node if none exists.

hasFadeGroup

public boolean hasFadeGroup()
Returns true if this node has a ZFadeGroup above it as an edit group, false otherwise.

removeFadeGroup

public boolean removeFadeGroup()
Removes a ZFadeGroup edit group for above a node. Returns true if the ZFadeGroup could be removed, false otherwise.

getStickyGroup

public ZStickyGroup getStickyGroup()
Returns a ZStickyGroup to use for a node, or inserts one above the node if none exists.

hasStickyGroup

public boolean hasStickyGroup()
Returns true if this node has a ZStickyGroup above it as an edit group, false otherwise.

removeStickyGroup

public boolean removeStickyGroup()
Removes a ZStickyGroup edit group for above a node. Returns true if the ZStickyGroup could be removed, false otherwise.

getSelectionGroup

public ZSelectionGroup getSelectionGroup()
Returns a ZSelectionGroup to use for a node, or inserts one above the node if none exists.

hasSelectionGroup

public boolean hasSelectionGroup()
Returns true if this node has a ZSelectionGroup above it as an edit group, false otherwise.

removeSelectionGroup

public boolean removeSelectionGroup()
Removes a ZSelectionGroup edit group for above a node. Returns true if the ZSelectionGroup could be removed, false otherwise.

getAnchorGroup

public ZAnchorGroup getAnchorGroup()
Returns a ZAnchorGroup to use for a node, or inserts one above the node if none exists.

hasAnchorGroup

public boolean hasAnchorGroup()
Returns true if this node has a ZAnchorGroup above it as an edit group, false otherwise.

removeAnchorGroup

public boolean removeAnchorGroup()
Removes a ZAnchorGroup edit group for above a node. Returns true if the ZAnchorGroup could be removed, false otherwise.

getLayoutGroup

public ZLayoutGroup getLayoutGroup()
Returns a ZLayoutGroup to use for a node, or inserts one above the node if none exists.

hasLayoutGroup

public boolean hasLayoutGroup()
Returns true if this node has a ZLayoutGroup above it as an edit group, false otherwise.

removeLayoutGroup

public boolean removeLayoutGroup()
Removes a ZLayoutGroup edit group for above a node. Returns true if the ZLayoutGroup could be removed, false otherwise.

getNameGroup

public ZNameGroup getNameGroup()
Returns a ZNameGroup to use for a node, or inserts one above the node if none exists.

hasNameGroup

public boolean hasNameGroup()
Returns true if this node has a ZNameGroup above it as an edit group, false otherwise.

removeNameGroup

public boolean removeNameGroup()
Removes a ZNameGroup edit group for above a node. Returns true if the ZNameGroup could be removed, false otherwise.

getInvisibleGroup

public ZInvisibleGroup getInvisibleGroup()
Returns a ZInvisibleGroup to use for a node, or inserts one above the node if none exists.

hasInvisibleGroup

public boolean hasInvisibleGroup()
Returns true if this node has a ZInvisibleGroup above it as an edit group, false otherwise.

removeInvisibleGroup

public boolean removeInvisibleGroup()
Removes a ZInvisibleGroup edit group for above a node. Returns true if the ZInvisibleGroup could be removed, false otherwise.

getSpatialIndexGroup

public ZSpatialIndexGroup getSpatialIndexGroup()
Returns a ZSpatialIndexGroup to use for a node, or inserts one above the node if none exists.

hasSpatialIndexGroup

public boolean hasSpatialIndexGroup()
Returns true if this node has a ZSpatialIndexGroup above it as an edit group, false otherwise.

removeSpatialIndexGroup

public boolean removeSpatialIndexGroup()
Removes a ZSpatialIndexGroup edit group for above a node. Returns true if the ZSpatialIndexGroup could be removed, false otherwise. Removes all nodeListers registered on the indexed nodes.

toString

public java.lang.String toString()
Generate a string that represents this object for debugging.
Overrides:
toString in class java.lang.Object
Returns:
the string that represents this object for debugging

Jazz API Documentation