Package org.web3d.vrml.lang
Class AbstractScene
java.lang.Object
org.web3d.vrml.lang.AbstractScene
- All Implemented Interfaces:
BasicScene
- Direct Known Subclasses:
CRVRMLScene
,ProtoScene
,SAIVRMLScene
Abstract implementation of the BasicScene
interface.
- Version:
- $Revision: 1.16 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.j3d.util.HashSet
<VRMLNode> All nodes currently held by this classprotected String
The URI that created this sceneprotected int
Major version number of this sceneprotected SceneMetaData
The meta data for the sceneprotected int
Minor version number of this sceneprotected VRMLNodeFactory
The node factory for this sceneprotected VRMLNode
The root node of the sceneList of all the routes storedprotected List
<VRMLNodeTemplate> List of all protos/externprotos held by this classprotected Map
<String, VRMLNodeTemplate> The list of template declarations stored here by name (key)protected String
The root URL for the world location -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractScene
(int major, int minor) Construct a new instance of the abstract scene. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDEFNode
(String name, VRMLNode node) Add a new def name to the map.void
addImportedNode
(String as, VRMLNode node, String exported) Add a new import name to the map.void
Add a node to this scene.void
addTemplate
(VRMLNodeTemplate template) Add a new template to this scene.getByPrimaryType
(int type) Get the list of nodes of the given primary type declared in this scene.getBySecondaryType
(int type) Get the list of nodes of the given secondary type declared in this scene.Get a list of the nodes that have been named with DEF in this scene.Get the IMPORT declaration information from this scene.int
Get the layer ID of this scene.Get the URI of the world that this scene represents.Get the meta data associated with this scene.Get the node factory that represents the setup of this scene.getNodeTemplate
(String name) Get the proto defined by the name.Get the list of top-level node templates declared in this scene.Get the node that forms the root of this scene.Get the list of ROUTEs declared in this scene.int
Get the specification major version that this scene belongs to.int
Get the specification minor version that this scene belongs to.Get the Root URL of the world that this scene represents.void
removeDEFNode
(String name) Remove a def name from the map.void
removeImportedNode
(String name) Remove an import name from the map.void
removeNode
(VRMLNode node) Remove a node from this scene.void
removeTemplate
(VRMLNodeTemplate template) Remove a template from this scene.void
setLayerId
(int id) Set the layer ID of this scene.void
setLoadedURI
(String uri) Set the URI of the world that this scene graph representsvoid
Set the node factory instance to be used with this scene.void
setRootNode
(VRMLNode node) Set the root node of the scene.void
setWorldRootURL
(String url) Set the root URL of the world that this scene graph representsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.lang.BasicScene
getProfileName
-
Field Details
-
metaData
The meta data for the scene -
rootNode
The root node of the scene -
routeList
-
allNodes
All nodes currently held by this class -
templateList
List of all protos/externprotos held by this class -
templateMap
The list of template declarations stored here by name (key) -
majorVersion
protected int majorVersionMajor version number of this scene -
minorVersion
protected int minorVersionMinor version number of this scene -
nodeFactory
The node factory for this scene -
worldURL
The root URL for the world location -
loadedURI
The URI that created this scene
-
-
Constructor Details
-
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 sceneminor
- The minor version number of this scene
-
-
Method Details
-
getLayerId
public int getLayerId()Get the layer ID of this scene. This method is only useful when the scene is not the root scene, such as being buried in an Inline.- Specified by:
getLayerId
in interfaceBasicScene
- Returns:
- id A non-negative layer identifier
-
setLayerId
public void setLayerId(int id) Set the layer ID of this scene. This method is only called when the scene is not the root scene, such as being buried in an Inline. This passes down the layer ID that the inline is kept in. The scene should make sure that this is passed down to the children nodes of this scene, but making sure to ignore any contained layers.- Specified by:
setLayerId
in interfaceBasicScene
- Parameters:
id
- A non-negative layer identifier
-
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 interfaceBasicScene
- Returns:
- The full URL of the world's location
-
getLoadedURI
Get the URI of the world that this scene represents. Returns null for dynamically created worlds.- Specified by:
getLoadedURI
in interfaceBasicScene
- Returns:
- The full URI of the world's location
-
getRootNode
Get the node that forms the root of this scene.- Specified by:
getRootNode
in interfaceBasicScene
- Returns:
- A reference to the root node of the scene
-
getMetaData
Get the meta data associated with this scene. A scene should always have some amount of metadata.- Specified by:
getMetaData
in interfaceBasicScene
- Returns:
- The current meta data
-
getSpecificationMajorVersion
public int getSpecificationMajorVersion()Get the specification major version that this scene belongs to.- Specified by:
getSpecificationMajorVersion
in interfaceBasicScene
- Returns:
- The major version number
-
getSpecificationMinorVersion
public int getSpecificationMinorVersion()Get the specification minor version that this scene belongs to.- Specified by:
getSpecificationMinorVersion
in interfaceBasicScene
- Returns:
- The minor version number
-
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 interfaceBasicScene
- Returns:
- The VRMLNodeFactory instance configured to represent this scene
-
setNodeFactory
public void setNodeFactory(VRMLNodeFactory fac) throws IllegalArgumentException, 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 interfaceBasicScene
- Parameters:
fac
- The factory instance to use- Throws:
IllegalArgumentException
- The factory instance provided was nullIllegalStateException
- A factory has already been set
-
addNode
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 interfaceBasicScene
- Parameters:
node
- The node to add
-
removeNode
Remove a node from 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 interfaceBasicScene
- Parameters:
node
- The node to add
-
addTemplate
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 interfaceBasicScene
- Parameters:
template
- The new template instance to use
-
removeTemplate
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 interfaceBasicScene
- Parameters:
template
- The template instance to remove
-
getRoutes
Get the list of ROUTEs declared in this scene.- Specified by:
getRoutes
in interfaceBasicScene
- Returns:
- The list of ROUTE instances in this scene
-
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 interfaceBasicScene
- Returns:
- The list of VRMLNodeTemplate instances in this scene
-
getByPrimaryType
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 interfaceBasicScene
- Parameters:
type
- index of type- Returns:
- The list of node instances in this scene.
-
getBySecondaryType
Get the list of nodes of the given secondary type declared in this scene.- Specified by:
getBySecondaryType
in interfaceBasicScene
- Parameters:
type
- index of type- Returns:
- The list of node instances in this scene.
-
getNodeTemplate
Get the proto defined by the name. If no proto is known by that name then return null.- Specified by:
getNodeTemplate
in interfaceBasicScene
- Parameters:
name
- The name of the proto to fetch.- Returns:
- The proto known by that name or null
-
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 theVRMLNode
instances. If there are no nodes marked with DEF then the map will be empty.- Specified by:
getDEFNodes
in interfaceBasicScene
- Returns:
- A map of the DEF'd nodes.
-
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 interfaceBasicScene
- Returns:
- A map of the imported nodes
-
setWorldRootURL
Set the root URL of the world that this scene graph represents- Parameters:
url
- The full URL of the world's location
-
setLoadedURI
Set the URI of the world that this scene graph represents- Parameters:
uri
- The full URI of the world's location
-
setRootNode
Set the root node of the scene.- Parameters:
node
- The root node of the scene to use
-
addDEFNode
Add a new def name to the map. If there is a DEF name of this type already registered, it is replaced with the incoming instance (as per VRML specification).- Parameters:
name
- The name of the node to be replacednode
- The new node instance to be registered for the node
-
removeDEFNode
Remove a def name from the map.- Parameters:
name
- The name of the node to be removed
-
addImportedNode
Add a new import name to the map. If there is a Imported name of this type already registered, it is replaced with the incoming instance (as per VRML specification.- Parameters:
as
- The name of the node in the local file (AS value)node
- The node containing the DEF name of the local inline nodeexported
- The exported name
-
removeImportedNode
Remove an import name from the map.- Parameters:
name
- The name of the node to be removed
-