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 intThe number of children nodes we added, not the total.protected static final intIndex of the addChildren fieldprotected static final intIndex of the Bounding box center bboxCenter fieldprotected static final intIndex of the Bounding box display bboxDisplay fieldprotected static final intIndex of the Bounding box size bboxSize fieldprotected static final intIndex of the children fieldprotected static final intIndex of the removeChildren fieldprotected static final intIndex of the Bounding box display visible fieldprotected booleanFlag indicating if this node contains bindable/activatable nodesprotected static final intThe last field index used by this classprotected intCounter for the number of sharing references this hasprotected static final StringMessage when the USE is a bindableprotected float[]SFVec3f bboxCenter NULLprotected booleanSFBool bboxDisplay falseprotected float[]SFVec3f bboxSize NULLprotected List<VRMLNodeType> MFNode children NULLprotected booleanSFBool 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
ConstructorsModifierConstructorDescriptionprotectedBaseGroupingNode(String name) Construct a default instance of the grouping node type. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(VRMLNodeType newChild) Append a new child node to the existing collection.protected voidaddChildNode(VRMLNodeType node) Add a single child node to the list of available children.protected voidClear the child node list of all children in the VRML node.booleanA check to see if this grouping node contains any bindable nodes.protected voidcopy(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.booleanGet 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 copyintReturns the number of childrengetFieldValue(int index) Get the value of a field.intGet the primary type of this node.booleanGet the current value of the visible field.booleanisShared()Check to see if this node has been used more than once.protected voidremoveChildNode(VRMLNodeType node) Remove the given node from this grouping node.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetBboxCenter(float[] val) Set the bounding box for this node.voidsetBboxDisplay(boolean val) Set the bounding box display for this node.voidsetBboxSize(float[] val) Set the bounding box for this node.voidsetChildren(VRMLNodeType newChild) Accessor method to set the children field Creates an array containing only newChild If passed null this method will act like removeChildrenvoidsetChildren(VRMLNodeType[] newChildren) Accesor method to set the children field If passed null this method will act like removeChildrenvoidsetDEF()Notify this node that is has been DEFd.voidsetShared(boolean used) Adjust the sharing count up or down one increment depending on the flag.voidNotification that the construction phase of this node has finished.voidsetValue(int index, boolean value) Set the value of the field at the given index as an boolean.voidsetValue(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.voidsetValue(int index, VRMLNodeType child) Set the value of the field at the given index as an array of nodes.voidsetValue(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.voidsetVisible(boolean val) Set visible field for this node.voidupdateRefCount(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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsCompleteMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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:VRMLBoundedNodeTypeGet the current value of field the bboxCenter field. The default value is0 0 0.- Specified by:
getBboxCenterin interfaceVRMLBoundedNodeType- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxSize field. The default value is-1 -1 -1.- Specified by:
getBboxSizein interfaceVRMLBoundedNodeType- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxDisplay field. The default value isfalse.- Specified by:
getBboxDisplayin interfaceVRMLBoundedNodeType- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the visible field. The default value istrue.- Specified by:
getVisiblein interfaceVRMLBoundedNodeType- Returns:
- the value of the visible(SFBool)
-
getChildren
Get the children, provides a live reference not a copy- Specified by:
getChildrenin 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:
setChildrenin 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:
setChildrenin 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:
addChildin interfaceVRMLGroupingNodeType- Parameters:
newChild- The new child
-
getChildrenSize
public int getChildrenSize()Returns the number of children- Specified by:
getChildrenSizein 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:
containsBindableNodesin 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:
updateRefCountin interfaceVRMLNodeType- Overrides:
updateRefCountin 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:
setDEFin interfaceVRMLNodeType- Overrides:
setDEFin 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin classAbstractNode
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryTypein 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:VRMLNodeTypeSet 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:VRMLNodeTypeSet the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setBboxCenterin 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:
setBboxSizein 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:
setBboxDisplayin 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:
setVisiblein 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
-