Class EAIBrowser
- All Implemented Interfaces:
BrowserCoreListener
,Browser
Browser
interface, largely by
translating and interfacing between the wrapper classes and the
implementation class represented by {org.web3d.vrml.scripting.CommonBrowser}.
To function correctly, EAIBrowser needs to be constructed using CommonBrowser and BrowserCore instances. The EAIBrowser then registers as a listener so that BrowserCoreListener BrowserInitialized and browserShutdown messages. The BrowserCore instance is necessary mainly for the global namespace and VRMLExecutionSpace information.
- Version:
- $Revision: 1.18 $
- Author:
- Brad Vender
-
Constructor Summary
ConstructorsConstructorDescriptionEAIBrowser
(BrowserCore browserCore, VRML97CommonBrowser browserImpl, ExternalEventQueue eventQueue, org.j3d.util.ErrorReporter reporter) Construct an EAIBrowser for the given VrmlDisplayPanel -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBrowserListener
(BrowserListener theListener) addBrowserListener adds the specified listener to the set of listeners for this browser.void
Add a route between two nodes, from an eventOut to an eventIn.void
Lock the output from the external interface to the browser as the code is about to begin a series of updates.void
The browser has been disposed, all resources may be freed.void
browserInitialized
(VRMLScene newScene) The browser has been initialised with new content.void
The browser has been shut down and the previous content is no longer valid.Node[]
createVrmlFromString
(String string) Parse the given string and turn this into a list of VRML nodes.void
createVrmlFromURL
(String[] urls, Node targetNode, String eventInName) Create and load VRML from the given URL and place the returned values as nodes into the given VRML node in the scene.void
deleteRoute
(Node fromNode, String fromEventName, Node toNode, String toEventName) Delete a route between two nodes.void
dispose()
Clean up and get rid of this browser.void
Release the output of events from the external interface into the VRML browser.float
Get the current frame rate of the browser in frames per second.float
Get the current velocity of the bound viewpoint in meters per second.getName()
Returns the name of the Browser.Get a DEF node by name.Returns the version string for this Browser.Get the fully qualified URL of the currently loaded world.void
Initialize the world to a known and default state.void
Load the URL as the new root of the scene.void
removeBrowserListener
(BrowserListener listener) removeBrowserListener removes the specified listener from the set of listeners for this browser.void
replaceWorld
(Node[] nodes) Replace the current world with the given nodes.void
setDescription
(String newDescription) Set the description of the current world.void
urlLoadFailed
(String msg) The tried to load a URL and failed.
-
Constructor Details
-
EAIBrowser
public EAIBrowser(BrowserCore browserCore, VRML97CommonBrowser browserImpl, ExternalEventQueue eventQueue, org.j3d.util.ErrorReporter reporter) Construct an EAIBrowser for the given VrmlDisplayPanel- Parameters:
browserCore
- The BrowserCore to use as the implementation.browserImpl
- The VRML97CommonBrowser to use.eventQueue
- The queue for sending events to the internals.reporter
- The ErrorReporter for messages and errors.
-
-
Method Details
-
getName
Returns the name of the Browser.- Specified by:
getName
in interfaceBrowser
- Returns:
- The name of the Browser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
getVersion
Returns the version string for this Browser.- Specified by:
getVersion
in interfaceBrowser
- Returns:
- The version string for this Browser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
getCurrentSpeed
Description copied from interface:Browser
Get the current velocity of the bound viewpoint in meters per second. The velocity is defined in terms of the world values, not the local coordinate system of the viewpoint.- Specified by:
getCurrentSpeed
in interfaceBrowser
- Returns:
- The velocity in m/s or 0.0 if not supported
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
getCurrentFrameRate
Description copied from interface:Browser
Get the current frame rate of the browser in frames per second.- Specified by:
getCurrentFrameRate
in interfaceBrowser
- Returns:
- The current frame rate or 0.0 if not supported
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
getWorldURL
Description copied from interface:Browser
Get the fully qualified URL of the currently loaded world. This returns the entire URL including any possible arguments that might be associated with a CGI call or similar mechanism. If the initial world is replaced withloadURL
then the string will reflect the new URL. IfreplaceWorld
is called then the URL still represents the original world.- Specified by:
getWorldURL
in interfaceBrowser
- Returns:
- A string of the URL or null if not supported.
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.URLUnavailableException
- The URL is not available because a world has not been loaded- See Also:
-
replaceWorld
Description copied from interface:Browser
Replace the current world with the given nodes. Replaces the entire contents of the VRML world with the new nodes. Any node references that belonged to the previous world are still valid but no longer form part of the scene graph (unless it is these nodes passed to this method). The URL of the world still represents the just unloaded world.Calling this method causes a SHUTDOWN event followed by an INITIALIZED event to be generated.
- Specified by:
replaceWorld
in interfaceBrowser
- Parameters:
nodes
- The list of nodes to use as the new root of the world- Throws:
IllegalArgumentException
- if the nodes are not valid VRML nodesInvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
loadURL
public void loadURL(String[] urls, String[] params) throws InvalidBrowserException, InvalidURLException Description copied from interface:Browser
Load the URL as the new root of the scene. Replaces all the current scene graph with the new world. A non-blocking call that will change the contents at some time in the future.Generates an immediate SHUTDOWN event and then when the new contents are ready to be loaded, sends an INITIALIZED event.
- Specified by:
loadURL
in interfaceBrowser
- Parameters:
urls
- The list of URLs in decreasing order of preference as defined in the VRML97 specification.params
- The list of parameters to accompany the load call as defined in the Anchor node specification of VRML97- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidURLException
- All of the URLs passed to this method are bogus and cannot be translated to usable values
-
setDescription
Description copied from interface:Browser
Set the description of the current world. If the world is operating as part of a web browser then it shall attempt to set the title of the window. If the browser is from a component then the result is dependent on the implementation- Specified by:
setDescription
in interfaceBrowser
- Parameters:
newDescription
- The description string to set.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
createVrmlFromString
public Node[] createVrmlFromString(String string) throws InvalidBrowserException, InvalidVrmlException Description copied from interface:Browser
Parse the given string and turn this into a list of VRML nodes. Method is a blocking call that won't return until all of the top level nodes defined in the string have been returned.At the point that this method returns, external files such as textures, sounds and inlines may not have been loaded.
The string may contain all legal VRML syntax. The VRML header line is not required to be present in the string.
- Specified by:
createVrmlFromString
in interfaceBrowser
- Parameters:
string
- The string containing VRML string syntax- Returns:
- A list of the top level nodes in VRML representation as defined in the parameter
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidVrmlException
- If the string does not contain legal VRML syntax or no node instantiations
-
createVrmlFromURL
public void createVrmlFromURL(String[] urls, Node targetNode, String eventInName) throws InvalidBrowserException, InvalidNodeException, InvalidURLException, InvalidEventInException Description copied from interface:Browser
Create and load VRML from the given URL and place the returned values as nodes into the given VRML node in the scene. The difference between this and loadURL is that this method does not replace the entire scene with the contents from the URL. Instead, it places the return values as events in the nominated node and MFNode eventIn.- Specified by:
createVrmlFromURL
in interfaceBrowser
- Parameters:
urls
- The list of URLs in decreasing order of preference as defined in the VRML97 specification.targetNode
- The destination node for the VRML code to be sent to.eventInName
- The name of the MFNode eventIn to send the nodes to.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidNodeException
- The nominated destination node has been disposed ofInvalidURLException
- All of the URLs passed to this method are bogus and cannot be translated to usable valuesInvalidEventInException
-
getNode
public Node getNode(String nodeName) throws InvalidNodeException, InvalidBrowserException, URLUnavailableException Description copied from interface:Browser
Get a DEF node by name. Nodes given DEF names in the root scene graph are available to be retrieved by this method. DEFed nodes in Inlines, createVrmlFromString and createVrmlFromURL are not available.- Specified by:
getNode
in interfaceBrowser
- Parameters:
nodeName
- The name of the DEF node to retrieve- Returns:
- A reference to that node
- Throws:
InvalidNodeException
- The named node does not exist or is not accessible.InvalidBrowserException
- The dispose method has been called on this browser reference.URLUnavailableException
- The URL is not available because a world has not been loaded
-
addRoute
public void addRoute(Node fromNode, String fromEventName, Node toNode, String toEventName) throws InvalidBrowserException, InvalidEventOutException, InvalidEventInException, InvalidNodeException Description copied from interface:Browser
Add a route between two nodes, from an eventOut to an eventIn. If the ROUTE already exists, this method silently exits. It does not attempt to add a second parallel ROUTE.- Specified by:
addRoute
in interfaceBrowser
- Parameters:
fromNode
- The source node for the routefromEventName
- The eventOut source of the routetoNode
- The destination node of the routetoEventName
- The eventIn destination of the route- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidEventOutException
- if the named eventOut does not existInvalidEventInException
- if the named eventIn does not exist.InvalidNodeException
- The nominated destination or source node has been disposed of
-
deleteRoute
public void deleteRoute(Node fromNode, String fromEventName, Node toNode, String toEventName) throws InvalidBrowserException, InvalidEventOutException, InvalidEventInException, InvalidNodeException Description copied from interface:Browser
Delete a route between two nodes. If the route does not exist, the method silently exits.- Specified by:
deleteRoute
in interfaceBrowser
- Parameters:
fromNode
- The source node for the routefromEventName
- The eventOut source of the routetoNode
- The destination node of the routetoEventName
- The eventIn destination of the route- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidEventOutException
- if the named eventOut does not existInvalidEventInException
- if the named eventIn does not exist.InvalidNodeException
- The nominated destination or source node has been disposed of
-
beginUpdate
Description copied from interface:Browser
Lock the output from the external interface to the browser as the code is about to begin a series of updates. No events will be passed to the VRML world. They will be buffered pending release due to a subsequent call to endUpdate.This call is a nesting call which means subsequent calls to beginUpdate are kept on a stack. No events will be released to the VRML browser until as many endUpdates have been called as beginUpdate.
- Specified by:
beginUpdate
in interfaceBrowser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
endUpdate
Description copied from interface:Browser
Release the output of events from the external interface into the VRML browser. All events posted to this point from the last time that beginUpdate was called are released into the VRML browser for processing at the next available opportunity.This call is a nesting call which means subsequent calls to beginUpdate are kept on a stack. No events will be released to the VRML browser until as many endUpdates have been called as beginUpdate.
If no beginUpdate has been called before calling this method, it has no effect.
- Specified by:
endUpdate
in interfaceBrowser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.- See Also:
-
addBrowserListener
addBrowserListener adds the specified listener to the set of listeners for this browser.- Specified by:
addBrowserListener
in interfaceBrowser
- Parameters:
theListener
- The listener to add to the list of listeners for this browser- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
removeBrowserListener
removeBrowserListener removes the specified listener from the set of listeners for this browser.- Specified by:
removeBrowserListener
in interfaceBrowser
- Parameters:
listener
- The listener to remove from the list.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
browserInitialized
Description copied from interface:BrowserCoreListener
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:
newScene
- 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()Description copied from interface:BrowserCoreListener
The browser has been shut down and the previous content is no longer valid.- Specified by:
browserShutdown
in interfaceBrowserCoreListener
- See Also:
-
browserDisposed
public void browserDisposed()The browser has been disposed, all resources may be freed.- Specified by:
browserDisposed
in interfaceBrowserCoreListener
-
dispose
public void dispose()Clean up and get rid of this browser. When this method is called, the event queue will be processed, the browser will shut down, and any subsequent calls to browser methods (except getName() and getVersion()) will result in InvalidBrowserException's being generated.Since this version does not support sharing between clients, shutdown also initiates the termination of the Xj3D to EAI event adapter system.
-
initializeWorld
public void initializeWorld()Initialize the world to a known and default state. The initialization is done so that the event model and other internals of the system will be functioning, and to prevent special cases in the various event buffering routines. Since the event buffering routines are assumed to not be functioning, this method calls down to the VRML97CommonBrowser directly.
-