Xj3D 2.0 VRML/X3D Code API

vrml
Class Browser

java.lang.Object
  extended by vrml.Browser

public class Browser
extends java.lang.Object

Java binding for the Browser object, which represents capabilities to create and manage content.

Version:
$Revision: 1.7 $
Author:
Alan Hudson

Constructor Summary
Browser()
           
 
Method Summary
 void addRoute(BaseNode fromNode, java.lang.String fromEventOut, BaseNode toNode, java.lang.String toEventIn)
          Add a route between two nodes, from an eventOut to an eventIn.
 BaseNode[] createVrmlFromString(java.lang.String vrmlSyntax)
          Parse the given string and turn this into a list of VRML nodes.
 void createVrmlFromURL(java.lang.String[] url, BaseNode node, java.lang.String event)
          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(BaseNode fromNode, java.lang.String fromEventOut, BaseNode 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.lang.String[] parameter)
          Load the URL as the new root of the scene.
 void replaceWorld(BaseNode[] nodes)
          Replace the current world with the given nodes.
 void setDescription(java.lang.String description)
          Set the description of the current world.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Browser

public Browser()
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

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[], String[]), replaceWorld(BaseNode[])

replaceWorld

public void replaceWorld(BaseNode[] nodes)
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:
nodes - The list of nodes to use as the new root of the world

createVrmlFromString

public BaseNode[] createVrmlFromString(java.lang.String vrmlSyntax)
                                throws InvalidVRMLSyntaxException
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.

Parameters:
vrmlSyntax - The string containing VRML string syntax
Returns:
A list of the top level nodes in VRML representation as defined in the parameter
Throws:
InvalidVRMLSyntaxException - If the string does not contain legal VRML syntax or no node instantiations

createVrmlFromURL

public void createVrmlFromURL(java.lang.String[] url,
                              BaseNode node,
                              java.lang.String event)
                       throws InvalidVRMLSyntaxException
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.

Parameters:
url - The list of URLs in decreasing order of preference as defined in the VRML97 specification.
node - The destination node for the VRML code to be sent to.
event - The name of the MFNode eventIn to send the nodes to.
Throws:
InvalidVRMLSyntaxException - If the string does not contain legal VRML syntax or no node instantiations

addRoute

public void addRoute(BaseNode fromNode,
                     java.lang.String fromEventOut,
                     BaseNode toNode,
                     java.lang.String toEventIn)
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:
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

deleteRoute

public void deleteRoute(BaseNode fromNode,
                        java.lang.String fromEventOut,
                        BaseNode toNode,
                        java.lang.String toEventIn)
Delete a route between two nodes. If the route does not exist, the method silently exits.

Parameters:
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

loadURL

public void loadURL(java.lang.String[] url,
                    java.lang.String[] parameter)
             throws InvalidVRMLSyntaxException
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.
parameter - The list of parameters to accompany the load call as defined in the Anchor node specification of VRML97
Throws:
InvalidVRMLSyntaxException - If the string does not contain legal VRML syntax or no node instantiations

setDescription

public void setDescription(java.lang.String description)
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:
description - The description string to set.

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium