Xj3D VRML/X3D Code API

org.web3d.vrml.lang
Interface BasicScene

All Known Subinterfaces:
VRMLScene
All Known Implementing Classes:
AbstractScene, CRVRMLScene, SAIVRMLScene

public interface BasicScene

Abstract representation of a contained scene graph.

The scene returns lists of nodes of the given type. This list contains all of the nodes of that type in the order that they are declared in the incoming stream. As the scene changes due to scripting and external interactions, it will add new instances of these nodes to the end of the list. If there is none of the given node types, the methods shall return empty lists.

Version:
$Revision: 1.18 $
Author:
Justin Couch

Method Summary
 void addNode(VRMLNode node)
          Add a node to this scene.
 void addTemplate(VRMLNodeTemplate template)
          Add a new template to this scene.
 java.util.ArrayList getByPrimaryType(int type)
          Get the list of nodes of the given primary type declared in this scene.
 java.util.ArrayList getBySecondaryType(int type)
          Get the list of nodes of the given secondary type declared in this scene.
 java.util.Map getDEFNodes()
          Get a list of the nodes that have been named with DEF in this scene.
 java.util.Map getImports()
          Get the IMPORT declaration information from this scene.
 java.lang.String getLoadedURI()
          Get the URI of the world that this scene represents.
 SceneMetaData getMetaData()
          Get the meta data associated with this scene.
 VRMLNodeFactory getNodeFactory()
          Get the node factory that represents the setup of this scene.
 VRMLNodeTemplate getNodeTemplate(java.lang.String name)
          Get the proto defined by the name.
 java.util.ArrayList getNodeTemplates()
          Get the list of top-level node templates declared in this scene.
 VRMLNode getRootNode()
          Get the node that forms the root of this proto body.
 java.util.ArrayList getRoutes()
          Get the list of ROUTEs declared in this scene.
 int getSpecificationMajorVersion()
          Get the specification major version that this scene belongs to.
 int getSpecificationMinorVersion()
          Get the specification minor version that this scene belongs to.
 java.lang.String getWorldRootURL()
          Get the Root URL of the world that this scene represents.
 void removeNode(VRMLNode node)
          Remove a node from this scene.
 void removeTemplate(VRMLNodeTemplate template)
          Remove a template from this scene.
 void setNodeFactory(VRMLNodeFactory fac)
          Set the node factory instance to be used with this scene.
 

Method Detail

getMetaData

public SceneMetaData getMetaData()
Get the meta data associated with this scene. A scene should always have some amount of metadata.

Returns:
The current meta data

getRootNode

public VRMLNode getRootNode()
Get the node that forms the root of this proto body. The body will contain the renderable scene graph as the first item of the node and all other children as the non-renderable parts, as per the VRML spec.

Returns:
A reference to the root node of the scene

getWorldRootURL

public java.lang.String getWorldRootURL()
Get the Root URL of the world that this scene represents. This is the URL minus the file name, but including any directory information.

Returns:
The full URL of the world's location

getLoadedURI

public java.lang.String getLoadedURI()
Get the URI of the world that this scene represents. Returns null for dynamically created worlds.

Returns:
The full URI of the world's location

getNodeFactory

public VRMLNodeFactory getNodeFactory()
Get the node factory that represents the setup of this scene. Provided so that a caller can make use of the factory to create nodes that are only valid as part of the initial setup of this scene.

Returns:
The VRMLNodeFactory instance configured to represent this scene

setNodeFactory

public void setNodeFactory(VRMLNodeFactory fac)
                    throws java.lang.IllegalArgumentException,
                           java.lang.IllegalStateException
Set the node factory instance to be used with this scene. This is a one-shot call. After it has been set, it cannot be changed. An exception will be thrown.

Parameters:
fac - The factory instance to use
Throws:
java.lang.IllegalArgumentException - The factory instance provided was null
java.lang.IllegalStateException - A factory has already been set

getSpecificationMajorVersion

public int getSpecificationMajorVersion()
Get the specification major version that this scene belongs to.

Returns:
The major version number

getSpecificationMinorVersion

public int getSpecificationMinorVersion()
Get the specification minor version that this scene belongs to.

Returns:
The minor version number

addNode

public void addNode(VRMLNode node)
Add a node to this scene. This is a single node instance and the implementation is not required to traverse this node for all its children and sort them as well. It is expected external code shall be handling the tree traversal. The code will make sure that this node instance is only inserted into the internal structures exactly once, even if this is a duplicate call.

Parameters:
node - The node to add

removeNode

public void removeNode(VRMLNode node)
Remove a node from this scene. The implementation shall silently ignore a request to remove a node that does not exist in this scene.

Parameters:
node - The node to add

addTemplate

public void addTemplate(VRMLNodeTemplate template)
Add a new template to this scene. Each template is assumed to be independent of the others. If a template contains further templates, the nested instances should not be added to this scene.

Parameters:
template - The new template instance to use

removeTemplate

public void removeTemplate(VRMLNodeTemplate template)
Remove a template from this scene. The implementation shall silently ignore a request to remove a template that does not exist in this scene. If instances of this template already exist, they shall remain in the scene.

Parameters:
template - The template instance to remove

getRoutes

public java.util.ArrayList getRoutes()
Get the list of ROUTEs declared in this scene.

Returns:
The list of ROUTE instances in this scene

getNodeTemplates

public java.util.ArrayList getNodeTemplates()
Get the list of top-level node templates declared in this scene. The list will not be sorted into separate sets of PROTO and EXTERNPROTO instances.

Returns:
The list of VRMLNodeTemplate instances in this scene

getByPrimaryType

public java.util.ArrayList getByPrimaryType(int type)
Get the list of nodes of the given primary type declared in this scene. Proto instances may be fetched through this method too as they have a primary type of ProtoInstance.

Returns:
The list of node instances in this scene.

getBySecondaryType

public java.util.ArrayList getBySecondaryType(int type)
Get the list of nodes of the given secondary type declared in this scene.

Returns:
The list of node instances in this scene.

getNodeTemplate

public VRMLNodeTemplate getNodeTemplate(java.lang.String name)
Get the proto defined by the name. If no proto is known by that name then return null.

Parameters:
name - The name of the proto to fetch.
Returns:
The proto known by that name or null

getDEFNodes

public java.util.Map getDEFNodes()
Get a list of the nodes that have been named with DEF in this scene. The map is keyed by the DEF name string and the values are the VRMLNodeType instances. If there are no nodes marked with DEF then the map will be empty.

Returns:
A map of the DEF'd nodes.

getImports

public java.util.Map getImports()
Get the IMPORT declaration information from this scene. There is no validity checking of these statements. The map is the inline's DEF name as the key to the value being a String[] that contains the inlined file's exported name and the AS rename portion.

Returns:
A map of the imported nodes

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium