javax.media.j3d

## 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 at `childIndexOrder[0]` is rendered first, followed by `childIndexOrder[1]`, and so on, with the child at `childIndexOrder[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 and Description
    --- | ---
    `static int` | `ALLOW_CHILD_INDEX_ORDER_READ` Specifies that this OrderedGroup node allows reading its child index order information.
    `static int` | `ALLOW_CHILD_INDEX_ORDER_WRITE` Specifies 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 and Description
    `OrderedGroup()` Constructs and initializes a new OrderedGroup node object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChild(Node child)` Appends the specified child node to this group node's list of children.
    `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.
    `Node` | `cloneNode(boolean forceDuplicate)` Used to create a new instance of the node.
    `int[]` | `getChildIndexOrder()` Retrieves the current childIndexOrder array.
    `void` | `insertChild(Node child, int index)` Inserts the specified child node in this group node's list of children at the specified index.
    `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.
    `void` | `removeAllChildren()` Removes all children from this Group node.
    `void` | `removeChild(int index)` Removes the child node at the specified index from this group node's list of children.
    `void` | `removeChild(Node child)` Removes the specified child node from this group node's list of children.
    `void` | `setChildIndexOrder(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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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

  - ### Constructor Detail

    - #### OrderedGroup

          public OrderedGroup()

      Constructs and initializes a new OrderedGroup node object. The childIndexOrder array is initialized to null, meaning that its children are rendered in increasing index order.

  - ### 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 and `numChildren-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 and `numChildren-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 children
        `childIndexOrder` - 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 graph
        `RestrictedAccessException` - if this group node is part of live or compiled scene graph and the child node being added is not a BranchGroup node
        `MultipleParentException` - if `child` has 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:
        `addChild` in class `Group`
      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 graph
        `RestrictedAccessException` - if this group node is part of live or compiled scene graph and the child node being added is not a BranchGroup node
        `MultipleParentException` - if `child` has 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:
        `insertChild` in class `Group`
      Parameters:
        `child` - the new child
        `index` - at which location to insert. The `index` must be a value greater than or equal to 0 and less than or equal to `numChildren()`.
      Throws:
        `CapabilityNotSetException` - if the appropriate capability is not set and this group node is part of live or compiled scene graph
        `RestrictedAccessException` - if this group node is part of live or compiled scene graph and the child node being inserted is not a BranchGroup node
        `MultipleParentException` - if `child` has already been added as a child of another group node.
        `java.lang.IndexOutOfBoundsException` - if `index` is 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:
        `removeChild` in class `Group`
      Parameters:
        `index` - which child to remove. The `index` must be a value greater than or equal to 0 and less than `numChildren()`.
      Throws:
        `CapabilityNotSetException` - if the appropriate capability is not set and this group node is part of live or compiled scene graph
        `RestrictedAccessException` - if this group node is part of live or compiled scene graph and the child node being removed is not a BranchGroup node
        `java.lang.IndexOutOfBoundsException` - if `index` is 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:
        `moveTo` in class `Group`
      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:
        `removeChild` in class `Group`
      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 graph
        `RestrictedAccessException` - 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:
        `removeAllChildren` in class `Group`
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
        `RestrictedAccessException` - 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 by `cloneTree` to duplicate the current node.
      Overrides:
        `cloneNode` in class `Group`
      Parameters:
        `forceDuplicate` - when set to `true`, causes the `duplicateOnCloneTree` flag to be ignored. When `false`, the value of each node's `duplicateOnCloneTree` variable 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)`

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.