Class X3DCommonBrowser
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.25 $
- Author:
- Justin Couch
-
Field Summary
Fields inherited from class org.web3d.vrml.scripting.browser.CommonBrowser
core, errorReporter, loaderManager, routeManager, stateManager
-
Constructor Summary
ConstructorsConstructorDescriptionX3DCommonBrowser
(BrowserCore browser, ViewpointManager vpm, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm) Create a browser instance that represents the given universe details. -
Method Summary
Modifier and TypeMethodDescriptioncreateX3DFromStream
(String fileParent, InputStream stream) Parse the given input stream and turn this into a list of X3D nodes.createX3DFromString
(String x3dSyntax) Parse the given string and turn this into a list of X3D nodes.createX3DFromURL
(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
Bind the first viewpoint in the list.void
firstViewpoint
(int layer) Bind the first viewpoint in the list.Get the contained viewpoint manager instance.importDocument
(Node domNode) Implementation of the importDocument optional capabilities.void
Bind the last viewpoint in the list.void
lastViewpoint
(int layer) Bind the last viewpoint in the list.void
Bind the next viewpoint in the list.void
nextViewpoint
(int layer) Bind the next viewpoint in the list.void
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
(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.Methods inherited from class org.web3d.vrml.scripting.browser.CommonBrowser
addRoute, completeUrl, deleteRoute, getCurrentFrameRate, getCurrentSpeed, getDescription, getName, getVersion, getWorldURL, loadURL, setDescription
-
Constructor Details
-
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 browservpm
- The manager for viewpointsrm
- 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
-
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.- Returns:
- the contained viewpoint manager instance
-
replaceWorld
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(String fileParent, InputStream stream) throws VRMLException, VRMLParseException, 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:
fileParent
- the parent directory to form our base URLstream
- The stream containing VRML string syntax- Returns:
- The scene that was generated from the syntax
- Throws:
VRMLException
- General error during processingVRMLParseException
- If the string does not contain legal VRML syntax or no node instantiationsIOException
-
createX3DFromString
public VRMLScene createX3DFromString(String x3dSyntax) throws VRMLException, VRMLParseException, 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 processingVRMLParseException
- If the string does not contain legal VRML syntax or no node instantiationsIOException
-
createX3DFromURL
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- Returns:
- a VRMLScene reference
-
importDocument
Implementation of the importDocument optional capabilities.- Parameters:
domNode
-- Returns:
- Throws:
NotSupportedException
-
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.- Overrides:
setErrorReporter
in classCommonBrowser
- 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
-