Package org.xj3d.core.eventmodel
Interface ScriptManager
- All Known Implementing Classes:
DefaultScriptManager
public interface ScriptManager
Abstract representation of a class that can be used to provide script
lifecycle management facilities to the browser core.
The loader also takes part in the event model evaluation as well. For this,
it must hook into the URL change handling through the
VRMLUrlListener
interface and participate
as part of the larger event model. Method calls are provided in this
interface for other classes
(eg EventModelEvaluator
) to make
calls to at the appropriate time in the event model. This interface does
not extend the URLListener interface directly as it assumes that an
implementation may take other internal arrangements. It assumes that
listeners will be registered with the script nodes.
For VRML97/X3D conformant behaviour, the implied architecture of an implementation of this interface is 5 separate buckets of data:
- Waiting to be loaded
- In the process of being loaded
- Load complete (or failed) and waiting for initialize() to be called
- Load finished (or failed), nothing left to do
- Previously loaded scripts that have had set_url called and need to shutdown the old script and start the load process for others.
- Version:
- $Revision: 1.1 $
- Author:
- Justin Couch
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addScripts
(NodeArray list) Queue the scripts to add to the scene.void
Notification that all of the processing is finished and that eventsProcessed() should now be called.void
getProcessedScripts
(NodeArray list) Copy all the processed scripts to date into the given list.Get the current script loader to be used by this manager.void
initializeScripts
(double timestamp) Initialise any newly loaded scripts and then put them into the completed basket.void
prepareEvents
(double timestamp) Setup the scripts for the new timestamp.void
Process any events that scripts need to send.void
removeScripts
(NodeArray list) Remove this list of scripts from active service.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.void
Set the script loader to be used by this manager.void
shutdown()
Shutdown all scripts as the system is about to shutdown all of the current world and is starting again.void
The loader should now shutdown any scripts that have had their set_url events called.
-
Method Details
-
setErrorReporter
void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Parameters:
reporter
- The instance to use or null
-
setScriptLoader
Set the script loader to be used by this manager. Setting a null value will clear the current instance and disable all script loading.- Parameters:
ldr
- The loader instance to use
-
getScriptLoader
ScriptLoader getScriptLoader()Get the current script loader to be used by this manager. If none is currently in use, null will be returned.- Returns:
- The current loader instance or null
-
shutdownActiveScripts
void shutdownActiveScripts()The loader should now shutdown any scripts that have had their set_url events called. -
shutdown
void shutdown()Shutdown all scripts as the system is about to shutdown all of the current world and is starting again. -
initializeScripts
void initializeScripts(double timestamp) Initialise any newly loaded scripts and then put them into the completed basket.- Parameters:
timestamp
- The VRML time that the initialization occurred at
-
prepareEvents
void prepareEvents(double timestamp) Setup the scripts for the new timestamp. For X3D, this will also call the prepareEvents() method/function on the script, if it has one.- Parameters:
timestamp
- The current time in VRML time
-
processEvents
void processEvents()Process any events that scripts need to send. This looks for any inputs that have changed, and also any outputs and propagates the values to the eventOuts of the script. If the eventOuts are routed somewhere, it is the RouteManager's responsibility to look after sending those changed values. -
eventsProcessed
void eventsProcessed()Notification that all of the processing is finished and that eventsProcessed() should now be called. -
removeScripts
Remove this list of scripts from active service. They have been deleted from the scene graph and therefore the listener should no longer be registered with them.- Parameters:
list
- The list of scripts to remove
-
addScripts
Queue the scripts to add to the scene.- Parameters:
list
- the list of scripts to add
-
getProcessedScripts
Copy all the processed scripts to date into the given list. After this is done, clear the internal collection. The calling script should be empty because it will replace the contents of the given list with this collection of values.- Parameters:
list
- The list to copy values into
-