Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class ObjectSet

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.ObjectSet

public abstract class ObjectSet
extends SceneGraphObject

A general purpose container class to allow end users to extend the basic geometry capabilities, while still providing a way to manage scene graph state such as liveness calls and update handlers.

A lot of the state calls of children can only be called by extending the class and calling protected methods. When a child scenegraph object is defined for a collection of children outside of the base aviatrix3d package there is no way for passing in liveness state due to the protected nature of the required methods. This class provides methods that allow a derived class to call back into the package and set those states.

Implementation Note

Since this is a base set of nodes, no interface with the rendering pipeline has been implemented. It is up to the person extending this class to implement an appropriate interface that extends from Cullable so that the rendering infrastructure may process any or all children of this set.

Internationalisation Resource Names

Version:
$Revision: 2.5 $
Author:
Alan Hudson, Justin Couch

Field Summary
protected  SceneGraphObject[] childList
          The list of children nodes
protected  int lastChild
          Index to the next place to add items in the nodeList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Constructor Summary
protected ObjectSet()
          The default constructor
 
Method Summary
 void addChild(SceneGraphObject newChild)
          Appends the specified child node to this group node's list of children
protected  void checkForCyclicChild(SceneGraphObject parent)
          Check to see if this node is the same reference as the passed node that is a parent of this node.
 SceneGraphObject[] getAllChildren()
          Return an array containing all of this groups children.
 SceneGraphObject getChild(int idx)
          Retrieves the child node at the specified index in this group node's list of children.
 int indexOfChild(SceneGraphObject child)
          Retrieves the index of the specified child node in this group node's list of children.
 int numChildren()
          Returns the number of children this group contains.
 void removeAllChildren()
          Removes all children from the group.
 void removeChild(int idx)
          Remove the child at the specified index from the group.
 void removeChild(SceneGraphObject child)
          Removes the specified child from the group.
 void setChild(SceneGraphObject newChild, int idx)
          Replaces the child node at the specified index in this group node's list of children with the specified child.
protected  void setLive(boolean state)
          Notification that this object is live now.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

childList

protected SceneGraphObject[] childList
The list of children nodes


lastChild

protected int lastChild
Index to the next place to add items in the nodeList

Constructor Detail

ObjectSet

protected ObjectSet()
The default constructor

Method Detail

checkForCyclicChild

protected void checkForCyclicChild(SceneGraphObject parent)
                            throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node that is a parent of this node. This is the downwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. Since each class may have different lists of child node setups, this should be overriden by any class that can take children, and have the call passed along to the children.

Overrides:
checkForCyclicChild in class SceneGraphObject
Parameters:
parent - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

setLive

protected void setLive(boolean state)
Notification that this object is live now.

Overrides:
setLive in class SceneGraphObject
Parameters:
state - true if this should be marked as live now

addChild

public void addChild(SceneGraphObject newChild)
              throws AlreadyParentedException,
                     InvalidWriteTimingException
Appends the specified child node to this group node's list of children

Parameters:
newChild - The child to add
Throws:
AlreadyParentedException - There is a valid parent already set
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

setChild

public void setChild(SceneGraphObject newChild,
                     int idx)
              throws AlreadyParentedException,
                     InvalidWriteTimingException
Replaces the child node at the specified index in this group node's list of children with the specified child.

Parameters:
newChild - The child node to use
idx - The index to replace. Must be greater than 0 and less then numChildren
Throws:
java.lang.IndexOutOfBoundsException - When the idx is invalid
AlreadyParentedException - There is a valid parent already set
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

removeChild

public void removeChild(int idx)
                 throws InvalidWriteTimingException
Remove the child at the specified index from the group.

Parameters:
idx - The index of the child to remove
Throws:
IndexOfBoundsException - When the idx is invalid
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getChild

public SceneGraphObject getChild(int idx)
Retrieves the child node at the specified index in this group node's list of children.

Returns:
The node
Throws:
java.lang.IndexOutOfBoundsException - If the idx is invalid

getAllChildren

public SceneGraphObject[] getAllChildren()
Return an array containing all of this groups children. This structure is the nodes internal representation. Check the numChildren call to determine how many entries are valid.

Returns:
An array of nodes

numChildren

public int numChildren()
Returns the number of children this group contains.

Returns:
The number of children

indexOfChild

public int indexOfChild(SceneGraphObject child)
Retrieves the index of the specified child node in this group node's list of children.

Parameters:
child - The child to find
Returns:
the index of the child or -1 if not found

removeChild

public void removeChild(SceneGraphObject child)
                 throws InvalidWriteTimingException
Removes the specified child from the group. If the child does not exist its silently ignored.

Parameters:
child - The child to remove
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

removeAllChildren

public void removeAllChildren()
                       throws InvalidWriteTimingException
Removes all children from the group.

Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org