Package org.web3d.vrml.scripting.browser
Class CommonBrowser
java.lang.Object
org.web3d.vrml.scripting.browser.CommonBrowser
- Direct Known Subclasses:
VRML97CommonBrowser
,X3DCommonBrowser
The common parts of a browser implementation that all the scripting
interfaces require.
This class is a partial implementation that is then extended for version-specific functionality. There are major functional differences between VRML97 and X3D and require that some methods be implemented differently. For example createVrmlFromURL is asynchronous in VRML97 by synchronous in X3D and therefore not implemented in this base class. Look to the derived classes for a complete implementation.
The current implementation ignores any parameter values provided by the world.
- Version:
- $Revision: 1.21 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BrowserCore
The basic browser core functionality that this script hooks toprotected org.j3d.util.ErrorReporter
The ErrorReporter for messagesprotected WorldLoaderManager
Loader manager for doing async loadsprotected RouteManager
Route manager for dealing with add/remove ROUTE methods.protected FrameStateManager
The frame state manager for nodes loaded by this class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CommonBrowser
(BrowserCore browser, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm) Create a browser instance that represents the given universe details. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRoute
(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, String fromEventOut, VRMLNodeType toNode, String toEventIn) Add a route between two nodes, from an eventOut to an eventIn.protected String[]
completeUrl
(String[] base) Insure that a url is a fully qualified URL.void
deleteRoute
(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, String fromEventOut, VRMLNodeType toNode, String toEventIn) Delete a route between two nodes.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.Get the description string currently used by the world.getName()
Get the name of the browser.Get the version of the browser.Get the fully qualified URL of the currently loaded world.void
Load the URL as the new root of the scene.void
setDescription
(String desc) Set the description of the current world.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the CommonBrowser instance so that any errors generated can be reported in a nice manner.
-
Field Details
-
core
The basic browser core functionality that this script hooks to -
routeManager
Route manager for dealing with add/remove ROUTE methods. -
loaderManager
Loader manager for doing async loads -
stateManager
The frame state manager for nodes loaded by this class -
errorReporter
protected org.j3d.util.ErrorReporter errorReporterThe ErrorReporter for messages
-
-
Constructor Details
-
CommonBrowser
protected CommonBrowser(BrowserCore browser, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm) Create a browser instance that represents the given universe details. If the scene builder or factory is null, then it will find one from the global pool defined for the renderer used by the browser core.- Parameters:
browser
- The core representation of the browserrm
- A route manager for users creating/removing routesfsm
- State manager for coordinating inter-frame processingwlm
- Loader manager for doing async calls- Throws:
IllegalArgumentException
- A parameter is null
-
-
Method Details
-
getDescription
Get the description string currently used by the world. Returns null if not set or supported.- Returns:
- The current description string or null
-
setDescription
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- Parameters:
desc
- The description string to set.
-
getName
Get the name of the browser. The name is an implementation specific string representing the browser.- Returns:
- The name of the browser or null if not supported
-
getVersion
Get the version of the browser. Returns an implementation specific representation of the version number.- Returns:
- The version of the browser or null if not supported
-
getCurrentSpeed
public float getCurrentSpeed()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.- Returns:
- The velocity in m/s or 0.0 if not supported
-
getCurrentFrameRate
public float getCurrentFrameRate()Get the current frame rate of the browser in frames per second.- Returns:
- The current frame rate or 0.0 if not supported
-
getWorldURL
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.- Returns:
- A string of the URL or null if not supported.
- See Also:
-
addRoute
public void addRoute(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, String fromEventOut, VRMLNodeType toNode, String toEventIn) throws InvalidFieldException 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.- Parameters:
execSpace
- The space that this route takes place infromNode
- The source node for the routefromEventOut
- The eventOut source of the routetoNode
- The destination node of the routetoEventIn
- The eventIn destination of the route- Throws:
InvalidFieldException
- the eventIn or eventOut name is not a field of the src/destination node
-
deleteRoute
public void deleteRoute(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, String fromEventOut, VRMLNodeType toNode, String toEventIn) throws InvalidFieldException Delete a route between two nodes. If the route does not exist, the method silently exits.- Parameters:
execSpace
- The space that this route takes place infromNode
- The source node for the routefromEventOut
- The eventOut source of the routetoNode
- The destination node of the routetoEventIn
- The eventIn destination of the route- Throws:
InvalidFieldException
- the eventIn or eventOut name is not a field of the src/destination node
-
loadURL
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.
- Parameters:
url
- The list of URLs in decreasing order of preference as defined in the VRML97 specification.parameters
- The list of parameters to accompany the load call as defined in the Anchor node specification of VRML97
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the CommonBrowser instance so that any errors generated can be reported in a nice manner.- Parameters:
reporter
- The new ErrorReporter to use.
-
completeUrl
-