Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.scripting.sai
Class JavaSAIScriptWrapper

java.lang.Object
  extended by org.web3d.vrml.scripting.sai.JavaSAIScriptWrapper
All Implemented Interfaces:
FieldAccessListener, ScriptWrapper

public class JavaSAIScriptWrapper
extends java.lang.Object
implements ScriptWrapper, FieldAccessListener

A wrapper class used to convert between the Xj3D implementation specific details and the X3D spec requirements for a script.

Note that as this class does not wrap VRML97 scripts, the class does not need to take an instance of VRMLScriptNodeType as we cannot change the field listing dynamically.

Version:
$Revision: 1.19 $
Author:
Justin Couch

Constructor Summary
JavaSAIScriptWrapper(X3DScriptImplementation sc)
          Create a new script wrapper for the given script class
 
Method Summary
 void childRequiresAccessStateChange(boolean state)
          Notify that the child field now requires access to be valid or not valid as the case may be from the various flags.
 void eventsProcessed()
          Notification that the eventsProcessed() functionality should be called on the script code now.
 void initialize(VRMLScriptNodeType node)
          Initialise the underlying script, based on the surrounding node's details.
 boolean prepareEvents()
          Call the prepareEvents() method on the script, if it has one.
 void queueEvent(int type, java.lang.String name, boolean value)
          Queue a changed SFBool event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, boolean[] value, int numValid)
          Queue a changed MFBool event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, double value)
          Queue a changed SFTime event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, double[] value, int numValid)
          Queue a changed MFTime or MFDouble event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, float value)
          Queue a changed SFFloat event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, float[] value, int numValid)
          Queue a changed event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, int value)
          Queue a changed SFInt32 event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, int[] value, int numValid)
          Queue a changed MFInt32 event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, long value)
          Queue a changed SFLong event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, long[] value, int numValid)
          Queue a changed MFLong event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, java.lang.String value)
          Queue a changed SFString event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, java.lang.String[] value, int numValid)
          Queue a changed MFString event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, VRMLNodeType value)
          Queue a changed SFNode event value ready for processing by the script.
 void queueEvent(int type, java.lang.String name, VRMLNodeType[] value, int numValid)
          Queue a changed MFNode event value ready for processing by the script.
 boolean sendEvents()
          Send the events to the real script now, and then call eventsProcessed.
 void setTimestamp(double time)
          Set the timestamp that we shall start the next queue with.
 void shutdown()
          Called when the Script node is deleted.
 void updateEventOuts()
          Process the eventOuts of the script now.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSAIScriptWrapper

public JavaSAIScriptWrapper(X3DScriptImplementation sc)
Create a new script wrapper for the given script class

Parameters:
sc - The script that this class is wrapping
Method Detail

initialize

public void initialize(VRMLScriptNodeType node)
Initialise the underlying script, based on the surrounding node's details.

Specified by:
initialize in interface ScriptWrapper
Parameters:
node - The working node from the live scene graph

setTimestamp

public void setTimestamp(double time)
Set the timestamp that we shall start the next queue with.

Specified by:
setTimestamp in interface ScriptWrapper
Parameters:
time - The timestamp to use (in seconds)

prepareEvents

public boolean prepareEvents()
Call the prepareEvents() method on the script, if it has one. If it does not, this becomes a no-op. Return true if something executed and therefore we need to check on further events being sent.

Specified by:
prepareEvents in interface ScriptWrapper
Returns:
true if something executed

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       int value)
Queue a changed SFInt32 event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       int[] value,
                       int numValid)
Queue a changed MFInt32 event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       long value)
Queue a changed SFLong event value ready for processing by the script. Not used as VRML97 does not support these types.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       long[] value,
                       int numValid)
Queue a changed MFLong event value ready for processing by the script. Not used as VRML97 does not support these types.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       boolean value)
Queue a changed SFBool event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       boolean[] value,
                       int numValid)
Queue a changed MFBool event value ready for processing by the script. Not used as VRML97 does not have MFBool.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       float value)
Queue a changed SFFloat event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       float[] value,
                       int numValid)
Queue a changed event value ready for processing by the script. Used to set SFColor, SFRotation, SFVec2f, SFVec3f or MFFloat fields

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       double value)
Queue a changed SFTime event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       double[] value,
                       int numValid)
Queue a changed MFTime or MFDouble event value ready for processing by the script. Not used as VRML97 does not support these types.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       java.lang.String value)
Queue a changed SFString event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       java.lang.String[] value,
                       int numValid)
Queue a changed MFString event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       VRMLNodeType value)
Queue a changed SFNode event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field

queueEvent

public void queueEvent(int type,
                       java.lang.String name,
                       VRMLNodeType[] value,
                       int numValid)
Queue a changed MFNode event value ready for processing by the script.

Specified by:
queueEvent in interface ScriptWrapper
Parameters:
type - The type of field to process
name - The field name to process
value - The new value of the field
numValid - The number of valid values to copy from the array

sendEvents

public boolean sendEvents()
Send the events to the real script now, and then call eventsProcessed.

Specified by:
sendEvents in interface ScriptWrapper
Returns:
true if events were processed this time around

updateEventOuts

public void updateEventOuts()
Process the eventOuts of the script now. It should do that by calling setValue() on the script node instance passed in as part of the the initialize() method.

Specified by:
updateEventOuts in interface ScriptWrapper

eventsProcessed

public void eventsProcessed()
Notification that the eventsProcessed() functionality should be called on the script code now.

Specified by:
eventsProcessed in interface ScriptWrapper

shutdown

public void shutdown()
Called when the Script node is deleted. We free everything here to allow the GC to do its magic.

Specified by:
shutdown in interface ScriptWrapper

childRequiresAccessStateChange

public void childRequiresAccessStateChange(boolean state)
Notify that the child field now requires access to be valid or not valid as the case may be from the various flags.

Specified by:
childRequiresAccessStateChange in interface FieldAccessListener
Parameters:
state - true if access should be currently valid.

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium