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 TypeMethodDescriptionvoidaddScripts(NodeArray list) Queue the scripts to add to the scene.voidNotification that all of the processing is finished and that eventsProcessed() should now be called.voidgetProcessedScripts(NodeArray list) Copy all the processed scripts to date into the given list.Get the current script loader to be used by this manager.voidinitializeScripts(double timestamp) Initialise any newly loaded scripts and then put them into the completed basket.voidloadCompleted(VRMLScriptNodeType script) Notification of a successful load of a script.voidloadFailed(VRMLScriptNodeType script) Notification of a failed load of a script when none of the URLs could be loaded.voidprepareEvents(double timestamp) Setup the scripts for the new timestamp.voidProcess any events that scripts need to send.voidremoveScripts(NodeArray list) Remove this list of scripts from active service.voidsetErrorReporter(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.voidSet the script loader to be used by this manager.voidshutdown()Shutdown all scripts as the system is about to shutdown all of the current world and is starting again.voidThe loader should now shutdown any scripts that have had their set_url events called.voidurlChanged(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:
urlChangedin 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:
loadCompletedin 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:
loadFailedin 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:
setErrorReporterin 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:
setScriptLoaderin 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:
getScriptLoaderin 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:
shutdownActiveScriptsin 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:
shutdownin interfaceScriptManager
-
initializeScripts
public void initializeScripts(double timestamp) Initialise any newly loaded scripts and then put them into the completed basket.- Specified by:
initializeScriptsin 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:
prepareEventsin 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:
processEventsin interfaceScriptManager
-
eventsProcessed
public void eventsProcessed()Notification that all of the processing is finished and that eventsProcessed() should now be called.- Specified by:
eventsProcessedin 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:
removeScriptsin interfaceScriptManager- Parameters:
list- The list of scripts to remove
-
addScripts
Queue the scripts to add to the scene.- Specified by:
addScriptsin 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:
getProcessedScriptsin interfaceScriptManager- Parameters:
list- The list to copy values into
-