Class BaseGroupingNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseGroupingNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBoundedNodeType
,VRMLChildNodeType
,VRMLGroupingNodeType
,VRMLNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseAnchor
,BaseBillboard
,BaseCADAssembly
,BaseCADLayer
,BaseCADPart
,BaseCollision
,BaseEspduTransform
,BaseGeoLocation
,BaseGeoLOD
,BaseGeoTransform
,BaseGroup
,BaseHAnimJoint
,BaseHAnimSegment
,BaseHAnimSite
,BaseLOD
,BaseMatrixTransform
,BaseOrderedGroup
,BasePickableGroup
,BaseSwitch
,BaseTransform
public abstract class BaseGroupingNode
extends AbstractNode
implements VRMLGroupingNodeType, VRMLBoundedNodeType
Common basic implementation of any node that uses grouping functionality.
The basic (X3D) definition of X3DGroupingNode is:
X3DGroupingNode : X3DChildNode, X3DBoundedObject { MFNode [in] addChildren MFNode [in] removeChildren MFNode [in,out] children [] [X3DChildNode] SFNode [in,out] metadata NULL [X3DMetadataObject] SFVec3f [] bboxCenter 0 0 0 (-8,8) SFVec3f [] bboxSize -1 -1 -1 [0,8) or -1 -1 -1 SFBool [in,out] bboxDisplay FALSE SFBool [in,out] visible TRUE }
- Version:
- $Revision: 1.31 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The number of children nodes we added, not the total.protected static final int
Index of the addChildren fieldprotected static final int
Index of the Bounding box center bboxCenter fieldprotected static final int
Index of the Bounding box display bboxDisplay fieldprotected static final int
Index of the Bounding box size bboxSize fieldprotected static final int
Index of the children fieldprotected static final int
Index of the removeChildren fieldprotected static final int
Index of the Bounding box display visible fieldprotected boolean
Flag indicating if this node contains bindable/activatable nodesprotected static final int
The last field index used by this classprotected int
Counter for the number of sharing references this hasprotected static final String
Message when the USE is a bindableprotected float[]
SFVec3f bboxCenter NULLprotected boolean
SFBool bboxDisplay falseprotected float[]
SFVec3f bboxSize NULLprotected List
<VRMLNodeType> MFNode children NULLprotected boolean
SFBool visible trueFields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseGroupingNode
(String name) Construct a default instance of the grouping node type. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(VRMLNodeType newChild) Append a new child node to the existing collection.protected void
addChildNode
(VRMLNodeType node) Add a single child node to the list of available children.protected void
Clear the child node list of all children in the VRML node.boolean
A check to see if this grouping node contains any bindable nodes.protected void
copy
(VRMLGroupingNodeType node) Set the fields of the grouping node that has the fields set based on the fields of the passed in node.float[]
Get the current value of field the bboxCenter field.boolean
Get the current value of the bboxDisplay field.float[]
Get the current value of the bboxSize field.Get the children, provides a live reference not a copyint
Returns the number of childrengetFieldValue
(int index) Get the value of a field.int
Get the primary type of this node.boolean
Get the current value of the visible field.boolean
isShared()
Check to see if this node has been used more than once.protected void
removeChildNode
(VRMLNodeType node) Remove the given node from this grouping node.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setBboxCenter
(float[] val) Set the bounding box for this node.void
setBboxDisplay
(boolean val) Set the bounding box display for this node.void
setBboxSize
(float[] val) Set the bounding box for this node.void
setChildren
(VRMLNodeType newChild) Accessor method to set the children field Creates an array containing only newChild If passed null this method will act like removeChildrenvoid
setChildren
(VRMLNodeType[] newChildren) Accesor method to set the children field If passed null this method will act like removeChildrenvoid
setDEF()
Notify this node that is has been DEFd.void
setShared
(boolean used) Adjust the sharing count up or down one increment depending on the flag.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.void
setValue
(int index, VRMLNodeType child) Set the value of the field at the given index as an array of nodes.void
setValue
(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.void
setVisible
(boolean val) Set visible field for this node.void
updateRefCount
(int layer, boolean add) Change the reference count up or down by one for a given layer ID.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue
-
Field Details
-
FIELD_CHILDREN
protected static final int FIELD_CHILDRENIndex of the children field- See Also:
-
FIELD_ADDCHILDREN
protected static final int FIELD_ADDCHILDRENIndex of the addChildren field- See Also:
-
FIELD_REMOVECHILDREN
protected static final int FIELD_REMOVECHILDRENIndex of the removeChildren field- See Also:
-
FIELD_BBOX_CENTER
protected static final int FIELD_BBOX_CENTERIndex of the Bounding box center bboxCenter field- See Also:
-
FIELD_BBOX_SIZE
protected static final int FIELD_BBOX_SIZEIndex of the Bounding box size bboxSize field- See Also:
-
FIELD_BBOX_DISPLAY
protected static final int FIELD_BBOX_DISPLAYIndex of the Bounding box display bboxDisplay field- See Also:
-
FIELD_VISIBLE
protected static final int FIELD_VISIBLEIndex of the Bounding box display visible field- See Also:
-
LAST_GROUP_INDEX
protected static final int LAST_GROUP_INDEXThe last field index used by this class- See Also:
-
USE_BIND_MSG
-
vfChildren
MFNode children NULL -
vfBboxCenter
protected float[] vfBboxCenterSFVec3f bboxCenter NULL -
vfBboxSize
protected float[] vfBboxSizeSFVec3f bboxSize NULL -
vfBboxDisplay
protected boolean vfBboxDisplaySFBool bboxDisplay false -
vfVisible
protected boolean vfVisibleSFBool visible true -
childCount
protected int childCountThe number of children nodes we added, not the total. We don't Add nodes to NR that have no scene graph object (such as interpolators and timesensors). This count is so that we don't have to enable the ALLOW_CHILDREN_READ on the group (an optimisation step) -
hasBindables
protected boolean hasBindablesFlag indicating if this node contains bindable/activatable nodes
-
-
Constructor Details
-
BaseGroupingNode
Construct a default instance of the grouping node type.- Parameters:
name
- The name of the type of node
-
-
Method Details
-
copy
Set the fields of the grouping node that has the fields set based on the fields of the passed in node. This will not copy any children nodes, only the local fields.- Parameters:
node
- The grouping node to copy info from
-
getBboxCenter
public float[] getBboxCenter()Description copied from interface:VRMLBoundedNodeType
Get the current value of field the bboxCenter field. The default value is0 0 0
.- Specified by:
getBboxCenter
in interfaceVRMLBoundedNodeType
- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxSize field. The default value is-1 -1 -1
.- Specified by:
getBboxSize
in interfaceVRMLBoundedNodeType
- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxDisplay field. The default value isfalse
.- Specified by:
getBboxDisplay
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeType
Get the current value of the visible field. The default value istrue
.- Specified by:
getVisible
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the visible(SFBool)
-
getChildren
Get the children, provides a live reference not a copy- Specified by:
getChildren
in interfaceVRMLGroupingNodeType
- Returns:
- An array of VRMLNodeTypes
-
setChildren
Accesor method to set the children field If passed null this method will act like removeChildren- Specified by:
setChildren
in interfaceVRMLGroupingNodeType
- Parameters:
newChildren
- Array of new children
-
setChildren
Accessor method to set the children field Creates an array containing only newChild If passed null this method will act like removeChildren- Specified by:
setChildren
in interfaceVRMLGroupingNodeType
- Parameters:
newChild
- The new child
-
addChild
Append a new child node to the existing collection. Should be used sparingly. It is really only provided for Proto handling purposes.- Specified by:
addChild
in interfaceVRMLGroupingNodeType
- Parameters:
newChild
- The new child
-
getChildrenSize
public int getChildrenSize()Returns the number of children- Specified by:
getChildrenSize
in interfaceVRMLGroupingNodeType
- Returns:
- The number of children
-
containsBindableNodes
public boolean containsBindableNodes()A check to see if this grouping node contains any bindable nodes. This does a dynamic check of all the children now to see if any of them are bindable.- Specified by:
containsBindableNodes
in interfaceVRMLGroupingNodeType
- Returns:
- true if this or any of its children contain bindable nodes
-
updateRefCount
public void updateRefCount(int layer, boolean add) Change the reference count up or down by one for a given layer ID. If there is no reference to the given layer ID previously, add one now. A listing of the layer IDs that reference this node can be retrieved throughAbstractNode.getLayerIds()
.- Specified by:
updateRefCount
in interfaceVRMLNodeType
- Overrides:
updateRefCount
in classAbstractNode
- Parameters:
layer
- The id of the layer to modify the ref count onadd
- true to increment the reference count, false to decrement
-
setDEF
public void setDEF()Notify this node that is has been DEFd.- Specified by:
setDEF
in interfaceVRMLNodeType
- Overrides:
setDEF
in classAbstractNode
- Throws:
IllegalStateException
- The setup is finished.
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. This will call setupFinished() on the child nodes. Derived classes that do not like this behaviour should override this method or ensure that the implGroup has a parent before this method is called.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Description copied from interface:VRMLNodeType
Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFVec3f and SFRotation field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this fieldInvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, boolean value) Description copied from interface:VRMLNodeType
Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node
-
setValue
public void setValue(int index, VRMLNodeType child) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchild
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, VRMLNodeType[] children, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchildren
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setBboxCenter
public void setBboxCenter(float[] val) Set the bounding box for this node. Only used by the field parser at setup.- Specified by:
setBboxCenter
in interfaceVRMLBoundedNodeType
- Parameters:
val
- The box center to set
-
setBboxSize
Set the bounding box for this node. Only used by the field parser at setup.- Specified by:
setBboxSize
in interfaceVRMLBoundedNodeType
- Parameters:
val
- The box size to set- Throws:
InvalidFieldValueException
- The bounds is not valid
-
setBboxDisplay
public void setBboxDisplay(boolean val) Set the bounding box display for this node. Only used by the field parser- Specified by:
setBboxDisplay
in interfaceVRMLBoundedNodeType
- Parameters:
val
- the display value to set
-
setVisible
public void setVisible(boolean val) Set visible field for this node. Only used by the field parser- Specified by:
setVisible
in interfaceVRMLBoundedNodeType
- Parameters:
val
- the display value to set
-
clearChildren
protected void clearChildren()Clear the child node list of all children in the VRML node. Override to provide renderer-specific behaviour, but remember to also call this implementation too. -
addChildNode
Add a single child node to the list of available children. Override to provide renderer-specific behaviour, but remember to also call this implementation too.- Parameters:
node
- The node to add- Throws:
InvalidFieldValueException
- This is a bindable node shared
-
removeChildNode
Remove the given node from this grouping node. If the node is not a child of this node, the request is silently ignored.- Parameters:
node
- The node to remove
-