vrml.node
Class Script

java.lang.Object
  extended by vrml.BaseNode
      extended by vrml.node.Script
Direct Known Subclasses:
ScriptNodeEventOutControl, ScriptNodeFieldControl

public abstract class Script
extends BaseNode

This is the general Script class, to be subclassed by all scripts. Note that the provided methods allow the script author to explicitly throw tailored exceptions in case something goes wrong in the script.


Constructor Summary
Script()
           
 
Method Summary
 void eventsProcessed()
          eventsProcessed() is called after every invocation of processEvents().
protected  Field getEventIn(java.lang.String eventInName)
          Get an EventIn by name.
protected  Field getEventOut(java.lang.String eventOutName)
          Get an EventOut by name.
protected  Field getField(java.lang.String fieldName)
          Get a Field by name.
 void initialize()
           The initialize() method is called before any event is generated.
 void processEvent(Event event)
          processEvent() is called automatically when the script receives an event.
 void processEvents(int count, Event[] events)
          processEvents() is called automatically when the script receives some set of events.
 void shutdown()
          shutdown() is called when this Script node is deleted.
 java.lang.String toString()
          toString() overrides a utility method in Object, allowing run-time inspection of class name.
 
Methods inherited from class vrml.BaseNode
getBrowser, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Script

public Script()
Method Detail

initialize

public void initialize()

The initialize() method is called before any event is generated.

Authors may define an initialize() method within the Script class that is called before the browser presents the world to the user and before any events are processed by any nodes in the same VRML file as the Script node containing this script (see 4.12.3, Initialize() and shutdown()). The various methods of the Script class such as getEventIn(), getEventOut(), getExposedField(), and getField() are not guaranteed to return correct values before the initialize() method has been executed. The initialize() method is called once during the life of the Script object.

Reference: http://www.web3D.org/technicalinfo/specifications/vrml97/part1/java.html#B.4.6

Its default behaviour is no operation. See Example2.java in http://www.web3D.org/technicalinfo/specifications/vrml97/part1/java.html#B.5.1 for an example of a user-specified initialize() method.


getField

protected final Field getField(java.lang.String fieldName)
Get a Field by name.

Throws:
InvalidFieldException - if fieldName isn't a valid field name for a node of this type.

getEventOut

protected final Field getEventOut(java.lang.String eventOutName)
Get an EventOut by name. Throws an InvalidEventOutException if eventOutName isn't a valid eventOut name for a node of this type.


getEventIn

protected final Field getEventIn(java.lang.String eventInName)
Get an EventIn by name. Throws an InvalidEventInException if eventInName isn't a valid eventIn name for a node of this type.


processEvents

public void processEvents(int count,
                          Event[] events)
processEvents() is called automatically when the script receives some set of events. It shall not be called directly except by the author-defined subclass.

Parameters:
count - indicates the number of events delivered.
events - provides the event(s) ROUTEd to the script.

processEvent

public void processEvent(Event event)
processEvent() is called automatically when the script receives an event.

Parameters:
event - provides the event ROUTEd to the script.

eventsProcessed

public void eventsProcessed()
eventsProcessed() is called after every invocation of processEvents().


shutdown

public void shutdown()
shutdown() is called when this Script node is deleted. Reference: http://www.web3D.org/technicalinfo/specifications/vrml97/part1/java.html#B.4.5


toString

public java.lang.String toString()
toString() overrides a utility method in Object, allowing run-time inspection of class name.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()