Xj3D VRML/X3D Code API

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

java.lang.Object
  extended byorg.web3d.vrml.renderer.common.nodes.AbstractNode
      extended byorg.web3d.vrml.renderer.common.nodes.BaseSequencerNode
All Implemented Interfaces:
FrameStateListener, VRMLChildNodeType, VRMLNode, VRMLNodeType, VRMLSequencerNodeType

public abstract class BaseSequencerNode
extends AbstractNode
implements VRMLSequencerNodeType

Abstract implementation of a sequencer so that specific instances can derive from it.

Sequencer nodes are designed for discrete animation. Sequencers are driven by an input and produce corresponding impulse output functions.

Version:
$Revision: 1.3 $
Author:
Alan Hudson

Field Summary
protected static int FIELD_KEY
          The field index for key
protected static int FIELD_KEY_VALUE
          The field index for keyValue
protected static int FIELD_NEXT
          The field index for next
protected static int FIELD_PREVIOUS
          The field index for previous
protected static int FIELD_SET_FRACTION
          The field index for set_fraction
protected static int FIELD_VALUE_CHANGED
          The field index for the value_changed field
protected static int LAST_SEQUENCER_INDEX
          The last field index used by this class
protected  int numKey
          The number of valid items in vfKey
protected  float vfFraction
          The value of the fraction field
protected  float[] vfKey
          The value of the key 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
BaseSequencerNode(java.lang.String name)
          Initialise the time dependent node and it's fields that are held locally.
 
Method Summary
protected  void copy(VRMLSequencerNodeType node)
          Set the fields of the interpolator node that has the fields set based on the fields of the passed in node.
 VRMLFieldData getFieldValue(int index)
          Get the value of a field.
 float getFraction()
          Get the value of the fraction field.
 float[] getKey()
          Get current value of key field value.
 int getNumKey()
          Get the number of valid keys defined for this interpolator.
 int getPrimaryType()
          Get the primary type of this node.
 void sendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex)
          Send a routed value from this node to the given destination node.
 void setKey(float[] keys, int numValid)
          Set a new value for the key field.
 void setNext()
          Cause the next value to be generated on the output.
 void setPrevious()
          Cause the previous value to be generated on the output.
 void setValue(int index, float[] value, int numValid)
          Set the value of the field at the given index as an array of floats.
 
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.VRMLSequencerNodeType
setFraction
 
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, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
 
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
 

Field Detail

FIELD_NEXT

protected static final int FIELD_NEXT
The field index for next

See Also:
Constant Field Values

FIELD_PREVIOUS

protected static final int FIELD_PREVIOUS
The field index for previous

See Also:
Constant Field Values

FIELD_SET_FRACTION

protected static final int FIELD_SET_FRACTION
The field index for set_fraction

See Also:
Constant Field Values

FIELD_KEY

protected static final int FIELD_KEY
The field index for key

See Also:
Constant Field Values

FIELD_KEY_VALUE

protected static final int FIELD_KEY_VALUE
The field index for keyValue

See Also:
Constant Field Values

FIELD_VALUE_CHANGED

protected static final int FIELD_VALUE_CHANGED
The field index for the value_changed field

See Also:
Constant Field Values

LAST_SEQUENCER_INDEX

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

See Also:
Constant Field Values

vfFraction

protected float vfFraction
The value of the fraction field


vfKey

protected float[] vfKey
The value of the key field


numKey

protected int numKey
The number of valid items in vfKey

Constructor Detail

BaseSequencerNode

public BaseSequencerNode(java.lang.String name)
Initialise the time dependent node and it's fields that are held locally.

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

copy

protected void copy(VRMLSequencerNodeType node)
Set the fields of the interpolator node that has the fields set based on the fields of the passed in node.

Parameters:
node - The interpolator node to copy info from

getPrimaryType

public int getPrimaryType()
Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.

Specified by:
getPrimaryType in interface VRMLNode
Returns:
The primary type

setNext

public void setNext()
Cause the next value to be generated on the output. This is equivalent to sending a value to the next inputOnly field.

Specified by:
setNext in interface VRMLSequencerNodeType

setPrevious

public void setPrevious()
Cause the previous value to be generated on the output. This is equivalent to sending a value to the previous inputOnly field.

Specified by:
setPrevious in interface VRMLSequencerNodeType

getFraction

public float getFraction()
Get the value of the fraction field.

Specified by:
getFraction in interface VRMLSequencerNodeType
Returns:
The current value for fraction

setKey

public void setKey(float[] keys,
                   int numValid)
Set a new value for the key field. Null will delete all key values.

Specified by:
setKey in interface VRMLSequencerNodeType
Parameters:
keys - The new key values to use
numValid - The number of valid values to copy from the array

getNumKey

public int getNumKey()
Get the number of valid keys defined for this interpolator.

Specified by:
getNumKey in interface VRMLSequencerNodeType
Returns:
a value >= 0

getKey

public float[] getKey()
Get current value of key field value. If no keys exist a blank float[] will be returned.

Specified by:
getKey in interface VRMLSequencerNodeType
Returns:
The current key values

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,
                     float[] value,
                     int numValid)
              throws InvalidFieldException,
                     InvalidFieldValueException
Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFFloat and SFRotation field types.

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
numValid - The number of valid values to copy from the array
Throws:
InvalidFieldException - The field index is not know
InvalidFieldValueException - The value provided is out of range for the field type.

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium