Class OrderedGroup
- java.lang.Object
-
- javax.media.j3d.SceneGraphObject
-
- javax.media.j3d.Node
-
- javax.media.j3d.Group
-
- javax.media.j3d.OrderedGroup
-
- Direct Known Subclasses:
DecalGroup
public class OrderedGroup extends Group
The OrderedGroup node is a Group that ensures its children render in a specified order. In addition to the list of children inherited from the base Group class, OrderedGroup defines an integer array of child indices that specify the order in which its children are rendered. This provides a level of indirection in determining the rendering order of its children. By default, the child index order array is null, and the children are rendered in increasing index order.When the child index order array is non-null, it must be the same length as the number of children. Every entry in the array must have a unique value between 0 and
numChildren-1(i.e., there must be no duplicate values and no missing indices). The order that the child indices appear in the child index order array determines the order in which the children are rendered. The child atchildIndexOrder[0]is rendered first, followed bychildIndexOrder[1], and so on, with the child atchildIndexOrder[numChildren-1]rendered last.The child index order array only affects rendering. List operations that refer to a child by index, such as getChild(index), will not be altered by the entries in this array. They will get, enumerate, add, remove, etc., the children based on the actual index in the group node. However, some of the list operations, such as addChild, removeChild, etc., will update the child index order array as a result of their operation. For example, removeChild will remove the entry in the child index order array corresponding to the removed child's index and adjust the remaining entries accordingly. See the documentation for these methods for more details.
-
-
Field Summary
Fields Modifier and Type Field Description static intALLOW_CHILD_INDEX_ORDER_READSpecifies that this OrderedGroup node allows reading its child index order information.static intALLOW_CHILD_INDEX_ORDER_WRITESpecifies that this OrderedGroup node allows writing its child index order information.-
Fields inherited from class javax.media.j3d.Group
ALLOW_CHILDREN_EXTEND, ALLOW_CHILDREN_READ, ALLOW_CHILDREN_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITE
-
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
-
-
Constructor Summary
Constructors Constructor Description OrderedGroup()Constructs and initializes a new OrderedGroup node object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(Node child)Appends the specified child node to this group node's list of children.voidaddChild(Node child, int[] childIndexOrder)Appends the specified child node to this group node's list of children, and sets the child index order array to the specified array.NodecloneNode(boolean forceDuplicate)Used to create a new instance of the node.int[]getChildIndexOrder()Retrieves the current childIndexOrder array.voidinsertChild(Node child, int index)Inserts the specified child node in this group node's list of children at the specified index.voidmoveTo(BranchGroup branchGroup)Moves the specified branch group node from its existing location to the end of this group node's list of children.voidremoveAllChildren()Removes all children from this Group node.voidremoveChild(int index)Removes the child node at the specified index from this group node's list of children.voidremoveChild(Node child)Removes the specified child node from this group node's list of children.voidsetChildIndexOrder(int[] childIndexOrder)Sets the childIndexOrder array.-
Methods inherited from class javax.media.j3d.Group
getAllChildren, getAlternateCollisionTarget, getChild, getCollisionBounds, indexOfChild, numChildren, setAlternateCollisionTarget, setChild, setCollisionBounds
-
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
-
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
-
-
-
Field Detail
-
ALLOW_CHILD_INDEX_ORDER_READ
public static final int ALLOW_CHILD_INDEX_ORDER_READ
Specifies that this OrderedGroup node allows reading its child index order information.- Since:
- Java 3D 1.3
- See Also:
- Constant Field Values
-
ALLOW_CHILD_INDEX_ORDER_WRITE
public static final int ALLOW_CHILD_INDEX_ORDER_WRITE
Specifies that this OrderedGroup node allows writing its child index order information.- Since:
- Java 3D 1.3
- See Also:
- Constant Field Values
-
-
Method Detail
-
setChildIndexOrder
public void setChildIndexOrder(int[] childIndexOrder)
Sets the childIndexOrder array. If the specified array is null, this node's childIndexOrder array is set to null. Its children will then be rendered in increasing index order. If the specified array is not null, the entire array is copied to this node's childIndexOrder array. In this case, the length of the array must be equal to the number of children in this group, and every entry in the array must have a unique value between 0 andnumChildren-1(i.e., there must be no duplicate values and no missing indices).- Parameters:
childIndexOrder- the array that is copied into this node's child index order array; this can be null- Throws:
java.lang.IllegalArgumentException- if the specified array is non-null and any of the following are true:childIndexOrder.length != numChildren;childIndexOrder[i] < 0, for i in[0, numChildren-1];childIndexOrder[i] >= numChildren, for i in[0, numChildren-1];childIndexOrder[i] == childIndexOrder[j], for i,j in[0, numChildren-1], i!=j;
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
getChildIndexOrder
public int[] getChildIndexOrder()
Retrieves the current childIndexOrder array.- Returns:
- a copy of this node's childIndexOrder array; this can be null.
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
addChild
public void addChild(Node child, int[] childIndexOrder)
Appends the specified child node to this group node's list of children, and sets the child index order array to the specified array. If the specified array is null, this node's childIndexOrder array is set to null. Its children will then be rendered in increasing index order. If the specified array is not null, the entire array is copied to this node's childIndexOrder array. In this case, the length of the array must be equal to the number of children in this group after the new child has been added, and every entry in the array must have a unique value between 0 andnumChildren-1(i.e., there must be no duplicate values and no missing indices).- Parameters:
child- the child to add to this node's list of childrenchildIndexOrder- the array that is copied into this node's child index order array; this can be null- Throws:
CapabilityNotSetException- if the appropriate capability is not set and this group node is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and the child node being added is not a BranchGroup nodeMultipleParentException- ifchildhas already been added as a child of another group node.java.lang.IllegalArgumentException- if the specified array is non-null and any of the following are true:childIndexOrder.length != numChildren;childIndexOrder[i] < 0, for i in[0, numChildren-1];childIndexOrder[i] >= numChildren, for i in[0, numChildren-1];childIndexOrder[i] == childIndexOrder[j], for i,j in[0, numChildren-1], i!=j;
- Since:
- Java 3D 1.3
-
addChild
public void addChild(Node child)
Appends the specified child node to this group node's list of children.If the current child index order array is non-null, the array is increased in size by one element, and a new element containing the index of the new child is added to the end of the array. Thus, this new child will be rendered last.
- Overrides:
addChildin classGroup- Parameters:
child- the child to add to this node's list of children- Throws:
CapabilityNotSetException- if the appropriate capability is not set and this group node is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and the child node being added is not a BranchGroup nodeMultipleParentException- ifchildhas already been added as a child of another group node.- Since:
- Java 3D 1.3
-
insertChild
public void insertChild(Node child, int index)
Inserts the specified child node in this group node's list of children at the specified index. This method is only supported when the child index order array is null.- Overrides:
insertChildin classGroup- Parameters:
child- the new childindex- at which location to insert. Theindexmust be a value greater than or equal to 0 and less than or equal tonumChildren().- Throws:
CapabilityNotSetException- if the appropriate capability is not set and this group node is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and the child node being inserted is not a BranchGroup nodeMultipleParentException- ifchildhas already been added as a child of another group node.java.lang.IndexOutOfBoundsException- ifindexis invalid.java.lang.IllegalStateException- if the childIndexOrder array is not null.- Since:
- Java 3D 1.3
-
removeChild
public void removeChild(int index)
Removes the child node at the specified index from this group node's list of children.If the current child index order array is non-null, the element containing the removed child's index will be removed from the child index order array, and the array will be reduced in size by one element. If the child removed was not the last child in the Group, the values of the child index order array will be updated to reflect the indices that were renumbered. More formally, each child whose index in the Group node was greater than the removed element (before removal) will have its index decremented by one.
- Overrides:
removeChildin classGroup- Parameters:
index- which child to remove. Theindexmust be a value greater than or equal to 0 and less thannumChildren().- Throws:
CapabilityNotSetException- if the appropriate capability is not set and this group node is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and the child node being removed is not a BranchGroup nodejava.lang.IndexOutOfBoundsException- ifindexis invalid.- Since:
- Java 3D 1.3
-
moveTo
public void moveTo(BranchGroup branchGroup)
Moves the specified branch group node from its existing location to the end of this group node's list of children.If the current child index order array is non-null, the array is increased in size by one element, and a new element containing the index of the new child is added to the end of the array. Thus, this new child will be rendered last.
- Overrides:
moveToin classGroup- Parameters:
branchGroup- the branch group node to move to this node's list of children- Throws:
CapabilityNotSetException- if the appropriate capability is not set and this group node is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
removeChild
public void removeChild(Node child)
Removes the specified child node from this group node's list of children. If the specified object is not in the list, the list is not modified.If the current child index order array is non-null, the element containing the removed child's index will be removed from the child index order array, and the array will be reduced in size by one element. If the child removed was not the last child in the Group, the values of the child index order array will be updated to reflect the indices that were renumbered. More formally, each child whose index in the Group node was greater than the removed element (before removal) will have its index decremented by one.
- Overrides:
removeChildin classGroup- Parameters:
child- the child node to be removed.- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and the child node being removed is not a BranchGroup node- Since:
- Java 3D 1.3
-
removeAllChildren
public void removeAllChildren()
Removes all children from this Group node.If the current child index order array is non-null, then it is set to a zero-length array (the empty set). Note that a zero-length child index order array is not the same as a null array in that as new elements are added, the child index order array will grow and will be used instead of the Group's natural child order.
- Overrides:
removeAllChildrenin classGroup- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graphRestrictedAccessException- if this group node is part of live or compiled scene graph and any of the children being removed are not BranchGroup nodes- Since:
- Java 3D 1.3
-
cloneNode
public Node cloneNode(boolean forceDuplicate)
Used to create a new instance of the node. This routine is called bycloneTreeto duplicate the current node.- Overrides:
cloneNodein classGroup- Parameters:
forceDuplicate- when set totrue, causes theduplicateOnCloneTreeflag to be ignored. Whenfalse, the value of each node'sduplicateOnCloneTreevariable determines whether NodeComponent data is duplicated or copied.- See Also:
Node.cloneTree(),Node.cloneNode(boolean),Node.duplicateNode(javax.media.j3d.Node, boolean),NodeComponent.setDuplicateOnCloneTree(boolean)
-
-