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 intThe field index for currentTimeprotected static final intThe field index for finalTimeprotected static final intThe field index for enabledprotected static final intThe field index for fractionprotected static final intThe field index for isActiveprotected static final intThe field index for loopprotected static final intThe field index for rateprotected static final intThe field index for rateprotected static final intThe field index for startTimeprotected static final intThe field index for stopTimeprotected static final intThe last field index used by this classprotected static final intNumber of fields constantprotected doubleThe value of the currentTime fieldprotected booleanThe value of the direction fieldprotected booleanThe value of the enabled fieldprotected floatThe value of the fraction intervalprotected booleanThe value of the isActive fieldprotected booleanThe value of the loop fieldprotected floatThe value of the rate fieldprotected booleanThe value of the run fieldprotected doubleThe value of the startTime fieldprotected doubleThe value of the stopTime fieldFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
vrmlClockFields 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 TypeMethodDescriptionbooleanAccessor method to get current value to the enabled field.getFieldDeclaration(int index) Get the declaration of the field at the given index.intgetFieldIndex(String fieldName) Get the index of the given field name.getFieldValue(int index) Get the value of a field.booleanAccessor method to get current value of fieldisActive.booleangetLoop()Accessor method to get current value of field loop, default value isfalseint[]Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).intGet the number of fields.intGet the primary type of this node.int[]Get the secondary type of this node.doubleAccessor method to get current value of field startTime, default value is0.doubleAccessor method to get current value of field stopTime, default value is0voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetCurrentTime(double time) Set a new value for the current time.voidsetDirection(boolean direction) Set the direction field value.voidsetEnabled(boolean enabled) Set the sensor enabled or disabled.voidsetLoop(boolean loop) Set the loop field value.voidsetRate(float rate) Set the rate field value.voidsetRun(boolean run) Set the run field value.voidsetStartTime(double time) Set a new value for the initial time.voidsetStopTime(double time) Set a new value for the final time.voidNotification that the construction phase of this node has finished.voidsetValue(int index, boolean value) Set the value of the field at the given index as a boolean.voidsetValue(int index, double value) Set the value of the field at the given index as a double for the SFTime fields.voidsetValue(int index, float value) Set the value of the field at the given index as a float.voidsetVRMLClock(VRMLClock clk) Set the vrmlClock that this time dependent node will be running with.voidtimeClick(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, 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
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, 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:
setVRMLClockin interfaceVRMLTimeDependentNodeType- Overrides:
setVRMLClockin classBaseTimeDependentNode- Parameters:
clk- The vrmlClock to use for this node
-
setEnabled
public void setEnabled(boolean enabled) Set the sensor enabled or disabled.- Specified by:
setEnabledin interfaceVRMLSensorNodeType- Parameters:
enabled- The new enabled value
-
getEnabled
public boolean getEnabled()Accessor method to get current value to the enabled field.- Specified by:
getEnabledin interfaceVRMLSensorNodeType- Returns:
- The value of the enabled field
-
getIsActive
public boolean getIsActive()Accessor method to get current value of fieldisActive.- Specified by:
getIsActivein 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:
getFieldIndexin 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:
getNodeFieldIndicesin 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:
getFieldDeclarationin 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:
getNumFieldsin 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:
getPrimaryTypein 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:
getSecondaryTypein interfaceVRMLNode- Overrides:
getSecondaryTypein 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin 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:
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, 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:
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 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:
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 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:
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 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:
timeClickin interfaceVRMLTimeListener- Parameters:
time- The current time
-
setLoop
public void setLoop(boolean loop) Set the loop field value.- Specified by:
setLoopin 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:
getLoopin 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:
setStartTimein 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:
getStartTimein 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:
setStopTimein 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:
getStopTimein 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
-