Package org.xj3d.impl.core.eventmodel
Class DefaultScriptManager
java.lang.Object
org.xj3d.impl.core.eventmodel.DefaultScriptManager
- All Implemented Interfaces:
VRMLUrlListener
,ScriptManager
,ScriptLoadStatusListener
public class DefaultScriptManager
extends Object
implements ScriptManager, VRMLUrlListener, ScriptLoadStatusListener
Default implementation of the ScriptManager interface that implements VRML97
and X3D semantics.
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
-
Constructor Summary
Constructors -
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
loadCompleted
(VRMLScriptNodeType script) Notification of a successful load of a script.void
loadFailed
(VRMLScriptNodeType script) Notification of a failed load of a script when none of the URLs could be loaded.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.void
urlChanged
(VRMLNodeType node, int index) Notification that the Url content for this node has changed
-
Constructor Details
-
DefaultScriptManager
public DefaultScriptManager()Construct a new instance of the script manager
-
-
Method Details
-
urlChanged
Notification that the Url content for this node has changed- Specified by:
urlChanged
in interfaceVRMLUrlListener
- Parameters:
node
-index
- The index of the field that has changed
-
loadCompleted
Notification of a successful load of a script. Not used for failed loads.- Specified by:
loadCompleted
in interfaceScriptLoadStatusListener
- Parameters:
script
- The script that was loaded correctly
-
loadFailed
Notification of a failed load of a script when none of the URLs could be loaded.- Specified by:
loadFailed
in interfaceScriptLoadStatusListener
- Parameters:
script
- The script that failed to load
-
setErrorReporter
public 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.- Specified by:
setErrorReporter
in interfaceScriptManager
- 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.- Specified by:
setScriptLoader
in interfaceScriptManager
- Parameters:
ldr
- The loader instance to use
-
getScriptLoader
Get the current script loader to be used by this manager. If none is currently in use, null will be returned.- Specified by:
getScriptLoader
in interfaceScriptManager
- Returns:
- The current loader instance or null
-
shutdownActiveScripts
public void shutdownActiveScripts()The loader should now shutdown any scripts that have had their set_url events called.- Specified by:
shutdownActiveScripts
in interfaceScriptManager
-
shutdown
public void shutdown()Shutdown all scripts as the system is about to shutdown all of the current world and is starting again.- Specified by:
shutdown
in interfaceScriptManager
-
initializeScripts
public void initializeScripts(double timestamp) Initialise any newly loaded scripts and then put them into the completed basket.- Specified by:
initializeScripts
in interfaceScriptManager
- Parameters:
timestamp
- The VRML time that the initialization occurred at
-
prepareEvents
public 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.- Specified by:
prepareEvents
in interfaceScriptManager
- Parameters:
timestamp
- The current time in VRML time
-
processEvents
public 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.- Specified by:
processEvents
in interfaceScriptManager
-
eventsProcessed
public void eventsProcessed()Notification that all of the processing is finished and that eventsProcessed() should now be called.- Specified by:
eventsProcessed
in interfaceScriptManager
-
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.- Specified by:
removeScripts
in interfaceScriptManager
- Parameters:
list
- The list of scripts to remove
-
addScripts
Queue the scripts to add to the scene.- Specified by:
addScripts
in interfaceScriptManager
- Parameters:
list
- The list of script node instances to load
-
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.- Specified by:
getProcessedScripts
in interfaceScriptManager
- Parameters:
list
- The list to copy values into
-