Xj3D VRML/X3D Code API

org.web3d.vrml.renderer.common.nodes
Class BaseBindableNode

java.lang.Object
  extended byorg.web3d.vrml.renderer.common.nodes.AbstractNode
      extended byorg.web3d.vrml.renderer.common.nodes.BaseBindableNode
All Implemented Interfaces:
FrameStateListener, VRMLBindableNodeType, VRMLChildNodeType, VRMLNode, VRMLNodeType, VRMLTimeDependentNodeType

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.12 $
Author:
Alan Hudson, Justin Couch

Field Summary
protected static int FIELD_BIND
          Index of the set_bind eventIn
protected static int FIELD_BIND_TIME
          Index of the bindTime field
protected static int FIELD_IS_BOUND
          Index of the isBind eventOut
protected  boolean isOnStack
          Flag indicating if this node is already on the stack
protected static int LAST_BINDABLE_INDEX
          The last field index used by this class
protected  double vfBindTime
          SFTime bindTime
protected  boolean vfIsBound
          SFBool isBound
 
Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
BAD_NODE_MSG, errorReporter, FIELD_METADATA, fieldData, hasChanged, INIT_ONLY_WRITE_MSG, inSetup, isDEF, isStatic, LAST_NODE_INDEX, METADATA_NODE_MSG, METADATA_PROTO_MSG, nodeName, pMetadata, refCount, stateManager, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
 
Constructor Summary
protected BaseBindableNode(java.lang.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
 void addBindableNodeListener(VRMLBindableNodeListener l)
          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 getBindTime()
          Set the bindTime field of this node.
 VRMLFieldData getFieldValue(int index)
          Get the value of a field.
 boolean getIsBound()
          Get the current isBound state of the node.
 int[] getSecondaryType()
          Get the secondary type of this node.
 void removeBindableNodeListener(VRMLBindableNodeListener l)
          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 appropriate
 void 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, fireFieldChanged, getMetadataObject, getNodeFieldIndices, getRefCount, 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, updateRefCount
 
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.VRMLNodeType
addNodeListener, getMetadataObject, getRefCount, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
 
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.FrameStateListener
allEventsComplete
 

Field Detail

FIELD_BIND

protected static final int FIELD_BIND
Index of the set_bind eventIn

See Also:
Constant Field Values

FIELD_BIND_TIME

protected static final int FIELD_BIND_TIME
Index of the bindTime field

See Also:
Constant Field Values

FIELD_IS_BOUND

protected static final int FIELD_IS_BOUND
Index of the isBind eventOut

See Also:
Constant Field Values

LAST_BINDABLE_INDEX

protected static final int LAST_BINDABLE_INDEX
The last field index used by this class

See Also:
Constant Field Values

vfBindTime

protected double vfBindTime
SFTime bindTime


vfIsBound

protected boolean vfIsBound
SFBool isBound


isOnStack

protected boolean isOnStack
Flag indicating if this node is already on the stack

Constructor Detail

BaseBindableNode

protected BaseBindableNode(java.lang.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).

Parameters:
name - The name of the type of node
Method Detail

copy

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

public void setVRMLClock(VRMLClock clock)
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 interface VRMLTimeDependentNodeType
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 interface VRMLBindableNodeType
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 interface VRMLBindableNodeType
Parameters:
enable - True if this node is to be bound
notify - true if this should notify the listeners
time - The time that this was sent

getIsBound

public boolean getIsBound()
Get the current isBound state of the node.

Specified by:
getIsBound in interface VRMLBindableNodeType
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 interface VRMLBindableNodeType
Returns:
The bound time value last set

addBindableNodeListener

public void addBindableNodeListener(VRMLBindableNodeListener l)
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 interface VRMLBindableNodeType
Parameters:
l - The listener to add

removeBindableNodeListener

public void removeBindableNodeListener(VRMLBindableNodeListener l)
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 interface VRMLBindableNodeType
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 interface VRMLNode
Overrides:
getSecondaryType in class AbstractNode
Returns:
The secondary type

getFieldValue

public VRMLFieldData getFieldValue(int index)
                            throws InvalidFieldException
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 interface VRMLNodeType
Overrides:
getFieldValue in class AbstractNode
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

public void sendRoute(double time,
                      int srcIndex,
                      VRMLNodeType destNode,
                      int destIndex)
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 interface VRMLNodeType
Overrides:
sendRoute in class AbstractNode
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 from
destNode - The node reference that we will be sending the value to
destIndex - 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 interface VRMLNodeType
Overrides:
setValue in class AbstractNode
Parameters:
index - The index of destination field to set
value - The new value to use for the node
Throws:
InvalidFieldException - The field index is not know
InvalidFieldValueException - The value provided is out of range for the field type.

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

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium