Package org.xj3d.impl.core.loading
Class DefaultWorldLoaderManager
java.lang.Object
org.xj3d.impl.core.loading.DefaultWorldLoaderManager
- All Implemented Interfaces:
BrowserCoreListener
,WorldLoaderManager
public class DefaultWorldLoaderManager
extends Object
implements WorldLoaderManager, BrowserCoreListener
Independent thread used to load a world from a list of URLs and then
place it in the given node.
This implementation is designed to work as both a loadURL() and createVrmlFromUrl() call handler. The difference is defined by what data is supplied to the thread. If the target vrmlNodeType is specified, then we assume that the caller wants us to put the results there. If it is null, then assume that we're doing a loadURL call and replace the entire world.
- Version:
- $Revision: 1.7 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultWorldLoaderManager
(BrowserCore core, FrameStateManager fsm, RouteManager rm) Construct a new instance of the world loader that uses the given frame state manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
The browser has been disposed, all resources may be freed.void
browserInitialized
(VRMLScene scene) The browser has been initialised with new content.void
The browser has been shut down and the previous content is no longer valid.Fetch a world loader instance from the global pool to work on loading of a world.getBuilderFactory
(int renderer) Get the factory for the given renderer type.int
Return the number of WorldLoaders that are currently allocated from the pool and active loading.getParserFactory
(int renderer) Get the factory for the given renderer type.void
queueCreateURL
(String[] urls, VRMLNodeType node, int field, VRMLExecutionSpace space) Queue a request for a loadURL call.void
queueLoadURL
(String[] urls, Map<String, Object> params) Queue a request for a loadURL call.void
registerBuilderFactory
(int renderer, SceneBuilderFactory factory) Register the scene builder factory to be used for the given renderer type.void
registerParserFactory
(int renderer, VRMLParserFactory factory) Register the parser factory to be used for the given renderer type.void
releaseLoader
(WorldLoader loader) Release a currently used world loader back into the cache for others to make use of.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
setProgressListener
(org.ietf.uri.event.ProgressListener listener) Register a progress listener with the engine so progress can be tracked.void
urlLoadFailed
(String msg) The tried to load a URL and failed.
-
Constructor Details
-
DefaultWorldLoaderManager
Construct a new instance of the world loader that uses the given frame state manager.- Parameters:
core
- The browserCore of the browser for fetching info fromfsm
- The state manager for this loader to userm
-
-
-
Method Details
-
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 interfaceWorldLoaderManager
- Parameters:
reporter
- The instance to use or null
-
setProgressListener
public void setProgressListener(org.ietf.uri.event.ProgressListener listener) Register a progress listener with the engine so progress can be tracked. Only loadURL calls will issue progress, not createURL.- Specified by:
setProgressListener
in interfaceWorldLoaderManager
- Parameters:
listener
- The instance to use or null
-
queueLoadURL
Queue a request for a loadURL call.- Specified by:
queueLoadURL
in interfaceWorldLoaderManager
- Parameters:
urls
- List of urls to loadparams
- The parameters to accompany the URLs
-
queueCreateURL
Queue a request for a loadURL call.- Specified by:
queueCreateURL
in interfaceWorldLoaderManager
- Parameters:
urls
- List of urls to loadnode
- The vrmlNodeType to send the values tofield
- index of the field to write tospace
- The executionSpace the script is in for route adding
-
fetchLoader
Fetch a world loader instance from the global pool to work on loading of a world.- Specified by:
fetchLoader
in interfaceWorldLoaderManager
- Returns:
- A loader instance to use
-
releaseLoader
Release a currently used world loader back into the cache for others to make use of.- Specified by:
releaseLoader
in interfaceWorldLoaderManager
- Parameters:
loader
- The instance to return
-
registerBuilderFactory
Register the scene builder factory to be used for the given renderer type. There can only be one for any given renderer type (where the type value is defined by the constants inBrowserCore
. If the factory instance is null, it will clear the factory for the given renderer type from the map.- Specified by:
registerBuilderFactory
in interfaceWorldLoaderManager
- Parameters:
renderer
- The ID of the renderer typefactory
- The instance of the factory to use
-
getBuilderFactory
Get the factory for the given renderer type. If no factory exists return null.- Specified by:
getBuilderFactory
in interfaceWorldLoaderManager
- Parameters:
renderer
- The ID of the renderer type- Returns:
- The instance of the factory or null
-
registerParserFactory
Register the parser factory to be used for the given renderer type. There can only be one for any given renderer type (where the type value is defined by the constants inBrowserCore
. If the factory instance is null, it will clear the factory for the given renderer type from the map.- Specified by:
registerParserFactory
in interfaceWorldLoaderManager
- Parameters:
renderer
- The ID of the renderer typefactory
- The instance of the factory to use
-
getParserFactory
Get the factory for the given renderer type. If no factory exists return null.- Specified by:
getParserFactory
in interfaceWorldLoaderManager
- Parameters:
renderer
- The ID of the renderer type- Returns:
- The instance of the factory or null
-
getNumberLoadersActive
public int getNumberLoadersActive()Return the number of WorldLoaders that are currently allocated from the pool and active loading.- Specified by:
getNumberLoadersActive
in interfaceWorldLoaderManager
- Returns:
- The number of WorldLoaders currently active.
-
browserInitialized
The browser has been initialised with new content. The content given is found in the accompanying scene and description.- Specified by:
browserInitialized
in interfaceBrowserCoreListener
- Parameters:
scene
- The scene of the new content
-
urlLoadFailed
The tried to load a URL and failed. It is typically because none of the URLs resolved to anything valid or there were network failures.- Specified by:
urlLoadFailed
in interfaceBrowserCoreListener
- Parameters:
msg
- An error message to go with the failure
-
browserShutdown
public void browserShutdown()The browser has been shut down and the previous content is no longer valid.- Specified by:
browserShutdown
in interfaceBrowserCoreListener
-
browserDisposed
public void browserDisposed()The browser has been disposed, all resources may be freed.- Specified by:
browserDisposed
in interfaceBrowserCoreListener
-