Package org.web3d.vrml.scripting.sai
Class BaseExecutionContext
java.lang.Object
org.web3d.vrml.scripting.sai.BaseExecutionContext
- All Implemented Interfaces:
X3DExecutionContext
X3DExecutionContext implementation that is used for Protos and the base
of a X3DScene.
- Version:
- $Revision: 1.26 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ComponentInfo[]
The list of components in useprotected final int
The encoding type constantprotected org.j3d.util.ErrorReporter
Class that represents the external reporterprotected VRMLExecutionSpace
The execution space that this context works inprotected X3DExternProtoDeclaration[]
The list of extern protos declaredListing of all the valid X3DNode wrappers.protected Map
<VRMLNodeType, X3DNode> Mapping of the VRMLNodeType to its X3DNode wrapperprotected final ProfileInfo
The list of profiles in useprotected X3DProtoDeclaration[]
The array of protos declaredprotected BaseNode[]
Listing of root nodesprotected RouteManager
Route manager for handling user added/removed routesMapping of the ROUTE to its X3DRoute wrapperprotected BasicScene
The basic scene typeprotected final String
The version of the specification representedprotected FrameStateManager
FrameState manager for creating nodesprotected final String
The world URLFields inherited from interface org.web3d.x3d.sai.X3DExecutionContext
ASCII_ENCODING, BIFS_ENCODING, BINARY_ENCODING, LAST_STD_ENCODING, NO_SCENE, SCRIPTED_ENCODING, VRML_ENCODING, XML_ENCODING
-
Constructor Summary
ConstructorsConstructorDescriptionBaseExecutionContext
(VRMLExecutionSpace space, RouteManager rm, FrameStateManager fsm, ProfileInfo profile, ReferenceQueue<X3DField> refQueue, FieldFactory fac, FieldAccessListener fal, BaseNodeFactory bnf) Construct an execution context descriptor for the given information.BaseExecutionContext
(VRMLExecutionSpace space, RouteManager rm, FrameStateManager fsm, ProfileInfo profile, ComponentInfo[] components, ReferenceQueue<X3DField> refQueue, FieldFactory fac, FieldAccessListener fal, BaseNodeFactory bnf) Construct an execution context descriptor for the given information. -
Method Summary
Modifier and TypeMethodDescriptionAdd a route in this scene.createNode
(String name) Create a new node in this scene.createProto
(String name) Create a new proto instance in this scene.Get the list of all the components declared in the scene.int
Get the encoding of the original file type.Get the EXTERNPROTO declaration representing the given name.String[]
Get the list of EXTERNPROTOs declared in this scene.getImportedNode
(String name) Get the imported node instance represented by a given name.getNamedNode
(String name) Get the node instance represented by the given name.String[]
Get a list of the nodes that have been named with DEF or keyword in this scene.Get the name of the profile used by this scene.getProtoDeclaration
(String name) Get the PROTO declaration representing the given name.String[]
Get the list of ordinary PROTO's declared in this scene.X3DNode[]
Get the list of current root nodes in the scene.X3DRoute[]
Get the list of ROUTEs in this scene.Get the specification version name that was used to describe this scene.Get the fully qualified URL of this scene.void
Remove the externproto declaration registered under the given name.void
removeImportedNode
(String importName) Remove the IMPORT statement associated with a given local import name.void
removeNamedNode
(String name) Calling this method removes any existing mapping between a given literal name and any X3D nodes.void
removeProtoDeclaration
(String name) Remove the proto declaration registered under the given name.void
removeRoute
(X3DRoute route) Delete the route from this scene.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion.void
updateExternProtoDeclaration
(String name, X3DExternProtoDeclaration externproto) Add the EXTERNPROTO declaration representing the given name.void
updateImportedNode
(String exportedName, String importedName, X3DNode inline) Create or modify an IMPORT from the specified inline node to a given import name.void
updateNamedNode
(String nodeName, X3DNode node) Calling this method creates an association between a literal name and a node.void
updateProtoDeclaration
(String name, X3DProtoDeclaration proto) Add the PROTO declaration representing the given name.
-
Field Details
-
specVersion
The version of the specification represented -
encoding
protected final int encodingThe encoding type constant -
profile
The list of profiles in use -
components
The list of components in use -
errorReporter
protected org.j3d.util.ErrorReporter errorReporterClass that represents the external reporter -
url
The world URL -
rootNodes
Listing of root nodes -
protos
The array of protos declared -
externprotos
The list of extern protos declared -
executionSpace
The execution space that this context works in -
scene
The basic scene type -
routeManager
Route manager for handling user added/removed routes -
stateManager
FrameState manager for creating nodes -
nodeWrapperList
-
nodeWrapperMap
Mapping of the VRMLNodeType to its X3DNode wrapper -
routeWrapperMap
-
-
Constructor Details
-
BaseExecutionContext
public BaseExecutionContext(VRMLExecutionSpace space, RouteManager rm, FrameStateManager fsm, ProfileInfo profile, ComponentInfo[] components, ReferenceQueue<X3DField> refQueue, FieldFactory fac, FieldAccessListener fal, BaseNodeFactory bnf) Construct an execution context descriptor for the given information.- Parameters:
space
- The space to source information for this scenerm
- A route manager for users creating/removing routesfsm
- state manager for dealing with dynamic scene graph changesprofile
- Instance of the ProfileInfo that describes this scenecomponents
- The component definitions for this scenerefQueue
- The queue used for dealing with field referencesfac
- Factory used to create field wrappersfal
- The access listener for propagating s2 requestsbnf
- The factory used to create node wrappers
-
BaseExecutionContext
public BaseExecutionContext(VRMLExecutionSpace space, RouteManager rm, FrameStateManager fsm, ProfileInfo profile, ReferenceQueue<X3DField> refQueue, FieldFactory fac, FieldAccessListener fal, BaseNodeFactory bnf) Construct an execution context descriptor for the given information.- Parameters:
space
- The space to source information for this scenerm
- A route manager for users creating/removing routesfsm
-profile
- Instance of the ProfileInfo that describes this scenerefQueue
- The queue used for dealing with field referencesfac
- Factory used to create field wrappersfal
- The access listener for propagating s2 requestsbnf
- The factory used to create node wrappers
-
-
Method Details
-
getSpecificationVersion
Get the specification version name that was used to describe this scene. The version is a string that is relative to the specification used and is in the format "X.Y" where X and Y are integer values describing major and minor versions, respectively.- Specified by:
getSpecificationVersion
in interfaceX3DExecutionContext
- Returns:
- The version used for this scene
-
getEncoding
public int getEncoding()Get the encoding of the original file type.- Specified by:
getEncoding
in interfaceX3DExecutionContext
- Returns:
- The encoding description
-
getProfile
Get the name of the profile used by this scene. If the profile is not set, will return null.- Specified by:
getProfile
in interfaceX3DExecutionContext
- Returns:
- The name of the profile, or null
-
getComponents
Get the list of all the components declared in the scene. If there were no components registered, this will return null.- Specified by:
getComponents
in interfaceX3DExecutionContext
- Returns:
- The components declared or null
-
getWorldURL
Get the fully qualified URL of this scene. This returns the entire URL including any possible arguments that might be associated with a CGI call or similar mechanism. If the world was created programmatically, this will return null.- Specified by:
getWorldURL
in interfaceX3DExecutionContext
- Returns:
- A string of the URL 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.
-
getRoutes
Get the list of ROUTEs in this scene. This gives all of the top level routes in the scene in the order that they are declared.- Specified by:
getRoutes
in interfaceX3DExecutionContext
- Returns:
- The list of ROUTE instances in this scene
-
addRoute
public X3DRoute addRoute(X3DNode fromX3DNode, String readableField, X3DNode toX3DNode, String writableField) throws InvalidBrowserException, InvalidReadableFieldException, InvalidWritableFieldException, InvalidNodeException Add a route in this scene. The route is considered to be part of this scene regardless of whether the two end points are or not. The route will remain valid as long as both nodes are live and this scene is live. If this scene becomes invalid (eg a loadURL call is successful) then the route will no longer exist and there shall be no connection between the two nodes.- Specified by:
addRoute
in interfaceX3DExecutionContext
- Parameters:
fromX3DNode
- The source node for the routereadableField
- The readable field source of the routetoX3DNode
- The destination node of the routewritableField
- The writable field destination of the route- Returns:
- new SAIRoute
- Throws:
InvalidReadableFieldException
- if the named readable field does not existInvalidWritableFieldException
- if the named writable field does not exist.InvalidNodeException
- The nominated destination or source node has been disposed ofInvalidBrowserException
- The dispose method has been called on this browser reference.ConnectionException
- An error occurred in the connection to the browser.
-
removeRoute
Delete the route from this scene. If the route is not part of this scene an exception is generated.- Specified by:
removeRoute
in interfaceX3DExecutionContext
- Parameters:
route
- The route reference to delete- Throws:
InvalidBrowserException
- The dispose method has been called on this browser reference.
-
getProtosNames
Get the list of ordinary PROTO's declared in this scene. EXTERNPROTOs are not included in this list.- Specified by:
getProtosNames
in interfaceX3DExecutionContext
- Returns:
- The list of proto instances in this scene
-
getProtoDeclaration
Get the PROTO declaration representing the given name.- Specified by:
getProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the proto to fetch- Returns:
- PROTO declaration
-
updateProtoDeclaration
Add the PROTO declaration representing the given name.- Specified by:
updateProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the proto to fetchproto
- The declaration for the name
-
removeProtoDeclaration
Remove the proto declaration registered under the given name.- Specified by:
removeProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the proto to fetch
-
getExternProtoNames
Get the list of EXTERNPROTOs declared in this scene. The instances may or may not have been loaded at this point. Check with the interface declaration to see if this is the case.- Specified by:
getExternProtoNames
in interfaceX3DExecutionContext
- Returns:
- The list of EXTERNPROTO instances in this scene
-
getExternProtoDeclaration
Get the EXTERNPROTO declaration representing the given name.- Specified by:
getExternProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the externproto to fetch- Returns:
- EXTERNPROTO declaration
-
updateExternProtoDeclaration
Add the EXTERNPROTO declaration representing the given name.- Specified by:
updateExternProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the externproto to fetchexternproto
- The declaration for the name
-
removeExternProtoDeclaration
Remove the externproto declaration registered under the given name.- Specified by:
removeExternProtoDeclaration
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the externproto to fetch
-
getNamedNodes
Get a list of the nodes that have been named with DEF or keyword in this scene. The map is keyed by the name string and the values are theX3DNode
instances. If there are no nodes marked with DEF then the map will be empty.- Specified by:
getNamedNodes
in interfaceX3DExecutionContext
- Returns:
- A map of the DEF'd nodes.
-
getNamedNode
Get the node instance represented by the given name.- Specified by:
getNamedNode
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the node to fetch the definition for- Returns:
- The node instance or null if not known
-
removeNamedNode
Calling this method removes any existing mapping between a given literal name and any X3D nodes.- Specified by:
removeNamedNode
in interfaceX3DExecutionContext
- Parameters:
name
- The literal name of the mapping to remove.
-
updateNamedNode
Calling this method creates an association between a literal name and a node. If there is already a mapping from a given literal name to some value, that mapping will be replaced by the new mapping. If a mapping for that literal name did not exist, one will be created. There may exist multiple literal names which map to a given X3D node.- Specified by:
updateNamedNode
in interfaceX3DExecutionContext
- Parameters:
nodeName
- The literal name to change.node
- The node to map to.
-
getImportedNode
Get the imported node instance represented by a given name.- Specified by:
getImportedNode
in interfaceX3DExecutionContext
- Parameters:
name
- The name of the import to fetch- Returns:
- A node wrapper representing the node
-
removeImportedNode
Remove the IMPORT statement associated with a given local import name. See 19777-2 6.4.9 namedNode handling.- Specified by:
removeImportedNode
in interfaceX3DExecutionContext
- Parameters:
importName
- The local name used in the IMPORT
-
updateImportedNode
Create or modify an IMPORT from the specified inline node to a given import name. If 'importName' has already been used as the local name for an import, the old value will be replaced by the new value. Otherwise the appropriate new IMPORT will be constructed. See 19777-2 6.4.9 namedNode handling- Specified by:
updateImportedNode
in interfaceX3DExecutionContext
- Parameters:
exportedName
- The node name as exported from the inlineimportedName
- The name to use locally for the imported nodeinline
- The "DEF'd Inline" of the IMPORT (ISO 19775:2005).
-
getRootNodes
Get the list of current root nodes in the scene. The array contains the items in the order they were added or declared in the initial file or added after the initial scene was created.- Specified by:
getRootNodes
in interfaceX3DExecutionContext
- Returns:
- The list of root nodes in the scene
-
createNode
Create a new node in this scene. The node creation uses the pre-set profile and component information to ensure the validity of what the user wishes to create. If the named node is not in one of the defined profile or components then an exception is generated. This cannot be used to create nodes that are declared as protos or extern protos in this scene. You must use the proto-specific mechanisms for that.- Specified by:
createNode
in interfaceX3DExecutionContext
- Parameters:
name
- The node's name to create- Returns:
- The node pointer that represents the given name
- Throws:
InvalidNodeException
- The name does not represent a node in the given list of profile and components for this scene
-
createProto
Create a new proto instance in this scene. The node creation uses the name space semantics to locate the appropriate proto. This may require the browser to first look in the local proto space and then walk backwards up the proto declaration spaces to find a match.- Specified by:
createProto
in interfaceX3DExecutionContext
- Parameters:
name
- The proto's name to create- Returns:
- The node pointer that represents the given proto
- Throws:
InvalidNodeException
- The name does not represent a known proto declaration in the available namespaces
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old. Also changes the ErrorReporter used by the CommonBrowser instance.- Parameters:
reporter
- The instance to use or null
-