Class BaseTimeController
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
org.web3d.vrml.renderer.common.nodes.time.BaseTimeController
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLNodeType
,VRMLSensorNodeType
,VRMLTimeControlledNodeType
,VRMLTimeDependentNodeType
,VRMLTimeListener
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
OGLTimeController
public class BaseTimeController
extends BaseTimeDependentNode
implements VRMLSensorNodeType, VRMLTimeControlledNodeType, VRMLTimeListener
Base implementation of a custom TimeSensor 'like' node. The TimeController is
designed to be used as the basis for VCR type controls.
- Version:
- $Revision: 1.1 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for currentTimeprotected static final int
The field index for finalTimeprotected static final int
The field index for enabledprotected static final int
The field index for fractionprotected static final int
The field index for isActiveprotected static final int
The field index for loopprotected static final int
The field index for rateprotected static final int
The field index for rateprotected static final int
The field index for startTimeprotected static final int
The field index for stopTimeprotected static final int
The last field index used by this classprotected static final int
Number of fields constantprotected double
The value of the currentTime fieldprotected boolean
The value of the direction fieldprotected boolean
The value of the enabled fieldprotected float
The value of the fraction intervalprotected boolean
The value of the isActive fieldprotected boolean
The value of the loop fieldprotected float
The value of the rate fieldprotected boolean
The value of the run fieldprotected double
The value of the startTime fieldprotected double
The value of the stopTime fieldFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
vrmlClock
Fields 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
ConstructorsConstructorDescriptionConstruct a new time sensor objectConstruct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Accessor method to get current value to the enabled field.getFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.boolean
Accessor method to get current value of fieldisActive
.boolean
getLoop()
Accessor method to get current value of field loop, default value isfalse
int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.int
Get the primary type of this node.int[]
Get the secondary type of this node.double
Accessor method to get current value of field startTime, default value is0
.double
Accessor method to get current value of field stopTime, default value is0
void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setCurrentTime
(double time) Set a new value for the current time.void
setDirection
(boolean direction) Set the direction field value.void
setEnabled
(boolean enabled) Set the sensor enabled or disabled.void
setLoop
(boolean loop) Set the loop field value.void
setRate
(float rate) Set the rate field value.void
setRun
(boolean run) Set the run field value.void
setStartTime
(double time) Set a new value for the initial time.void
setStopTime
(double time) Set a new value for the final time.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as a boolean.void
setValue
(int index, double value) Set the value of the field at the given index as a double for the SFTime fields.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setVRMLClock
(VRMLClock clk) Set the vrmlClock that this time dependent node will be running with.void
timeClick
(long time) Notification that the time is now this value.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, setUserData, 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
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, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_DIRECTION
protected static final int FIELD_DIRECTIONThe field index for finalTime- See Also:
-
FIELD_ENABLED
protected static final int FIELD_ENABLEDThe field index for enabled- See Also:
-
FIELD_LOOP
protected static final int FIELD_LOOPThe field index for loop- See Also:
-
FIELD_RATE
protected static final int FIELD_RATEThe field index for rate- See Also:
-
FIELD_RUN
protected static final int FIELD_RUNThe field index for rate- See Also:
-
FIELD_CURRENT_TIME
protected static final int FIELD_CURRENT_TIMEThe field index for currentTime- See Also:
-
FIELD_START_TIME
protected static final int FIELD_START_TIMEThe field index for startTime- See Also:
-
FIELD_STOP_TIME
protected static final int FIELD_STOP_TIMEThe field index for stopTime- See Also:
-
FIELD_FRACTION
protected static final int FIELD_FRACTIONThe field index for fraction- See Also:
-
FIELD_IS_ACTIVE
protected static final int FIELD_IS_ACTIVEThe field index for isActive- See Also:
-
LAST_TIME_CONTROLLER_INDEX
protected static final int LAST_TIME_CONTROLLER_INDEXThe last field index used by this class- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfDirection
protected boolean vfDirectionThe value of the direction field -
vfEnabled
protected boolean vfEnabledThe value of the enabled field -
vfLoop
protected boolean vfLoopThe value of the loop field -
vfRate
protected float vfRateThe value of the rate field -
vfRun
protected boolean vfRunThe value of the run field -
vfCurrentTime
protected double vfCurrentTimeThe value of the currentTime field -
vfStartTime
protected double vfStartTimeThe value of the startTime field -
vfStopTime
protected double vfStopTimeThe value of the stopTime field -
vfFraction
protected float vfFractionThe value of the fraction interval -
vfIsActive
protected boolean vfIsActiveThe value of the isActive field
-
-
Constructor Details
-
BaseTimeController
public BaseTimeController()Construct a new time sensor object -
BaseTimeController
Construct a new instance of this node based on the details from the given node. If the node is not the same type, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not the same type
-
-
Method Details
-
setVRMLClock
Set the vrmlClock that this time dependent node will be running with. The vrmlClock provides all the information and listeners for keeping track of time. If we are enabled at the time that this method is called we automatically register the listener. Then, all the events that need to be generated will be handled at the next vrmlClock tick we get issued.- Specified by:
setVRMLClock
in interfaceVRMLTimeDependentNodeType
- Overrides:
setVRMLClock
in classBaseTimeDependentNode
- Parameters:
clk
- The vrmlClock to use for this node
-
setEnabled
public void setEnabled(boolean enabled) Set the sensor enabled or disabled.- Specified by:
setEnabled
in interfaceVRMLSensorNodeType
- Parameters:
enabled
- The new enabled value
-
getEnabled
public boolean getEnabled()Accessor method to get current value to the enabled field.- Specified by:
getEnabled
in interfaceVRMLSensorNodeType
- Returns:
- The value of the enabled field
-
getIsActive
public boolean getIsActive()Accessor method to get current value of fieldisActive
.- Specified by:
getIsActive
in interfaceVRMLSensorNodeType
- Returns:
- The current value of isActive
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
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
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
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, double value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a double for the SFTime fields. The fields effected by this cycleTime, cycleInterval, startTime, stopTime, fraction and time fields. This method does not currently check for negative values. Should it?- 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 knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
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 field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- 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 knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
timeClick
public void timeClick(long time) Notification that the time is now this value.- Specified by:
timeClick
in interfaceVRMLTimeListener
- Parameters:
time
- The current time
-
setLoop
public void setLoop(boolean loop) Set the loop field value.- Specified by:
setLoop
in interfaceVRMLTimeControlledNodeType
- Parameters:
loop
- Whether time loops or not
-
getLoop
public boolean getLoop()Accessor method to get current value of field loop, default value isfalse
- Specified by:
getLoop
in interfaceVRMLTimeControlledNodeType
- Returns:
- The value of the loop field
-
setStartTime
public void setStartTime(double time) Set a new value for the initial time. If the sensor is active then it is ignored.- Specified by:
setStartTime
in interfaceVRMLTimeControlledNodeType
- Parameters:
time
- The new initial time
-
getStartTime
public double getStartTime()Accessor method to get current value of field startTime, default value is0
.- Specified by:
getStartTime
in interfaceVRMLTimeControlledNodeType
- Returns:
- The current startTime
-
setStopTime
public void setStopTime(double time) Set a new value for the final time. If the sensor is active then it is ignored.- Specified by:
setStopTime
in interfaceVRMLTimeControlledNodeType
- Parameters:
time
- The new final time
-
getStopTime
public double getStopTime()Accessor method to get current value of field stopTime, default value is0
- Specified by:
getStopTime
in interfaceVRMLTimeControlledNodeType
- Returns:
- The current stop Time
-
setDirection
public void setDirection(boolean direction) Set the direction field value.- Parameters:
direction
- The new direction, true for forward, false for backward
-
setRun
public void setRun(boolean run) Set the run field value.- Parameters:
run
- The new run, true for running, false for stopped
-
setRate
public void setRate(float rate) Set the rate field value.- Parameters:
rate
- The multiplier of time passage
-
setCurrentTime
public void setCurrentTime(double time) Set a new value for the current time. If the sensor is active then it is ignored.- Parameters:
time
- The new current time
-