Class BaseBindableNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseBindableNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBindableNodeType
,VRMLChildNodeType
,VRMLNodeType
,VRMLTimeDependentNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseBackground
,BaseFog
,BaseGeoViewpoint
,BaseNavigationInfo
,BaseOrthoViewpoint
,BaseTextureBackground
,BaseViewpoint
public abstract class BaseBindableNode
extends AbstractNode
implements VRMLBindableNodeType, VRMLTimeDependentNodeType
An abstract implementation of any bindable node.
The implementation treats the time and bound states independently. It is assumed that the browser environment displaying the world will take care of the stack and bind time information setting.
- Version:
- $Revision: 1.13 $
- Author:
- Alan Hudson, Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the set_bind eventInprotected static final int
Index of the bindTime fieldprotected static final int
Index of the isBind eventOutprotected boolean
Flag indicating if this node is already on the stackprotected static final int
The last field index used by this classprotected double
SFTime bindTimeprotected boolean
SFBool isBoundFields 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
BaseBindableNode
(String name) Construct a default instance of this class with the bind flag set to false and no time information set (effective value of zero). -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for geometry changed events.protected void
copy
(VRMLBindableNodeType node) Set the fields of the binadble node that has the fields set based on the fields of the passed in node.protected void
fireIsBoundChanged
(boolean isActive) Send the bindable listeners the an event to say we have just become the active node.double
Set the bindTime field of this node.getFieldValue
(int index) Get the value of a field.boolean
Get the current isBound state of the node.int[]
Get the secondary type of this node.void
Remove a listener for geometry changed events.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setBind
(boolean enable, boolean notify, double time) Set the bind field of this node.void
setOnStack
(boolean onStack) Notify the bindable node that it is on the stack, or not on the stack, as the case may be and that it should send bind events as appropriatevoid
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setVRMLClock
(VRMLClock clock) Set the clock that this time dependent node will be running with.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, 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, getPrimaryType, 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, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_BIND
protected static final int FIELD_BINDIndex of the set_bind eventIn- See Also:
-
FIELD_BIND_TIME
protected static final int FIELD_BIND_TIMEIndex of the bindTime field- See Also:
-
FIELD_IS_BOUND
protected static final int FIELD_IS_BOUNDIndex of the isBind eventOut- See Also:
-
LAST_BINDABLE_INDEX
protected static final int LAST_BINDABLE_INDEXThe last field index used by this class- See Also:
-
vfBindTime
protected double vfBindTimeSFTime bindTime -
vfIsBound
protected boolean vfIsBoundSFBool isBound -
isOnStack
protected boolean isOnStackFlag indicating if this node is already on the stack
-
-
Constructor Details
-
BaseBindableNode
Construct a default instance of this class with the bind flag set to false and no time information set (effective value of zero).- Parameters:
name
- The name of the type of node
-
-
Method Details
-
copy
Set the fields of the binadble node that has the fields set based on the fields of the passed in node. This directly copies the bind state, so could cause some interesting problems. Not sure what we should do with this currently.- Parameters:
node
- The bindable node to copy info from
-
setVRMLClock
Set the clock that this time dependent node will be running with. The clock provides all the information and listeners for keeping track of time. Setting a value of null will ask the node to remove the clock from it's use so that the node may be removed from the scene.- Specified by:
setVRMLClock
in interfaceVRMLTimeDependentNodeType
- Parameters:
clock
- The clock to use for this node
-
setOnStack
public void setOnStack(boolean onStack) Notify the bindable node that it is on the stack, or not on the stack, as the case may be and that it should send bind events as appropriate- Specified by:
setOnStack
in interfaceVRMLBindableNodeType
- Parameters:
onStack
- true if this node is now on the stack
-
setBind
public void setBind(boolean enable, boolean notify, double time) Set the bind field of this node. This will cause the node to be moved within the stack according to the properties.- Specified by:
setBind
in interfaceVRMLBindableNodeType
- Parameters:
enable
- True if this node is to be boundnotify
- true if this should notify the listenerstime
- The time that this was sent
-
getIsBound
public boolean getIsBound()Get the current isBound state of the node.- Specified by:
getIsBound
in interfaceVRMLBindableNodeType
- Returns:
- the current binding state
-
getBindTime
public double getBindTime()Set the bindTime field of this node. This has no effect on the bind information.- Specified by:
getBindTime
in interfaceVRMLBindableNodeType
- Returns:
- The bound time value last set
-
addBindableNodeListener
Add a listener for geometry changed events. If the listener is null or already registered it will silently ignore the requests.- Specified by:
addBindableNodeListener
in interfaceVRMLBindableNodeType
- Parameters:
l
- The listener to add
-
removeBindableNodeListener
Remove a listener for geometry changed events. If the listener is null or has not been registered it will silently ignore the requests.- Specified by:
removeBindableNodeListener
in interfaceVRMLBindableNodeType
- Parameters:
l
- The listener to remove
-
getSecondaryType
public int[] getSecondaryType()Get the secondary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Overrides:
getSecondaryType
in classAbstractNode
- Returns:
- The secondary 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, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an boolean. This would be used to set SFBool field type bind.- 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- Throws:
InvalidFieldException
- The field index is not knowInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
fireIsBoundChanged
protected void fireIsBoundChanged(boolean isActive) Send the bindable listeners the an event to say we have just become the active node.- Parameters:
isActive
- true if this node is becoming active
-