Xj3D VRML/X3D Code API

org.web3d.vrml.lang
Class AbstractScene

java.lang.Object
  extended byorg.web3d.vrml.lang.AbstractScene
All Implemented Interfaces:
BasicScene
Direct Known Subclasses:
CRVRMLScene, ProtoScene, SAIVRMLScene

public abstract class AbstractScene
extends java.lang.Object
implements BasicScene

Abstract implementation of the BasicScene interface.

Version:
$Revision: 1.15 $
Author:
Justin Couch

Field Summary
protected  HashSet allNodes
          All nodes currently held by this class
protected  java.lang.String loadedURI
          The URI that created this scene
protected  int majorVersion
          Major version number of this scene
protected  SceneMetaData metaData
          The meta data for the scene
protected  int minorVersion
          Minor version number of this scene
protected  VRMLNodeFactory nodeFactory
          The node factory for this scene
protected  VRMLNode rootNode
          The root node of the scene
protected  java.util.ArrayList routeList
          List of all the routes stored
protected  java.util.ArrayList templateList
          List of all protos/externprotos held by this class
protected  java.util.HashMap templateMap
          The list of template declarations stored here by name (key)
protected  java.lang.String worldURL
          The root URL for the world location
 
Constructor Summary
protected AbstractScene(int major, int minor)
          Construct a new instance of the abstract scene.
 
Method Summary
 void addDEFNode(java.lang.String name, VRMLNode node)
          Add a new def name to the map.
 void addImportedNode(java.lang.String as, java.lang.String def, java.lang.String exported)
          Add a new import name to the map.
 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 scene.
 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 removeDEFNode(java.lang.String name)
          Remove a def name from the map.
 void removeImportedNode(java.lang.String name)
          Remove a import name from the map.
 void removeNode(VRMLNode node)
          Add a node to this scene.
 void removeTemplate(VRMLNodeTemplate template)
          Remove a template from this scene.
 void setLoadedURI(java.lang.String uri)
          Set the URI of the world that this scenegraph represents
 void setNodeFactory(VRMLNodeFactory fac)
          Set the node factory instance to be used with this scene.
 void setRootNode(VRMLNode node)
          Set the root node of the scene.
 void setWorldRootURL(java.lang.String url)
          Set the root URL of the world that this scenegraph represents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaData

protected SceneMetaData metaData
The meta data for the scene


rootNode

protected VRMLNode rootNode
The root node of the scene


routeList

protected java.util.ArrayList routeList
List of all the routes stored


allNodes

protected HashSet allNodes
All nodes currently held by this class


templateList

protected java.util.ArrayList templateList
List of all protos/externprotos held by this class


templateMap

protected java.util.HashMap templateMap
The list of template declarations stored here by name (key)


majorVersion

protected int majorVersion
Major version number of this scene


minorVersion

protected int minorVersion
Minor version number of this scene


nodeFactory

protected VRMLNodeFactory nodeFactory
The node factory for this scene


worldURL

protected java.lang.String worldURL
The root URL for the world location


loadedURI

protected java.lang.String loadedURI
The URI that created this scene

Constructor Detail

AbstractScene

protected AbstractScene(int major,
                        int minor)
Construct a new instance of the abstract scene. Will initialise all data structures.

Parameters:
major - The major version number of this scene
minor - The minor version number of this scene
Method Detail

setWorldRootURL

public void setWorldRootURL(java.lang.String url)
Set the root URL of the world that this scenegraph represents

Parameters:
url - The full URL of the world's location

setLoadedURI

public void setLoadedURI(java.lang.String uri)
Set the URI of the world that this scenegraph represents

Parameters:
uri - The full URI of the world's location

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.

Specified by:
getWorldRootURL in interface BasicScene
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.

Specified by:
getLoadedURI in interface BasicScene
Returns:
The full URI of the world's location

setRootNode

public void setRootNode(VRMLNode node)
Set the root node of the scene.

Parameters:
node - The root node of the scene to use

getRootNode

public VRMLNode getRootNode()
Get the node that forms the root of this scene.

Specified by:
getRootNode in interface BasicScene
Returns:
A reference to the root node of the scene

getMetaData

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

Specified by:
getMetaData in interface BasicScene
Returns:
The current meta data

getSpecificationMajorVersion

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

Specified by:
getSpecificationMajorVersion in interface BasicScene
Returns:
The major version number

getSpecificationMinorVersion

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

Specified by:
getSpecificationMinorVersion in interface BasicScene
Returns:
The minor version number

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.

Specified by:
getNodeFactory in interface BasicScene
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.

Specified by:
setNodeFactory in interface BasicScene
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

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.

Specified by:
addNode in interface BasicScene
Parameters:
node - The node to add

removeNode

public void removeNode(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 implementation shall silently ignore a request to remove a node that does not exist in this scene.

Specified by:
removeNode in interface BasicScene
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.

Specified by:
addTemplate in interface BasicScene
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.

Specified by:
removeTemplate in interface BasicScene
Parameters:
template - The template instance to remove

getRoutes

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

Specified by:
getRoutes in interface BasicScene
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.

Specified by:
getNodeTemplates in interface BasicScene
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.

Specified by:
getByPrimaryType in interface BasicScene
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.

Specified by:
getBySecondaryType in interface BasicScene
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.

Specified by:
getNodeTemplate in interface BasicScene
Parameters:
name - The name of the proto to fetch.
Returns:
The proto known by that name or null

addDEFNode

public void addDEFNode(java.lang.String name,
                       VRMLNode node)
Add a new def name to the map. If there is a DEF name of this type already registered, it is replace with the incoming instance (as per VRML specification.

Parameters:
name - The name of the node to be replaced
node - The new node instance to be registered for the node

removeDEFNode

public void removeDEFNode(java.lang.String name)
Remove a def name from the map.

Parameters:
name - The name of the node to be removed

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 VRMLNode instances. If there are no nodes marked with DEF then the map will be empty.

Specified by:
getDEFNodes in interface BasicScene
Returns:
A map of the DEF'd nodes.

addImportedNode

public void addImportedNode(java.lang.String as,
                            java.lang.String def,
                            java.lang.String exported)
Add a new import name to the map. If there is a Imported name of this type already registered, it is replace with the incoming instance (as per VRML specification.

Parameters:
as - The name of the node in the local file (AS value)
def - The DEF name of the local inline node
exported - The exported name

removeImportedNode

public void removeImportedNode(java.lang.String name)
Remove a import name from the map.

Parameters:
name - The name of the node to be removed

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 AS name as the key to the value being a String[] that contains the inline's DEF name and exported name.

Specified by:
getImports in interface BasicScene
Returns:
A map of the imported nodes

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium