Aviatrix3D
2.0

org.j3d.aviatrix3d
Class SwitchGroup

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
          extended by org.j3d.aviatrix3d.Group
              extended by org.j3d.aviatrix3d.SwitchGroup
All Implemented Interfaces:
GroupPickTarget, PickableObject, PickTarget, Cullable, GroupCullable, TransformHierarchy

public class SwitchGroup
extends Group

Special grouping node that allows the selection of only a single child to be rendered.

If the node that is the selected index is removed, then the selectedChild is automatically to be invalid. The user must reset the selected child index in order for rendering to continue.

Version:
$Revision: 1.19 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Group
childList, cullList, dirtyBoundsCount, lastChild, pickableList, pickFlags, wkVec1, wkVec2
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_NOT_LIVE_MESSAGE, updateHandler, WRITE_TIMING_MSG
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickableObject
COLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECT
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickTarget
CUSTOM_PICK_TYPE, GROUP_PICK_TYPE, LEAF_PICK_TYPE, SINGLE_PICK_TYPE
 
Constructor Summary
SwitchGroup()
          The default constructor
 
Method Summary
 int getActiveChild()
          Get the currently selected active child of this switch node.
 Cullable[] getCullableChildren()
          Get the list of children that are valid to be rendered according to the rules of the grouping node.
 PickTarget getPickableChild(int idx)
          Return the pickable target instance at the given index.
 PickTarget[] getPickableChildren()
          Return an array containing all of this group's pickable children.
 int numCullableChildren()
          Returns the number of valid renderable children to process.
 int numPickableChildren()
          Returns the number of valid pickable child targets to process.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void removeAllChildren()
          Removes all children from the group.
 void removeChild(int idx)
          Remove the child at the specified index from the group.
 void setActiveChild(int idx)
          Set the selected child to be rendered to the given index.
 void setChild(Node newChild, int idx)
          Replaces the child node at the specified index in this group node's list of children with the specified child.
 
Methods inherited from class org.j3d.aviatrix3d.Group
addChild, checkForCyclicChild, checkPickMask, getAllChildren, getChild, getCullableParent, getPickableBounds, getPickMask, getPickTargetType, hasMultipleParents, indexOfChild, markBoundsDirty, numChildren, pickBatch, pickSingle, removeChild, requestBoundsUpdate, setBounds, setLive, setPickMask, setUpdateHandler, updateBounds
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, removeParent, setParent, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
dataChanged, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.GroupCullable
getBounds
 

Constructor Detail

SwitchGroup

public SwitchGroup()
The default constructor

Method Detail

setChild

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

Overrides:
setChild in class Group
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
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

removeChild

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

Overrides:
removeChild in class 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 callback method

removeAllChildren

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

Overrides:
removeAllChildren in class Group
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getCullableChildren

public Cullable[] getCullableChildren()
Get the list of children that are valid to be rendered according to the rules of the grouping node.

Specified by:
getCullableChildren in interface GroupCullable
Overrides:
getCullableChildren in class Group
Returns:
an array of nodes

numCullableChildren

public int numCullableChildren()
Returns the number of valid renderable children to process. If there are no valid renderable children return -1.

Specified by:
numCullableChildren in interface GroupCullable
Overrides:
numCullableChildren in class Group
Returns:
A number greater than or equal to zero or -1

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class Group

numPickableChildren

public int numPickableChildren()
Returns the number of valid pickable child targets to process. If there are no valid children return -1.

Specified by:
numPickableChildren in interface GroupPickTarget
Overrides:
numPickableChildren in class Group
Returns:
A number greater than or equal to zero or -1

getPickableChildren

public PickTarget[] getPickableChildren()
Return an array containing all of this group's pickable children. This structure is the nodes internal representation. Check the numPickableChildren() call for how many valid objects are part of this array. If there are none, this may return either a null or a valid array, depending on the implementation.

The list may contain null values.

Specified by:
getPickableChildren in interface GroupPickTarget
Overrides:
getPickableChildren in class Group
Returns:
An array of pick targets

getPickableChild

public PickTarget getPickableChild(int idx)
Return the pickable target instance at the given index. If there is nothing at the given index, null will be returned.

Specified by:
getPickableChild in interface GroupPickTarget
Overrides:
getPickableChild in class Group
Parameters:
idx - The index of the child to get
Returns:
The target object at the given index.

setActiveChild

public void setActiveChild(int idx)
                    throws InvalidWriteTimingException
Set the selected child to be rendered to the given index. If the index is invalid, then an exception is issued. Using a value of -1 means that no child will be rendered.

Parameters:
idx - The index of the child to now be rendered
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getActiveChild

public int getActiveChild()
Get the currently selected active child of this switch node. If none is active, -1 will be returned.

Returns:
The valid child index or -1

Aviatrix3D
2.0

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