Class BaseSensorNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseSensorNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLNodeType
,VRMLSensorNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseCollisionSensor
,BaseDragSensorNode
,BaseGeoTouchSensor
,BaseKeySensor
,BaseLoadSensor
,BasePickingNode
,BaseProximitySensor
,BaseStringSensor
,BaseTouchSensor
,BaseVisibilitySensor
An abstract representation of any form of sensor for
subclassing by specific implementations.
- Version:
- $Revision: 1.8 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for enabledprotected static final int
The field index for isActiveprotected static final int
The last field index used by this classprotected boolean
The value of the enabled fieldprotected boolean
The value of the isActive fieldFields 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
BaseSensorNode
(String name) Initialise the sensor node and it's fields that are held locally. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
Get the current value of the enabled field.getFieldValue
(int index) Get the value of a field.boolean
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, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, 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, 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, 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, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_ENABLED
protected static final int FIELD_ENABLEDThe field index for enabled- See Also:
-
FIELD_IS_ACTIVE
protected static final int FIELD_IS_ACTIVEThe field index for isActive- See Also:
-
LAST_SENSOR_INDEX
protected static final int LAST_SENSOR_INDEXThe last field index used by this class- See Also:
-
vfEnabled
protected boolean vfEnabledThe value of the enabled field -
vfIsActive
protected boolean vfIsActiveThe value of the isActive field
-
-
Constructor Details
-
BaseSensorNode
Initialise the sensor node and it's fields that are held locally.- Parameters:
name
- The name of the type of node
-
-
Method Details
-
copy
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 interfaceVRMLSensorNodeType
- Parameters:
state
- True if this sensor is to be enabled
-
getEnabled
public boolean getEnabled()Get the current value of the enabled field. Default value istrue
.- Specified by:
getEnabled
in interfaceVRMLSensorNodeType
- Returns:
- The value of the enabled field
-
getIsActive
public boolean getIsActive()Get current value of the output-only field isActive.- Specified by:
getIsActive
in interfaceVRMLSensorNodeType
- Returns:
- The current value of isActive
-
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 a boolean. This is be used to set SFBool field types isActive, enabled and loop.- 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 index is not a valid fieldInvalidFieldValueException
- The field value is not legal for the field specified.
-