|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Representation of a factory that can produce instances of VRMLNode implementations.
This interface is primarily provided to allow an independence of the factory implementation from the factory functionality. Classes that need to create instances of VRMLNodes would just be passed this interface rather than the full factory. That then allows a single parser to be passed different factories generating different output as needed. For example one factory might use it to write info to a serialised network stream while another uses it as a layer over a rendering API such as Java3D or OpenGL.
The factory has a form of filtering mechanism in built for profile support. It acts as a form of filtering when requesting nodes. If the requested node is not part of the set profile list then the create calls would return null.
Node Creation Behaviour
In order to create a node, the factory has to be told what profile and any
optional components the nodes are to come from. Then, the createVRMLNode()
calls work on this information to determine whether it is legal or not to
create the node. If it is not, then an UnsupportedNodeException is
generated naming the node that is in error.
Because Xj3D is also permanently "in development", we have to also recognise that not all components will be completely implemented. For these, the loaded file should not fail with an undefined node message when the node really is valid for that component but we haven't implemented it yet. In that case, the createVRMLNode() methods will return a null. Users should check for this and make sure to understand the difference between this case and that of the invalid node, which generates the exception. In this later case, the user should continue to process the rest of the stream, while issuing a notification message about the missing node implementation.
| Field Summary | |
static int |
ANY_LEVEL
Flag to say that the component level can be whatever is available |
| Method Summary | |
ComponentInfo |
addComponent(java.lang.String name,
int level)
Add a component level requirement to the factory nodes. |
java.lang.Object |
clone()
Create a clone of this factory. |
VRMLNode |
createVRMLNode(java.lang.String nodeName,
boolean staticNode)
Create a new node instance from the given node name. |
VRMLNode |
createVRMLNode(java.lang.String component,
java.lang.String nodeName,
boolean staticNode)
Create a new node instance of the given node that exists in the given profile. |
VRMLNode |
createVRMLNode(VRMLNode node,
boolean staticNode)
Create a new node instance that is a cloned copy of the given node. |
void |
disableComponent(int[] specVersion,
java.lang.String componentName,
int level)
Disable a component. |
ComponentInfo[] |
getAvailableComponents()
List all of the available components that this factory is capable of supporting. |
java.lang.String[] |
getAvailableProfileNames()
Convenience method to get just the names all the available profiles that this factory is capable of supporting. |
ProfileInfo[] |
getAvailableProfiles()
List the all the available profiles that this factory is capable of supporting. |
int[] |
getMaxSupportedSpecVersion()
Get the maximum supported spec version. |
void |
setErrorReporter(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(java.lang.String profile)
Set the profile that is to be supported for the following nodes. |
void |
setSpecVersion(int major,
int minor)
Set the spec version that this node factory should be setting it's profile information for. |
| Field Detail |
public static final int ANY_LEVEL
| Method Detail |
public void setErrorReporter(ErrorReporter reporter)
reporter - The instance to use or null
public void setSpecVersion(int major,
int minor)
throws UnsupportedSpecVersionException
major - The major version of the VRML/X3D spec to useminor - The minor version of the VRML/X3D spec to use
UnsupportedSpecVersionException - The profile is not unsupported by
this implementationpublic int[] getMaxSupportedSpecVersion()
public void disableComponent(int[] specVersion,
java.lang.String componentName,
int level)
specVersion - The spec version. Major, Minor.componentName - The component namelevel - The component level and higher to disable
public void setProfile(java.lang.String profile)
throws UnsupportedProfileException
profile - The profile name to use
UnsupportedProfileException - The profile is not unsupported by
this implementation
public ComponentInfo addComponent(java.lang.String name,
int level)
throws UnsupportedComponentException
name - The name of the componentlevel - The level of the component to support
UnsupportedComponentException - The component is not unsupported by
this implementationpublic ProfileInfo[] getAvailableProfiles()
public java.lang.String[] getAvailableProfileNames()
public ComponentInfo[] getAvailableComponents()
public VRMLNode createVRMLNode(java.lang.String nodeName,
boolean staticNode)
throws UnsupportedNodeException
nodeName - The name of the node instance to createstaticNode - Whether this node is will be modified
UnsupportedNodeException - The node is not part of the declared
profile and components
public VRMLNode createVRMLNode(java.lang.String component,
java.lang.String nodeName,
boolean staticNode)
throws UnsupportedComponentException,
UnsupportedNodeException
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
UnsupportedComponentException - The component is not in the list of
usable components currently set
UnsupportedNodeException - The node is not part of the declared
profile and components
public VRMLNode createVRMLNode(VRMLNode node,
boolean staticNode)
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 sucessive calls to this method. Note that this implies the source node may well be from a different renderer implementation to the output form.
node - The node instance to create a copy ofstaticNode - Whether this node is will be modified
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException - Was not able to clone the object
|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||