public class OrderedGroup extends Group
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.
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.
|
ALLOW_CHILDREN_EXTEND, ALLOW_CHILDREN_READ, ALLOW_CHILDREN_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITE
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 and Description |
---|
OrderedGroup()
Constructs and initializes a new OrderedGroup node object.
|
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.
|
getAllChildren, getAlternateCollisionTarget, getChild, getCollisionBounds, indexOfChild, numChildren, setAlternateCollisionTarget, setChild, setCollisionBounds
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
public static final int ALLOW_CHILD_INDEX_ORDER_READ
public static final int ALLOW_CHILD_INDEX_ORDER_WRITE
public OrderedGroup()
public void setChildIndexOrder(int[] childIndexOrder)
numChildren-1
(i.e., there must be
no duplicate values and no missing indices).childIndexOrder
- the array that is copied into this
node's child index order array; this can be nullIllegalArgumentException
- 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 graphpublic int[] getChildIndexOrder()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void addChild(Node child, int[] childIndexOrder)
numChildren-1
(i.e., there must be no duplicate values and no missing
indices).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 nullCapabilityNotSetException
- 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
- if child
has already
been added as a child of another group node.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;public void addChild(Node child)
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.
addChild
in class Group
child
- the child to add to this node's list of childrenCapabilityNotSetException
- 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
- if child
has already
been added as a child of another group node.public void insertChild(Node child, int index)
insertChild
in class Group
child
- the new childindex
- at which location to insert. The index
must be a value
greater than or equal to 0 and less than or equal to
numChildren()
.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
- if child
has already
been added as a child of another group node.IndexOutOfBoundsException
- if index
is invalid.IllegalStateException
- if the childIndexOrder array is
not null.public void removeChild(int index)
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.
removeChild
in class Group
index
- which child to remove. The index
must be a value
greater than or equal to 0 and less than numChildren()
.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 nodeIndexOutOfBoundsException
- if index
is invalid.public void moveTo(BranchGroup branchGroup)
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.
moveTo
in class Group
branchGroup
- the branch group node to move to this node's list
of childrenCapabilityNotSetException
- if the appropriate capability is
not set and this group node is part of live or compiled scene graphpublic void removeChild(Node child)
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.
removeChild
in class Group
child
- the child node to be removed.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 nodepublic void removeAllChildren()
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.
removeAllChildren
in class Group
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 nodespublic Node cloneNode(boolean forceDuplicate)
cloneTree
to duplicate the current node.cloneNode
in class Group
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.Node.cloneTree()
,
Node.cloneNode(boolean)
,
Node.duplicateNode(org.scijava.java3d.Node, boolean)
,
NodeComponent.setDuplicateOnCloneTree(boolean)
Copyright © 2016–2022 SciJava. All rights reserved.