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 intThe field index for enabledprotected static final intThe field index for isActiveprotected static final intThe last field index used by this classprotected booleanThe value of the enabled fieldprotected booleanThe 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
ConstructorsModifierConstructorDescriptionprotectedBaseSensorNode(String name) Initialise the sensor node and it's fields that are held locally. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcopy(VRMLSensorNodeType node) Set the fields of the sensor node that has the fields set based on the fields of the passed in node.booleanGet the current value of the enabled field.getFieldValue(int index) Get the value of a field.booleanGet current value of the output-only field isActive.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetEnabled(boolean state) Set a new state for the enabled field.voidsetValue(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, 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, getPrimaryType, 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, 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:
setEnabledin 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:
getEnabledin interfaceVRMLSensorNodeType- Returns:
- The value of the enabled field
-
getIsActive
public boolean getIsActive()Get current value of the output-only field isActive.- Specified by:
getIsActivein 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:
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, 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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.
-