org.xith3d.scenegraph.utils
Class TreeCloner

java.lang.Object
  extended by org.xith3d.scenegraph.utils.TreeCloner
All Implemented Interfaces:
DetailedTraversalCallback

public class TreeCloner
extends java.lang.Object
implements DetailedTraversalCallback

Clones a Subtree of the scenegraph.


Constructor Summary
TreeCloner()
           
 
Method Summary
protected  void add(Node node)
           
<GroupNodeExtension extends GroupNode>
GroupNodeExtension
cloneTree(GroupNodeExtension root)
           
 boolean traversalCheckGroup(BranchGroup bg)
          This method is called for each group in the traversal.
 boolean traversalCheckGroup(Group group)
          This method is called for each group in the traversal.
 boolean traversalCheckGroup(OrderedGroup og)
          This method is called for each group in the traversal.
 boolean traversalCheckGroup(Switch sw)
          This method is called for each group in the traversal.
 boolean traversalCheckGroup(TransformGroup tg)
          This method is called for each group in the traversal.
 boolean traversalCheckGroupCommon(GroupNode group)
          This method is (certainly) called for each group in the traversal.
 boolean traversalOperation(BranchGroup bg)
          This method is called for each BranchGroup in the traversed Group.
 boolean traversalOperation(Fog fog)
          This method is called for each Light node in the traversed Group.
 boolean traversalOperation(Group group)
          This method is called for each Group in the traversed Group.
 boolean traversalOperation(Light light)
          This method is called for each Light node in the traversed Group.
 boolean traversalOperation(Node node)
          This method is called for each Node in the traversed Group.
 boolean traversalOperation(OrderedGroup og)
          This method is called for each OrderedGroup in the traversed Group.
 boolean traversalOperation(Shape3D shape)
          This method is called for each Node in the traversed Group.
 boolean traversalOperation(Sound sound)
          This method is called for each Sound node in the traversed Group.
 boolean traversalOperation(Switch sw)
          This method is called for each Node in the traversed Group.
 boolean traversalOperation(TransformGroup tg)
          This method is called for each TransformGroup in the traversed Group.
 boolean traversalOperationAfter(BranchGroup bg)
          This method is called for each BranchGroup in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Fog fog)
          This method is called for each Light node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Group group)
          This method is called for each Group in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Light light)
          This method is called for each Light node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Node node)
          This method is called for each Node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(OrderedGroup og)
          This method is called for each OrderedGroup in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Shape3D shape)
          This method is called for each Node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Sound sound)
          This method is called for each Sound node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(Switch sw)
          This method is called for each Node in the traversed Group after the Node has been worked on.
 boolean traversalOperationAfter(TransformGroup tg)
          This method is called for each TransformGroup in the traversed Group after the Node has been worked on.
 boolean traversalOperationCommon(GroupNode node)
          This method is (certainly) called for each Node in the traversed Group, which is a group itself.
 boolean traversalOperationCommon(Node node)
          This method is (certainly) called for each Node in the traversed Group, which is not a group itself.
 boolean traversalOperationCommonAfter(GroupNode group)
          This method is (certainly) called for each Group in the traversed Node, which is a Group itself after the Node has been worked on.
 boolean traversalOperationCommonAfter(Node node)
          This method is (certainly) called for each Node in the traversed Node, which is not a Group itself after the Node has been worked on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeCloner

public TreeCloner()
Method Detail

add

protected final void add(Node node)

traversalOperationCommon

public boolean traversalOperationCommon(Node node)
This method is (certainly) called for each Node in the traversed Group, which is not a group itself. It implements the operation to be done for the Nodes.

Specified by:
traversalOperationCommon in interface DetailedTraversalCallback
Parameters:
node - the current Node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationCommon

public boolean traversalOperationCommon(GroupNode node)
This method is (certainly) called for each Node in the traversed Group, which is a group itself. It implements the operation to be done for the Nodes.

Specified by:
traversalOperationCommon in interface DetailedTraversalCallback
Parameters:
node - the current Node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalCheckGroupCommon

public boolean traversalCheckGroupCommon(GroupNode group)
This method is (certainly) called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroupCommon in interface DetailedTraversalCallback
Parameters:
group - the Group to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalCheckGroup

public boolean traversalCheckGroup(BranchGroup bg)
This method is called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroup in interface DetailedTraversalCallback
Parameters:
bg - the BranchGroup to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalCheckGroup

public boolean traversalCheckGroup(Group group)
This method is called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroup in interface DetailedTraversalCallback
Parameters:
group - the Group to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalCheckGroup

