|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.web3d.vrml.renderer.CRProtoCreator
A class that is used to create real instances of protos from their definitions.
The creator strips the definition apart and builds a runtime node based on the details and the node factory provided. The creator can handle one instance at a time, athough it will correctly parse and build nested proto declarations without extra effort.
We have a small conundrum to deal with - if the proto definition contains SF/MFNode fields, we don't know whether the values should be also generated as real runtime nodes too. Maybe the usage of this node will provide values that are dealt with after this class has finished. Other times, these defaul values must be used. For this implementation, we have gone with the safety-first approach: Always parse the definition of any SF or MFNode field and turn those into runtime instances. Although this may create extra garbage, there seems to be no nice way of dealing with this issue without a completely different architecture for the library.
Note: Under the current implementation, EXTERNPROTOs are not yet catered for.
| Field Summary | |
protected SceneGraphTraversalSimpleObserver |
currentObserver
The current observer. |
protected ErrorReporter |
errorReporter
Reporter instance for handing out errors |
protected VRMLNodeFactory |
factory
The factory that is used to generate the runtime version |
protected java.util.HashMap |
importMap
Mapping of import names to the copy proxy instance |
protected boolean |
isVRML97
Flag to say if the current proto instance is VRML97 capable |
protected int |
majorVersion
The major version of the spec this instance belongs to. |
protected int |
minorVersion
The minor version of the spec this instance belongs to. |
protected NodeCopier |
nodeCopier
Class used to copy SF/MFNode field instances |
protected java.util.HashMap |
nodeMap
Mapping of declaration node to the J3D version |
protected ProtoCopier |
protoCopier
Class used to create the proto body nodes |
protected CRProtoInstance |
protoInstance
The proto instance we're building up |
protected VRMLExecutionSpace |
rootSpace
The parent executionSpace used when working with instances of nodes inside the field declarations. |
protected ProtoScene |
scene
The scene as we are building it up during traversal |
protected FrameStateManager |
stateManager
The state manager to currently use |
protected SceneGraphTraverser |
traverser
Traverser used to examine SF/MFNode fields and the proto body |
protected java.lang.String |
worldURL
The current world's root URL |
| Constructor Summary | |
protected |
CRProtoCreator(VRMLNodeFactory fac,
java.lang.String worldURL,
int major,
int minor)
Create a new instance of a generic proto creator. |
| Method Summary | |
void |
fillinInstance(VRMLNodeTemplate template,
VRMLNode nodeInstance,
VRMLExecutionSpace space)
Given a stubbed instance, fill in the rest of the details. |
protected void |
finishCreate(PrototypeDecl proto)
Internal method to group code together for finishing proto creation |
void |
observedNode(VRMLNodeType parent,
VRMLNodeType child,
int field,
boolean used)
Notification of a child node. |
protected abstract void |
protoNode(VRMLNodeType parent,
VRMLProtoInstance proto,
int field,
boolean used)
Separate handler for the proto node, which needs to be renderer-specific |
void |
setErrorReporter(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 |
setFrameStateManager(FrameStateManager fsm)
Set the frame state manager to use for the builder after this point. |
protected void |
setProtoField(VRMLNodeType node,
int field,
int fieldSize,
VRMLFieldData data)
Process a single field of a contained, nested proto. |
| Methods 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.NodeTemplateToInstanceCreator |
newInstance |
| Field Detail |
protected VRMLNodeFactory factory
protected SceneGraphTraverser traverser
protected ProtoScene scene
protected FrameStateManager stateManager
protected java.util.HashMap nodeMap
protected java.util.HashMap importMap
protected CRProtoInstance protoInstance
protected VRMLExecutionSpace rootSpace
protected NodeCopier nodeCopier
protected ProtoCopier protoCopier
protected SceneGraphTraversalSimpleObserver currentObserver
protected ErrorReporter errorReporter
protected boolean isVRML97
protected int majorVersion
protected int minorVersion
protected java.lang.String worldURL
| Constructor Detail |
protected CRProtoCreator(VRMLNodeFactory fac,
java.lang.String worldURL,
int major,
int minor)
fac - The factory to use (Must generate VRMLNodeType instances)worldURL - the current world's root URLmajor - The major version number of this sceneminor - The minor version number of this scene| Method Detail |
public void setErrorReporter(ErrorReporter reporter)
setErrorReporter in interface NodeTemplateToInstanceCreatorreporter - The instance to use or null
public void fillinInstance(VRMLNodeTemplate template,
VRMLNode nodeInstance,
VRMLExecutionSpace space)
fillinInstance in interface NodeTemplateToInstanceCreatortemplate - The proto definition loaded from the EPspace - The execution space this node belongs innodeInstance - The instance to fill out
public void observedNode(VRMLNodeType parent,
VRMLNodeType child,
int field,
boolean used)
observedNode in interface SceneGraphTraversalSimpleObserverparent - The parent node of this nodechild - The child node that is being observedfield - The index of the child field in its parent nodeused - true if the node reference is actually a USEpublic void setFrameStateManager(FrameStateManager fsm)
fsm - The state manager to use
protected abstract void protoNode(VRMLNodeType parent,
VRMLProtoInstance proto,
int field,
boolean used)
parent - The parent node of this nodeproto - The proto node that has been foundfield - The index of the child field in its parent nodeused - true if the node reference is actually a USEprotected void finishCreate(PrototypeDecl proto)
proto - The decl of the proto
protected void setProtoField(VRMLNodeType node,
int field,
int fieldSize,
VRMLFieldData data)
throws FieldException
node - The node reference we are sending the value tofield - The index of the field to set the data forfieldSize - The size of field to set the data fordata - The source data used to set the field
FieldException - Any one of the normal field exceptions
|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||