Xj3D VRML/X3D Code API

org.web3d.vrml.scripting.browser
Class CommonBrowser

java.lang.Object
  extended byorg.web3d.vrml.scripting.browser.CommonBrowser
Direct Known Subclasses:
VRML97CommonBrowser, X3DCommonBrowser

public abstract class CommonBrowser
extends java.lang.Object

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.17 $
Author:
Justin Couch

Field Summary
protected  BrowserCore core
          The basic browser core functionality that this script hooks to
protected  ErrorReporter errorReporter
          The ErrorReporter for messages
protected  WorldLoaderManager loaderManager
          Loader manager for doing aysnc loads
protected  WorldLoaderThreadPool loaderPool
          Loader thread pool in use
protected  RouteManager routeManager
          Route manager for dealing with add/remove ROUTE methods.
protected  FrameStateManager stateManager
          The frame state manager for nodes loaded by this class
 
Constructor Summary
protected CommonBrowser(BrowserCore browser, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm)
          Create a browser instance that represents the given universe details.
 
Method Summary
 void addRoute(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, java.lang.String fromEventOut, VRMLNodeType toNode, java.lang.String toEventIn)
          Add a route between two nodes, from an eventOut to an eventIn.
protected  java.lang.String[] completeUrl(java.lang.String[] base)
          Insure that a url is a fully qualified URL.
 void deleteRoute(VRMLExecutionSpace execSpace, VRMLNodeType fromNode, java.lang.String fromEventOut, VRMLNodeType toNode, java.lang.String toEventIn)
          Delete a route between two nodes.
 float getCurrentFrameRate()
          Get the current frame rate of the browser in frames per second.
 float getCurrentSpeed()
          Get the current velocity of the bound viewpoint in meters per second.
 java.lang.String getDescription()
          Get the description string currently used by the world.
 java.lang.String getName()
          Get the name of the browser.
 java.lang.String getVersion()
          Get the version of the browser.
 java.lang.String getWorldURL()
          Get the fully qualified URL of the currently loaded world.
 void loadURL(java.lang.String[] url, java.util.Map parameters)
          Load the URL as the new root of the scene.
 void setDescription(java.lang.String desc)
          Set the description of the current world.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the CommonBrowser instance so that any errors generated can be reported in a nice manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

core

protected BrowserCore core
The basic browser core functionality that this script hooks to


routeManager

protected RouteManager routeManager
Route manager for dealing with add/remove ROUTE methods.


loaderManager

protected WorldLoaderManager loaderManager
Loader manager for doing aysnc loads


loaderPool

protected WorldLoaderThreadPool loaderPool
Loader thread pool in use


stateManager

protected FrameStateManager stateManager
The frame state manager for nodes loaded by this class


errorReporter

protected ErrorReporter errorReporter
The ErrorReporter for messages

Constructor Detail

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 browser
rm - A route manager for users creating/removing routes
wlm - Loader manager for doing async calls
fsm - State manager for coordinating inter-frame processing
Throws:
java.lang.IllegalArgumentException - A paramter is null
Method Detail

getDescription

public java.lang.String 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

public void setDescription(java.lang.String desc)
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

public java.lang.String 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

public java.lang.String 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

public java.lang.String 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 with loadURL then the string will reflect the new URL. If replaceWorld is called then the URL still represents the original world.

Returns:
A string of the URL or null if not supported.
See Also:
loadURL(String[], Map)

addRoute

public void addRoute(VRMLExecutionSpace execSpace,
                     VRMLNodeType fromNode,
                     java.lang.String fromEventOut,
                     VRMLNodeType toNode,
                     java.lang.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 in
fromNode - The source node for the route
fromEventOut - The eventOut source of the route
toNode - The destination node of the route
toEventIn - 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,
                        java.lang.String fromEventOut,
                        VRMLNodeType toNode,
                        java.lang.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 in
fromNode - The source node for the route
fromEventOut - The eventOut source of the route
toNode - The destination node of the route
toEventIn - The eventIn destination of the route
Throws:
InvalidFieldException - the eventIn or eventOut name is not a field of the src/destination node

loadURL

public void loadURL(java.lang.String[] url,
                    java.util.Map parameters)
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
Throws:
VRMLException - General error during processing

setErrorReporter

public void setErrorReporter(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

protected java.lang.String[] completeUrl(java.lang.String[] base)
Insure that a url is a fully qualified URL. Uses the core.worldURL or the local user directory if nothing is loaded.

Parameters:
base - The base url
Returns:
A fully qualified URL

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium