Interface Browser
- All Known Subinterfaces:
ExternalBrowser
,Xj3DBrowser
- All Known Implementing Classes:
SAIBrowser
Individual VRML browser implementors are to extend this interface and provide this functionality. The individual users will not see anything but this interface.
A number of the methods in this application can take strings representing URLs. Relative URL strings contained in URL fields of nodes or these method arguments are interpreted as follows:
Relative URLs are treated as per clause B.3.5 of the EAI Java Bindings
- Version:
- $Revision: 1.15 $
- Author:
- Justin Couch
-
Method Summary
Modifier and TypeMethodDescriptioncreateScene
(ProfileInfo profile, ComponentInfo[] components) Create a new, empty scene that can be used to programmatically fill in new scenes.createX3DFromStream
(String fileParent, InputStream is) Parse the contents of the stream and interpret it as X3D content.createX3DFromString
(String x3dString) Parse the given string and turn this into a list of X3D nodes.createX3DFromURL
(String[] url) Create and load X3D from the given URL.void
Bind the first viewpoint in the list.void
firstViewpoint
(int layer) Bind the first viewpoint in the list.Get the collection of browser properties that the browser provides.getComponentInfo
(String name, int level) Get specific component info at the requested support level.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 of the current world.Get the information about the current scene.getName()
Get the name of the browser.getProfile
(String name) Get a specific profile.Get the collection of rendering properties that the browser provides.Get a listing of all the components that this browser implementation is capable of supporting.Get a listing of the profiles that this browser implementation is capable of supporting.Get the version of the browser.importDocument
(Node element) A utility request to import a W3C DOM document or document fragment and convert it to an X3D scene.void
Bind the last viewpoint in the list.void
lastViewpoint
(int layer) Bind the last viewpoint in the list.void
Load the URL as the new root of the scene.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
Print the message to the browser console without wrapping a new line onto it.void
Print the message to the browser console and append a new line onto it.void
replaceWorld
(X3DScene scene) Replace the current world with the given nodes.void
setDescription
(String desc) Set the description of the current world.
-
Method Details
-
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
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
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
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
getSupportedProfiles
Get a listing of the profiles that this browser implementation is capable of supporting.- Returns:
- The listing of all supported profiles
- Throws:
ConnectionException
- An error occurred in the connection to the browser.InvalidBrowserException
-
getProfile
Get a specific profile.- Parameters:
name
- The profile name- Returns:
- The specified profile
- Throws:
ConnectionException
- An error occurred in the connection to the browser.NotSupportedException
- The requested profile is not supportedInvalidBrowserException
-
getSupportedComponents
Get a listing of all the components that this browser implementation is capable of supporting.- Returns:
- The listing of all supported components
- Throws:
ConnectionException
- An error occurred in the connection to the browser.InvalidBrowserException
-
getComponentInfo
ComponentInfo getComponentInfo(String name, int level) throws InvalidBrowserException, NotSupportedException Get specific component info at the requested support level.- Parameters:
name
- The component namelevel
- The minimum component level- Returns:
- The specified component info
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.NotSupportedException
- The requested profile is not supported
-
getExecutionContext
Get the information about the current scene. If no scene has been set then this will return null.- Returns:
- The current scene data
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
createScene
X3DScene createScene(ProfileInfo profile, ComponentInfo[] components) throws InvalidBrowserException, IllegalArgumentException Create a new, empty scene that can be used to programmatically fill in new scenes. This scene has the give profile and/or component information set, and is not currently being rendered. Either argument may be null, but not both arguments. If the profile is null, then the default profile of "NONE" is used, and only the components are used. The scene version is set to the highest supported version of the specification that this browser currently implements.- Parameters:
profile
- The profile to use for this scene or null for nonecomponents
- The list of components to use or null- Returns:
- A new empty scene to work with
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.IllegalArgumentException
- Both arguments provided are null or zero length
-
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
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
getCurrentFrameRate
Get the current frame rate of the browser in frames per second.- Returns:
- The current frame rate or 0.0 if not supported
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
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 to render in the browser- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
loadURL
void loadURL(String[] url, Map<String, Object> parameters) throws InvalidBrowserException, InvalidURLExceptionLoad 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:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidURLException
- All of the URLs passed to this method are bogus and cannot be translated to usable valuesConnectionException
- An error occurred in the connection to the browser.
-
getDescription
Get the description of the current world.- Returns:
- A description string or null if none set
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
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.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
createX3DFromString
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 - either UTF8 or XML encoding. The X3D header line is not required to be present in the string if UTF8 syntax.
- Parameters:
x3dString
- The string containing VRML string syntax- Returns:
- The scene that was created from the string.
- Throws:
InvalidX3DException
- If the string does not contain legal X3D/VRML syntax or no node instantiationsInvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
createX3DFromStream
X3DScene createX3DFromStream(String fileParent, InputStream is) throws InvalidBrowserException, InvalidX3DException, IOException Parse the contents of the stream and interpret it as X3D content. The browser shall interpret the content using the initial characters of the stream to determine which encoding and file format is used.- Parameters:
fileParent
- the parent directory to form our base URLis
- The input stream that contains the content to parse- Returns:
- The scene that was created from the string.
- Throws:
InvalidX3DException
- If the string does not contain legal X3D/VRML syntax or no node instantiationsInvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.IOException
- An I/O Error occurred while reading the stream
-
createX3DFromURL
X3DScene createX3DFromURL(String[] url) throws InvalidBrowserException, InvalidURLException, InvalidX3DException Create and load X3D from the given URL. The call will not return until the basic top-level scene has been processed or an error has occurred. Inlines, textures, sound and externprotos are not guaranteed to be loaded at this time. If the caller needs to know what the final URL was that loaded, use the getWorldURL() call from the returned scene.- Parameters:
url
- The list of URLs in decreasing order of preference as defined in the VRML97/X3D specification.- Returns:
- The scene that was created from the URLs.
- Throws:
InvalidX3DException
- If the string does not contain legal X3D/VRML syntax or no node instantiationsInvalidBrowserException
- The dispose method has been called on this browser reference.InvalidURLException
- All of the URLs passed to this method are bogus and cannot be translated to usable valuesConnectionException
- An error occurred in the connection to the browser.
-
importDocument
X3DScene importDocument(Node element) throws InvalidBrowserException, InvalidDocumentException, NotSupportedException A utility request to import a W3C DOM document or document fragment and convert it to an X3D scene. The method only performs a conversion process and does not display the resulting scene. The scene may then be used as the argument for the replaceWorld service. When the conversion is made, there is no lasting connection between the DOM and the generated scene. Each request shall be a one-off conversion attempt (the conversion may not be successful if the DOM does not match the X3D scene graph structure).- Parameters:
element
- The root element to convert- Returns:
- A scene representation corresponding to the document
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.InvalidDocumentException
- The document structure cannot be converted to an X3D scene for some reasonNotSupportedException
-
print
Print the message to the browser console without wrapping a new line onto it.- Parameters:
msg
- The object to be printed- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
println
Print the message to the browser console and append a new line onto it.- Parameters:
msg
- The object to be printed- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Parameters:
layer
- index of the next viewpoint- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Parameters:
layer
- index of the previous viewpoint- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
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.- Parameters:
layer
- index of the first viewpoint- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
lastViewpoint
Bind the last viewpoint in the list.- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
lastViewpoint
Bind the last viewpoint in the list.- Parameters:
layer
- index of the last viewpoint- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
getRenderingProperties
Map<String,Object> getRenderingProperties() throws InvalidBrowserException, InvalidOperationTimingExceptionGet the collection of rendering properties that the browser provides. Rendering properties are key/value pairs, as defined in table 9.2 of ISO/IEC 19775-1. Keys are instances of Strings, while the value is dependent on the property. If the property is not defined in the returned map, treat it as not being supported by the browser.- Returns:
- A read-only map of the list of properties defined by the browser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.InvalidOperationTimingException
- This was not called during the correct timing during a script (may be called at any time from external)
-
getBrowserProperties
Map<String,Object> getBrowserProperties() throws InvalidBrowserException, InvalidOperationTimingExceptionGet the collection of browser properties that the browser provides. Rendering properties are key/value pairs, as defined in table 9.2 of ISO/IEC 19775-1. Keys are instances of Strings, while the value is dependent on the property. If the property is not defined in the returned map, treat it as not being supported by the browser.- Returns:
- A read-only map of the list of properties defined by the browser
- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.InvalidOperationTimingException
- This was not called during the correct timing during a script (may be called at any time from external)
-