Xj3D VRML/X3D Code API

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

java.lang.Object
  extended byorg.web3d.vrml.renderer.common.nodes.AbstractNode
      extended byorg.web3d.vrml.renderer.common.nodes.BaseSensorNode
All Implemented Interfaces:
FrameStateListener, VRMLChildNodeType, VRMLNode, VRMLNodeType, VRMLSensorNodeType
Direct Known Subclasses:
BaseDragSensorNode

public abstract class BaseSensorNode
extends AbstractNode
implements VRMLSensorNodeType

An abstract representation of any form of sensor for subclassing by specific implementations.

Version:
$Revision: 1.7 $
Author:
Alan Hudson

Field Summary
protected static int FIELD_ENABLED
          The field index for enabled
protected static int FIELD_IS_ACTIVE
          The field index for isActive
protected static int LAST_SENSOR_INDEX
          The last field index used by this class
protected  boolean vfEnabled
          The value of the enabled field
protected  boolean vfIsActive
          The value of the isActive field
 
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 BaseSensorNode(java.lang.String name)
          Initialise the sensor node and it's fields that are held locally.
 
Method Summary
protected  void copy(VRMLSensorNodeType node)
          Set the fields of the sensor node that has the fields set based on the fields of the passed in node.
 boolean getEnabled()
          Get the current value of the enabled field.
 VRMLFieldData getFieldValue(int index)
          Get the value of a field.
 boolean getIsActive()
          Get current value of the output-only field isActive.
 void sendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex)
          Send a routed value from this node to the given destination node.
 void setEnabled(boolean state)
          Set a new state for the enabled field.
 void setValue(int index, boolean value)
          Set the value of the field at the given index as a boolean.
 
Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, fireFieldChanged, getMetadataObject, getNodeFieldIndices, getRefCount, getSecondaryType, 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, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
 
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
 

Field Detail

FIELD_ENABLED

protected static final int FIELD_ENABLED
The field index for enabled

See Also:
Constant Field Values

FIELD_IS_ACTIVE

protected static final int FIELD_IS_ACTIVE
The field index for isActive

See Also:
Constant Field Values

LAST_SENSOR_INDEX

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

See Also:
Constant Field Values

vfEnabled

protected boolean vfEnabled
The value of the enabled field


vfIsActive

protected boolean vfIsActive
The value of the isActive field

Constructor Detail

BaseSensorNode

protected BaseSensorNode(java.lang.String name)
Initialise the sensor node and it's fields that are held locally.

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

copy

protected void copy(VRMLSensorNodeType node)
Set the fields of the sensor 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 sensor node to copy info from

setEnabled

public void setEnabled(boolean state)
Set a new state for the enabled field.

Specified by:
setEnabled in interface VRMLSensorNodeType
Parameters:
state - True if this sensor is to be enabled

getEnabled

public boolean getEnabled()
Get the current value of the enabled field. Default value is true.

Specified by:
getEnabled in interface VRMLSensorNodeType
Returns:
The value of the enabled field

getIsActive

public boolean getIsActive()
Get current value of the output-only field isActive.

Specified by:
getIsActive in interface VRMLSensorNodeType
Returns:
The current value of isActive

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 a boolean. This is be used to set SFBool field types isActive, enabled and loop.

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 index is not a valid field
InvalidFieldValueException - The field value is not legal for the field specified.

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium