Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.scripting.browser
Class X3DCommonBrowser

java.lang.Object
  extended by org.web3d.vrml.scripting.browser.CommonBrowser
      extended by org.web3d.vrml.scripting.browser.X3DCommonBrowser

public class X3DCommonBrowser
extends CommonBrowser

The common parts of a browser implementation suitable for X3D scripting.

This class is a full implementation because the external and scripting interfaces will use it differently. External use can just subclass and add the SAI Browser interface. For scripting, the need to extend the Browser base class means that this class will need to be delegated to.

The current implementation ignores any parameter values provided by the world.

Version:
$Revision: 1.24 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.web3d.vrml.scripting.browser.CommonBrowser
core, errorReporter, loaderManager, routeManager, stateManager
 
Constructor Summary
X3DCommonBrowser(BrowserCore browser, ViewpointManager vpm, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm)
          Create a browser instance that represents the given universe details.
 
Method Summary
 VRMLScene createX3DFromStream(java.io.InputStream stream)
          Parse the given input stream and turn this into a list of X3D nodes.
 VRMLScene createX3DFromString(java.lang.String x3dSyntax)
          Parse the given string and turn this into a list of X3D nodes.
 VRMLScene createX3DFromURL(java.lang.String[] urls)
          Create and load X3D from the given URL and place the returned values as nodes into the given X3D node in the scene.
 void firstViewpoint()
          Bind the first viewpoint in the list.
 void firstViewpoint(int layer)
          Bind the first viewpoint in the list.
 ViewpointManager getViewpointManager()
          Get the contained viewpoint manager instance.
 VRMLScene importDocument(org.w3c.dom.Node domNode)
          Implementation of the importDocument optional capabilities.
 void lastViewpoint()
          Bind the last viewpoint in the list.
 void lastViewpoint(int layer)
          Bind the last viewpoint in the list.
 void nextViewpoint()
          Bind the next viewpoint in the list.
 void nextViewpoint(int layer)
          Bind the next viewpoint in the list.
 void previousViewpoint()
          Bind the previous viewpoint in the list.
 void previousViewpoint(int layer)
          Bind the previous viewpoint in the list.
 void replaceWorld(VRMLScene scene)
          Replace the current world with the given nodes.
 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 org.web3d.vrml.scripting.browser.CommonBrowser
addRoute, completeUrl, deleteRoute, getCurrentFrameRate, getCurrentSpeed, getDescription, getName, getVersion, getWorldURL, loadURL, setDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

X3DCommonBrowser

public X3DCommonBrowser(BrowserCore browser,
                        ViewpointManager vpm,
                        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
vpm - The manager for viewpoints
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

getViewpointManager

public ViewpointManager getViewpointManager()
Get the contained viewpoint manager instance. This may be used for more precise control of the viewpoint handling than the basic interface provided by this class.


replaceWorld

public void replaceWorld(VRMLScene scene)
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.

Parameters:
scene - The new scene instance to use

createX3DFromStream

public VRMLScene createX3DFromStream(java.io.InputStream stream)
                              throws VRMLException,
                                     VRMLParseException,
                                     java.io.IOException
Parse the given input stream and turn this into a list of X3D 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 stream may contain all legal X3D syntax. The X3D header line is not required to be present in the string.

Parameters:
stream - The stream containing VRML string syntax
Returns:
The scene that was generated from the syntax
Throws:
VRMLException - General error during processing
VRMLParseException - If the string does not contain legal VRML syntax or no node instantiations
java.io.IOException

createX3DFromString

public VRMLScene createX3DFromString(java.lang.String x3dSyntax)
                              throws VRMLException,
                                     VRMLParseException,
                                     java.io.IOException
Parse the given string and turn this into a list of X3D 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 X3D syntax. The X3D header line is not required to be present in the string.

Parameters:
x3dSyntax - The string containing X3D string syntax
Returns:
The scene that was generated from the syntax
Throws:
VRMLException - General error during processing
VRMLParseException - If the string does not contain legal VRML syntax or no node instantiations
java.io.IOException

createX3DFromURL

public VRMLScene createX3DFromURL(java.lang.String[] urls)
Create and load X3D from the given URL and place the returned values as nodes into the given X3D 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.

Parameters:
urls - The list of URLs in decreasing order of preference as defined in the X3D specification.

importDocument

public VRMLScene importDocument(org.w3c.dom.Node domNode)
                         throws NotSupportedException
Implementation of the importDocument optional capabilities.

Throws:
NotSupportedException

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.

Overrides:
setErrorReporter in class CommonBrowser
Parameters:
reporter - The new ErrorReporter to use.

nextViewpoint

public void nextViewpoint()
Bind the next viewpoint in the list. The definition of "next" is not specified, and may be browser dependent. If only one viewpoint is declared, this method does nothing.


nextViewpoint

public void nextViewpoint(int layer)
Bind the next viewpoint in the list. The definition of "next" is not specified, and may be browser dependent. If only one viewpoint is declared, this method does nothing.

Parameters:
layer - The ID of the layer. Must be between 0 and the maximum layer number

previousViewpoint

public void previousViewpoint()
Bind the previous viewpoint in the list. The definition of "previous" is not specified, and may be browser dependent. If only one viewpoint is declared, this method does nothing.


previousViewpoint

public void previousViewpoint(int layer)
Bind the previous viewpoint in the list. The definition of "previous" is not specified, and may be browser dependent. If only one viewpoint is declared, this method does nothing.

Parameters:
layer - The ID of the layer. Must be between 0 and the maximum layer number

firstViewpoint

public void firstViewpoint()
Bind the first viewpoint in the list. This is the first viewpoint declared in the user's file. ie The viewpoint that would be bound by default on loading.


firstViewpoint

public void firstViewpoint(int layer)
Bind the first viewpoint in the list. This is the first viewpoint declared in the user's file. ie The viewpoint that would be bound by default on loading.

Parameters:
layer - The ID of the layer. Must be between 0 and the maximum layer number

lastViewpoint

public void lastViewpoint()
Bind the last viewpoint in the list.


lastViewpoint

public void lastViewpoint(int layer)
Bind the last viewpoint in the list.

Parameters:
layer - The ID of the layer. Must be between 0 and the maximum layer number

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium