Class DefaultNodeFactory
- All Implemented Interfaces:
Cloneable
,VRMLNodeFactory
- Direct Known Subclasses:
NRNodeFactory
,OGLNodeFactory
VRMLNodeFactory
that produces implementations of the nodes and can be customized for a
specific renderer.
This implementation serves two purposes - generalised node factory
implementation and the base of a renderer-specific implementation. The
class is a full instance allowing it to be used directly, but the
constructor is marked protected
so that you can't create
an instance directly. However, you can use the static factory method to
fetch the singleton instance for that particular renderer type.
Property Files
Yes, there are a lot used by this class. Most of them we don't know until runtime because the loading of one file is used to find the definition of another file to load with further property information. There is a much more in-depth tutorial on how to extend Xj3D on the website, so this is just an overview.
At the top of the pile is xj3d.properties
. This file is used
at startup of the factory. In here, is located the list of profiles
supported, components supported and renderers supported. The list of
profiles are then used to load a separate property file for each profile,
with the file name profile_name.properties
. The
file name is all lower case, regardless of what the initial formal profile
name is. In the profile properties file is the title and the list of
each component and level that is required for that profile.
After the profiles, there is a list of the components that may be supported. This list just points to the property file that contains the definition of the component. These files may be placed anywhere, however, for the inbuilt components of Xj3D, you will find the property files in this package (directory). Users wishing to create custom components may place them anywhere, so long as they are findable in the CLASSPATH at runtime. Each file contains a title, name of the implementor and a URL of that implementor. In addition, it contains the definition of the maximum level supported by that component and the list of nodes that are provided at each level. This class is longer a singleton. setProfile was clearing the supported nodes each time. This meant multiple threads with different profiles got messed up.
- Version:
- $Revision: 2.9 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Definition of the Java3D rendererprotected int
The major version of the spec this file belongs to.protected int
The minor version of the spec this file belongs to.static final String
Definition of the Mobile rendererstatic final String
Definition of the null rendererstatic final String
Definition of the OpenGL rendererFields inherited from interface org.web3d.vrml.lang.VRMLNodeFactory
ANY_LEVEL
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DefaultNodeFactory
(String rendererID) Construct an instance of the factory for the given renderer type. -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(String name, int level) Add a component level requirement to the factory nodes.static void
Convenience method to clear all the cached information so that we start again with new information.clone()
Create a clone of this factory.static VRMLNodeFactory
createFactory
(String rendererID) Factory method to create an instance of the node factory that can be used for a specific renderer.createVRMLNode
(String nodeName, boolean staticNode) Create a new node instance from the given node name.createVRMLNode
(String component, String nodeName, boolean staticNode) Create a new node instance of the given node that exists in the given profile.createVRMLNode
(VRMLNode node, boolean staticNode) Create a new node instance that is a cloned copy of the given node.void
disableComponent
(int[] specVersion, String componentName, int level) Disable a component.findComponent
(String name, int level) Check to see if the given component could be found on the system at the given level.findProfile
(String name) Check to see if the given profile could be found on the system.List all of the available components that this factory is capable of supporting.String[]
Convenience method to get just the names all the available profiles that this factory is capable of supporting.List the all the available profiles that this factory is capable of supporting.int[]
Get the maximum supported spec version.int[]
Get the spec version that this node factory is currently set to.static VRMLNodeFactory
newInstance
(String rendererID) Factory method to create an new instance of the node factory every time the method is called.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.void
setProfile
(String profile) Set the profile that is to be supported for the following nodes.void
setSpecVersion
(int major, int minor) Set specification version
-
Field Details
-
JAVA3D_RENDERER
-
NULL_RENDERER
-
OPENGL_RENDERER
-
MOBILE_RENDERER
-
majorVersion
protected int majorVersionThe major version of the spec this file belongs to. -
minorVersion
protected int minorVersionThe minor version of the spec this file belongs to.
-
-
Constructor Details
-
DefaultNodeFactory
Construct an instance of the factory for the given renderer type.- Parameters:
rendererID
- The ID of the renderer to use for this factory
-
-
Method Details
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Description copied from interface:VRMLNodeFactory
Register an error reporter with the engine so that any errors generated by the loading of 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.- Specified by:
setErrorReporter
in interfaceVRMLNodeFactory
- Parameters:
reporter
- The instance to use or null
-
setSpecVersion
Set specification version- Specified by:
setSpecVersion
in interfaceVRMLNodeFactory
- Parameters:
major
- 2 (VRML97), 3, or 4minor
- 0, 1, 2, 3- Throws:
UnsupportedSpecVersionException
-
getSpecVersion
public int[] getSpecVersion()Description copied from interface:VRMLNodeFactory
Get the spec version that this node factory is currently set to.- Specified by:
getSpecVersion
in interfaceVRMLNodeFactory
- Returns:
- An int array of major, minor version.
-
setProfile
Description copied from interface:VRMLNodeFactory
Set the profile that is to be supported for the following nodes. Calling this method will clear all previously set profile and components.- Specified by:
setProfile
in interfaceVRMLNodeFactory
- Parameters:
profile
- The profile name to use- Throws:
UnsupportedProfileException
- The profile is not unsupported by this implementation
-
getMaxSupportedSpecVersion
public int[] getMaxSupportedSpecVersion()Description copied from interface:VRMLNodeFactory
Get the maximum supported spec version.- Specified by:
getMaxSupportedSpecVersion
in interfaceVRMLNodeFactory
- Returns:
- An int array of major, minor version.
-
disableComponent
Description copied from interface:VRMLNodeFactory
Disable a component. Typically done when something finds out it cannot support the component.- Specified by:
disableComponent
in interfaceVRMLNodeFactory
- Parameters:
specVersion
- The spec version. Major, Minor.componentName
- The component namelevel
- The component level and higher to disable
-
addComponent
Description copied from interface:VRMLNodeFactory
Add a component level requirement to the factory nodes. If that component or level is not supported, an exception is thrown. If the level is ANY_LEVEL then that says to find the highest supported component.- Specified by:
addComponent
in interfaceVRMLNodeFactory
- Parameters:
name
- The name of the componentlevel
- The level of the component to support- Returns:
- The component information declaration matching the input
- Throws:
UnsupportedComponentException
- The component is not unsupported by this implementation
-
findComponent
Description copied from interface:VRMLNodeFactory
Check to see if the given component could be found on the system at the given level. If it is, it will be automatically added to the available component list. This is relative to the given specification level that has been set for this factory instance.- Specified by:
findComponent
in interfaceVRMLNodeFactory
- Parameters:
name
- The name of the componentlevel
- The level of the component to support- Returns:
- The component definition if found, null if not
-
findProfile
Description copied from interface:VRMLNodeFactory
Check to see if the given profile could be found on the system. If it is, it will be automatically added to the available profile list. This is relative to the given specification level that has been set for this factory instance.- Specified by:
findProfile
in interfaceVRMLNodeFactory
- Parameters:
name
- The name of the profile- Returns:
- The profile definition if found, null if not
-
getAvailableProfiles
Description copied from interface:VRMLNodeFactory
List the all the available profiles that this factory is capable of supporting. It is not the list of set profiles to filter for.- Specified by:
getAvailableProfiles
in interfaceVRMLNodeFactory
- Returns:
- A list of the supported profiles
-
getAvailableProfileNames
Description copied from interface:VRMLNodeFactory
Convenience method to get just the names all the available profiles that this factory is capable of supporting. It is not the list of set profiles to filter for.- Specified by:
getAvailableProfileNames
in interfaceVRMLNodeFactory
- Returns:
- A list of the supported profile names
-
getAvailableComponents
Description copied from interface:VRMLNodeFactory
List all of the available components that this factory is capable of supporting.- Specified by:
getAvailableComponents
in interfaceVRMLNodeFactory
- Returns:
- The definition of all the available components
-
createVRMLNode
Description copied from interface:VRMLNodeFactory
Create a new node instance from the given node name. A best guess is made to the node's profile that it belongs to. This means that it could occasionally get it wrong if there are conflicting node names. If the node does not exist in the set profile + component then an exception is thrown. If it is part of the profile, but has not yet been implemented then null is returned.- Specified by:
createVRMLNode
in interfaceVRMLNodeFactory
- Parameters:
nodeName
- The name of the node instance to createstaticNode
- Whether this node will be modified- Returns:
- An instance of the node, uninitialised or null.
- Throws:
UnsupportedNodeException
- The node is not part of the declared profile and components
-
createVRMLNode
public VRMLNode createVRMLNode(String component, String nodeName, boolean staticNode) throws UnsupportedComponentException, UnsupportedNodeException Description copied from interface:VRMLNodeFactory
Create a new node instance of the given node that exists in the given profile. If the node does not exist in that profile then an exception is thrown. If it is part of the profile, but has not yet been implemented then null is returned.- Specified by:
createVRMLNode
in interfaceVRMLNodeFactory
- Parameters:
component
- The name of the component to create the name fornodeName
- The name of the node instance to createstaticNode
- Whether this node is will be modified- Returns:
- An instance of the node, uninitialised or null.
- Throws:
UnsupportedComponentException
- The component is not in the list of usable components currently setUnsupportedNodeException
- The node is not part of the declared profile and components
-
createVRMLNode
Description copied from interface:VRMLNodeFactory
Create a new node instance that is a cloned copy of the given node. The copy shall be a shallow copy. All of the node's direct field data has full copies of the values made, but any referenced child nodes are not included in the copy.The primary use of this method is in generating proto instances from a set of template nodes. The parser of the proto will be responsible for making sure the children scene graphs are correctly built by successive calls to this method. Note that this implies the source node may well be from a different renderer implementation to the output form.
- Specified by:
createVRMLNode
in interfaceVRMLNodeFactory
- Parameters:
node
- The node instance to create a copy ofstaticNode
- Whether this node is will be modified- Returns:
- An instance of the node initialised to the values or null.
-
createFactory
Factory method to create an instance of the node factory that can be used for a specific renderer.- Parameters:
rendererID
- The ID of the renderer to use for this factory- Returns:
-
newInstance
Factory method to create an new instance of the node factory every time the method is called.- Parameters:
rendererID
- The ID of the renderer to use for this factory- Returns:
-
clearCachedInfo
public static void clearCachedInfo()Convenience method to clear all the cached information so that we start again with new information. This will clear all global information, not just the info in the current instance. -
clone
Description copied from interface:VRMLNodeFactory
Create a clone of this factory. The clone will have the same profile and component mix already constructed.- Specified by:
clone
in interfaceVRMLNodeFactory
- Overrides:
clone
in classObject
- Returns:
- A cloned copy of this instance
- Throws:
CloneNotSupportedException
- Was not able to clone the object
-