public boolean traversalCheckGroup(Switch sw)
This method is called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroup in interface DetailedTraversalCallback
Parameters:
sw - the Switch group to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalCheckGroup

public boolean traversalCheckGroup(TransformGroup tg)
This method is called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroup in interface DetailedTraversalCallback
Parameters:
tg - the TransformGroup to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalCheckGroup

public boolean traversalCheckGroup(OrderedGroup og)
This method is called for each group in the traversal. It must return true to be further traversed (and its children)

Specified by:
traversalCheckGroup in interface DetailedTraversalCallback
Parameters:
og - the OrderedGroup to be checked
Returns:
if false the traversal is not stopped, but the children are not further traversed

traversalOperation

public boolean traversalOperation(Node node)
This method is called for each Node in the traversed Group. It implements the operation to be done for the Nodes.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
node - the current Node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(BranchGroup bg)
This method is called for each BranchGroup in the traversed Group. It implements the operation to be done for the BranchGroups.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
bg - the current BranchGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Group group)
This method is called for each Group in the traversed Group. It implements the operation to be done for the Groups.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
group - the current Group in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(TransformGroup tg)
This method is called for each TransformGroup in the traversed Group. It implements the operation to be done for the TransformGroups.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
tg - the current TransformGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(OrderedGroup og)
This method is called for each OrderedGroup in the traversed Group. It implements the operation to be done for the OrderedGroups.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
og - the current OrderedGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Switch sw)
This method is called for each Node in the traversed Group. It implements the operation to be done for the Nodes.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
sw - the current Switch node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Shape3D shape)
This method is called for each Node in the traversed Group. It implements the operation to be done for the Nodes.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
shape - the current Shape3D in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Light light)
This method is called for each Light node in the traversed Group. It implements the operation to be done for the Lights.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
light - the current Light in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Fog fog)
This method is called for each Light node in the traversed Group. It implements the operation to be done for the Lights.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
fog - the current Fog in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperation

public boolean traversalOperation(Sound sound)
This method is called for each Sound node in the traversed Group. It implements the operation to be done for the Sound node.

Specified by:
traversalOperation in interface DetailedTraversalCallback
Parameters:
sound - the current Sound node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationCommonAfter

public boolean traversalOperationCommonAfter(Node node)
This method is (certainly) called for each Node in the traversed Node, which is not a Group itself after the Node has been worked on. It implements the operation to be done for the Groups.

Specified by:
traversalOperationCommonAfter in interface DetailedTraversalCallback
Parameters:
node - the current node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationCommonAfter

public boolean traversalOperationCommonAfter(GroupNode group)
This method is (certainly) called for each Group in the traversed Node, which is a Group itself after the Node has been worked on. It implements the operation to be done for the Groups.

Specified by:
traversalOperationCommonAfter in interface DetailedTraversalCallback
Parameters:
group - the current GroupNode in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(BranchGroup bg)
This method is called for each BranchGroup in the traversed Group after the Node has been worked on. It implements the operation to be done for the BranchGroups.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
bg - the current BranchGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Group group)
This method is called for each Group in the traversed Group after the Node has been worked on. It implements the operation to be done for the Groups.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
group - the current Group in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(TransformGroup tg)
This method is called for each TransformGroup in the traversed Group after the Node has been worked on. It implements the operation to be done for the TransformGroups.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
tg - the current TransformGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(OrderedGroup og)
This method is called for each OrderedGroup in the traversed Group after the Node has been worked on. It implements the operation to be done for the OrderedGroups.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
og - the current OrderedGroup in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Node node)
This method is called for each Node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Nodes.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
node - the current Node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Switch sw)
This method is called for each Node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Nodes.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
sw - the current Switch node in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Shape3D shape)
This method is called for each Node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Nodes.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
shape - the current Shape3D in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Light light)
This method is called for each Light node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Lights.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
light - the current Light in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Fog fog)
This method is called for each Light node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Lights.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
fog - the current Fog in the traversal
Returns:
if false, the traversal is stopped after this node

traversalOperationAfter

public boolean traversalOperationAfter(Sound sound)
This method is called for each Sound node in the traversed Group after the Node has been worked on. It implements the operation to be done for the Sound node.

Specified by:
traversalOperationAfter in interface DetailedTraversalCallback
Parameters:
sound - the current Sound node in the traversal
Returns:
if false, the traversal is stopped after this node

cloneTree

public <GroupNodeExtension extends GroupNode> GroupNodeExtension cloneTree(GroupNodeExtension root)