|
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.CRMainSceneBuilder
A scene builder implementation for reading input from a SAV source and building a scenegraph with them.
This basic implementation does most of the hard work regardless of the individual renderer in use. The implementer of this class is only required to provide a single method - startNode(), although they are free to override any that they wish. It is strongly recommended that the overridden method be called on this class too to make sure state does not get out of alignment.
| Field Summary | |
protected static java.lang.String |
BAD_METHOD_MSG
Message for the exceptions thrown for methods being called when they should not be (eg proto callbacks) |
protected boolean |
badFieldName
Flag indicating that the last field we processed had an invalid name. |
protected VRMLNodeFactory |
baseNodeFactory
The base node factory used to create individual factories |
protected int[] |
childIndexStack
The stack of child indexes used during processing |
protected int |
currentFieldIndex
Copy of the top child index for efficiency purposes |
protected VRMLNodeType |
currentNode
Copy of the top node for efficiency purposes |
protected VRMLScriptNodeType |
currentScript
Copy of the current working script definition |
protected java.util.Map |
defMap
The mapping of def names (key) to node instances (value) |
protected HashSet |
dontLoadTypes
Set of classes that we don't want to load |
protected ErrorReporter |
errorReporter
The error handler used for reporting errors |
protected java.util.Map |
exportProxyMap
The mapping of export node names (import foo.exportname AS bar) to their ImportProxyNode instance. |
protected java.util.Map |
externProtoMap
The mapping of externproto names (key) to node instances (value) |
protected VRMLFieldReader |
fieldParser
Field Parser for the current scene |
protected HashSet |
ignoreDefSet
Set of DEF names to ignore when we come to USE decls |
protected int |
ignoreNodeCounter
Counter when we ignore a node type we don't know about |
protected java.util.Map |
importProxyMap
The mapping of imported node names (import foo.bar AS importname) to their ImportProxyNode instance. |
protected boolean |
init
Flag to indicate that one time initialisation process has happened |
protected boolean |
inScript
Flag to indicate we are inside a script at the moment |
protected boolean |
inStatic
Flag to indicate we are currently under a static group |
protected boolean |
isVrml97
Flag indicating what mode - VRML97 or VRML3.0 that we're using |
protected Locator |
locator
The document locator to find error information |
protected int |
majorVersion
The major version of the spec this file belongs to. |
protected WriteableSceneMetaData |
metaData
The metadata for this scene |
protected int |
minorVersion
The minor version of the spec this file belongs to. |
protected VRMLNodeFactory |
nodeFactory
The node factory used to create real node instances |
protected VRMLNodeType[] |
nodeStack
The stack of nodes used during processing the document |
protected CRProtoCreator |
protoCreator
The creator used to instantiate protos |
protected java.util.Map |
protoMap
The mapping of proto names (key) to node instances (value) |
protected VRMLWorldRootNodeType |
root
The scene root node |
protected CRVRMLScene |
scene
The scene that we are currently building |
protected SimpleStack |
scriptStack
The working stack of currently building scripts. |
protected static int |
STACK_INCREMENT
The increment size of the stack if it get overflowed |
protected static int |
STACK_START_SIZE
The initial size of the stack for element processing |
protected FrameStateManager |
stateManager
The state manager to currently use |
protected int |
staticDepthCounter
Counter when we discover a static group node |
protected HashSet |
staticNodeSet
Set of names under a StaticGroup so we can check for routes |
protected int |
topOfStack
Counter to the top item in the stack array |
protected static java.lang.String |
VRML_EXPORT_ERROR
Error when an export statement is found in an VRML97 file |
protected static java.lang.String |
VRML_IMPORT_ERROR
Error when an import statement is found in an VRML97 file |
protected static java.lang.String |
VRML97_PROFILE_STRING
Name of the profile used for VRML97 compatibility |
protected java.lang.String |
worldURL
The current world's root URL |
| Constructor Summary | |
protected |
CRMainSceneBuilder(VRMLNodeFactory fac)
Create a scene builder with the given node factory. |
| Method Summary | |
void |
componentDecl(java.lang.String componentInfo)
A component declaration has been found in the code. |
void |
endDocument()
Declaration of the end of the document. |
void |
endExternProtoDecl()
Notification of the end of an EXTERNPROTO declaration. |
void |
endField()
Notification of the end of a field declaration. |
void |
endNode()
Notification of the end of a node declaration. |
void |
endProtoBody()
Notification of the end of an ordinary proto body. |
void |
endProtoDecl()
Notification of the end of an ordinary proto declaration statement. |
void |
endScriptDecl()
Notification of the end of a script declaration. |
void |
exportDecl(java.lang.String defName,
java.lang.String exported)
An EXPORT declaration has been found in the document. |
void |
externProtoURI(java.lang.String[] values)
Notification of the URI list for an EXTERNPROTO. |
void |
fieldValue(boolean value)
Set the value of the field at the given index as an boolean. |
void |
fieldValue(boolean[] value,
int len)
Set the value of the field at the given index as an array of boolean. |
void |
fieldValue(double value)
Set the value of the field at the given index as an double. |
void |
fieldValue(double[] value,
int len)
Set the value of the field at the given index as an array of doubles. |
void |
fieldValue(float value)
Set the value of the field at the given index as a float. |
void |
fieldValue(float[] value,
int len)
Set the value of the field at the given index as an array of floats. |
void |
fieldValue(int value)
Set the value of the field at the given index as an integer. |
void |
fieldValue(int[] value,
int len)
Set the value of the field at the given index as an array of integers. |
void |
fieldValue(long value)
Set the value of the field at the given index as an long. |
void |
fieldValue(long[] value,
int len)
Set the value of the field at the given index as an array of longs. |
void |
fieldValue(java.lang.String value)
The value of a normal field. |
void |
fieldValue(java.lang.String[] values)
The value of an MFField where the underlying parser knows about how the values are broken up. |
void |
fieldValue(java.lang.String[] value,
int len)
Set the value of the field at the given index as an array of strings. |
protected abstract void |
generateProtoCreator()
Generate a protoCreator instance now because one has not been set yet. |
NodeTemplateToInstanceCreator |
getProtoCreator()
Grab the proto creator instance in use by this builder. |
CRVRMLScene |
getScene()
Get the scene that was last built by this scene handler. |
void |
importDecl(java.lang.String inline,
java.lang.String exported,
java.lang.String imported)
An IMPORT declaration has been found in the document. |
void |
metaDecl(java.lang.String key,
java.lang.String value)
A META declaration has been found in the code. |
void |
profileDecl(java.lang.String profileName)
A profile declaration has been found in the code. |
void |
protoFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
Notification of a proto's field declaration. |
void |
protoIsDecl(java.lang.String fieldName)
Notification of a field value uses an IS statement. |
void |
reset()
Reset the builder. |
protected void |
resizeStack()
Resize the stack if needed. |
void |
routeDecl(java.lang.String srcNodeName,
java.lang.String srcFieldName,
java.lang.String destNodeName,
java.lang.String destFieldName)
Notification of a ROUTE declaration in the file. |
void |
scriptFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
Notification of a script's field declaration. |
void |
setDocumentLocator(Locator loc)
Set the document locator that can be used by the implementing code to find out information about the current line information. |
void |
setErrorReporter(ErrorReporter reporter)
Set the error handler instance used by this instance of the builder. |
void |
setFrameStateManager(FrameStateManager fsm)
Set the frame state manager to use for the builder after this point. |
void |
setGlobals(java.util.Map defs,
java.util.Map protos,
java.util.Map externProtos)
Set the global DEF map to be used within fields. |
void |
setLoadRequirements(boolean useVrml97,
boolean useBackgrounds,
boolean useFogs,
boolean useLights,
boolean useAudio,
boolean useViewpoints,
boolean useExternals)
Set the flags about what to load. |
void |
startDocument(java.lang.String uri,
java.lang.String url,
java.lang.String encoding,
java.lang.String type,
java.lang.String version,
java.lang.String comment)
Declaration of the start of the document. |
void |
startExternProtoDecl(java.lang.String name)
Notification of the start of an EXTERNPROTO declaration of the given name. |
void |
startField(java.lang.String name)
Notification of a field declaration. |
abstract void |
startNode(java.lang.String name,
java.lang.String defName)
Notification of the start of a node. |
void |
startProtoBody()
Notification of the start of an ordinary proto body. |
void |
startProtoDecl(java.lang.String name)
Notification of the start of an ordinary (inline) proto declaration. |
void |
startScriptDecl()
Notification of the start of a script declaration. |
void |
useDecl(java.lang.String defName)
The field value is a USE for the given node name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final java.lang.String BAD_METHOD_MSG
protected static final int STACK_START_SIZE
protected static final int STACK_INCREMENT
protected static final java.lang.String VRML97_PROFILE_STRING
protected static final java.lang.String VRML_IMPORT_ERROR
protected static final java.lang.String VRML_EXPORT_ERROR
protected CRProtoCreator protoCreator
protected boolean init
protected ErrorReporter errorReporter
protected Locator locator
protected VRMLFieldReader fieldParser
protected boolean inScript
protected int ignoreNodeCounter
protected boolean inStatic
protected int staticDepthCounter
protected boolean badFieldName
protected int currentFieldIndex
protected VRMLNodeType currentNode
protected VRMLScriptNodeType currentScript
protected CRVRMLScene scene
protected WriteableSceneMetaData metaData
protected VRMLWorldRootNodeType root
protected VRMLNodeType[] nodeStack
protected int[] childIndexStack
protected int topOfStack
protected java.util.Map defMap
protected java.util.Map protoMap
protected java.util.Map externProtoMap
protected java.util.Map importProxyMap
protected java.util.Map exportProxyMap
protected SimpleStack scriptStack
protected VRMLNodeFactory baseNodeFactory
protected VRMLNodeFactory nodeFactory
protected boolean isVrml97
protected HashSet dontLoadTypes
protected HashSet ignoreDefSet
protected HashSet staticNodeSet
protected java.lang.String worldURL
protected int majorVersion
protected int minorVersion
protected FrameStateManager stateManager
| Constructor Detail |
protected CRMainSceneBuilder(VRMLNodeFactory fac)
fac - The factory instance to use.
java.lang.NullPointerException - The factory reference is null| Method Detail |
public void setDocumentLocator(Locator loc)
startDocument() has
been called, you can assume that you will not have one available.
setDocumentLocator in interface ContentHandlerloc - The locator instance to use
public void startDocument(java.lang.String uri,
java.lang.String url,
java.lang.String encoding,
java.lang.String type,
java.lang.String version,
java.lang.String comment)
throws SAVException,
VRMLException
# start. The type string contains the representation of
the first few characters of the file after the #. This allows us to
work out if it is VRML97 or the later X3D spec.
Version numbers change from VRML97 to X3D and aren't logical. In the
first, it is #VRML V2.0 and the second is
#X3D V1.0 even though this second header represents a
later spec.
startDocument in interface ContentHandleruri - The URI of the file.url - The base URL of the file for resolving relative URIs
contained in the fileencoding - The encoding of this document - utf8 or binarytype - The bytes of the first part of the file headerversion - The VRML version of this documentcomment - Any trailing text on this line. If there is none, this
is null.
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void profileDecl(java.lang.String profileName)
throws SAVException,
VRMLException
profileDecl in interface ContentHandlerprofileName - The name of the profile to use
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void componentDecl(java.lang.String componentInfo)
throws SAVException,
VRMLException
componentDecl in interface ContentHandlercomponentInfo - The name of the component to use
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void metaDecl(java.lang.String key,
java.lang.String value)
throws SAVException,
VRMLException
metaDecl in interface ContentHandlerkey - The value of the key stringvalue - The value of the value string
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void importDecl(java.lang.String inline,
java.lang.String exported,
java.lang.String imported)
throws SAVException,
VRMLException
importDecl in interface ContentHandlerinline - The name of the inline DEF nodesexported - The exported name from the inlined fileimported - The local name to use for the exported name
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void exportDecl(java.lang.String defName,
java.lang.String exported)
throws SAVException,
VRMLException
exportDecl in interface ContentHandlerdefName - The DEF name of the nodes to be exportedexported - The name to be exported as
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void endDocument()
throws SAVException,
VRMLException
endDocument in interface ContentHandlerSAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public abstract void startNode(java.lang.String name,
java.lang.String defName)
throws SAVException,
VRMLException
startNode in interface ContentHandlername - The name of the node that we are about to parsedefName - The string associated with the DEF name. Null if not
given for this node.
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void endNode()
throws SAVException,
VRMLException
endNode in interface ContentHandlerSAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void startField(java.lang.String name)
throws SAVException,
VRMLException
ScriptHandler or ProtoHandler methods are
used.
startField in interface ContentHandlername - The name of the field declared
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void fieldValue(java.lang.String value)
throws SAVException,
VRMLException
startField() or endNode().
If this field is an SFNode with a USE declaration you will have the
useDecl(String) method called rather than this method.
fieldValue in interface StringContentHandlervalue - The value of this field
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void fieldValue(java.lang.String[] values)
throws SAVException,
VRMLException
fieldValue in interface StringContentHandlervalues - The list of string representing the values
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void useDecl(java.lang.String defName)
throws SAVException,
VRMLException
startField() or endNode().
useDecl in interface ContentHandlerdefName - The name of the DEF string to use
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void endField()
throws SAVException,
VRMLException
useDecl(String) or fieldValue(String).
endField in interface ContentHandlerSAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void fieldValue(int value)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the node
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(int[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(boolean value)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the node
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(boolean[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(float value)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the node
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(float[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(long value)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the node
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(long[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(double value)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the node
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(double[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void fieldValue(java.lang.String[] value,
int len)
throws SAVException,
VRMLException
fieldValue in interface BinaryContentHandlervalue - The new value to use for the nodelen - The number of valid entries in the value array
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException - This call is taken at the wrong time in the
structure of the document.
public void startProtoDecl(java.lang.String name)
throws SAVException,
VRMLException
startProtoDecl in interface ProtoHandlername - The name of the proto
SAVException - Always thrown
VRMLException - Never thrown
public void endProtoDecl()
throws SAVException,
VRMLException
endProtoDecl in interface ProtoHandlerSAVException - Always thrown
VRMLException - Never thrown
public void protoFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
throws SAVException,
VRMLException
protoFieldDecl in interface ProtoHandleraccess - The access type (eg exposedField, field etc)type - The field type (eg SFInt32, MFVec3d etc)name - The name of the fieldvalue - The default value of the field. Null if not allowed.
SAVException - Always thrown
VRMLException - Never thrown
public void protoIsDecl(java.lang.String fieldName)
throws SAVException,
VRMLException
protoIsDecl in interface ProtoHandlerfieldName - The name of the field that is being IS'd
SAVException - Always thrown
VRMLException - Never thrown
public void startProtoBody()
throws SAVException,
VRMLException
endProtoBody() statement form the body and not the normal
scenegraph information.
startProtoBody in interface ProtoHandlerSAVException - Always thrown
VRMLException - Never thrown
public void endProtoBody()
throws SAVException,
VRMLException
endProtoBody in interface ProtoHandlerSAVException - Always thrown
VRMLException - Never thrown
public void startExternProtoDecl(java.lang.String name)
throws SAVException,
VRMLException
endExternProtoDecl() call
you should only receive protoFieldDecl(int, java.lang.String, java.lang.String, java.lang.Object) calls.
startExternProtoDecl in interface ProtoHandlername - The node name of the extern proto
SAVException - Always thrown
VRMLException - Never thrown
public void endExternProtoDecl()
throws SAVException,
VRMLException
endExternProtoDecl in interface ProtoHandlerSAVException - Always thrown
VRMLException - Never thrown
public void externProtoURI(java.lang.String[] values)
throws SAVException,
VRMLException
externProtoURI in interface ProtoHandlervalues - A list of strings representing all of the URI values
SAVException - Always thrown
VRMLException - Never thrown
public void startScriptDecl()
throws SAVException,
VRMLException
endScriptDecl() call belong to this
script node. This method will be called after the ContentHandler
startNode() method call. All DEF information is contained
in that method call and this just signifies the start of script
processing so that we know to treat the field parsing callbacks a
little differently.
startScriptDecl in interface ScriptHandlerSAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void endScriptDecl()
throws SAVException,
VRMLException
endNode() callback.
endScriptDecl in interface ScriptHandlerSAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void scriptFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
throws SAVException,
VRMLException
url, mustEvaluate and
directOutput fields. These fields use the normal field
callbacks of ContentHandler.
scriptFieldDecl in interface ScriptHandleraccess - The access type (eg exposedField, field etc)type - The field type (eg SFInt32, MFVec3d etc)name - The name of the fieldvalue - The default value of the field
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsed
public void routeDecl(java.lang.String srcNodeName,
java.lang.String srcFieldName,
java.lang.String destNodeName,
java.lang.String destFieldName)
throws SAVException,
VRMLException
routeDecl in interface RouteHandlersrcNodeName - The name of the DEF of the source nodesrcFieldName - The name of the field to route values fromdestNodeName - The name of the DEF of the destination nodedestFieldName - The name of the field to route values to
SAVException - This call is taken at the wrong time in the
structure of the document
VRMLException - The content provided is invalid for this
part of the document or can't be parsedprotected abstract void generateProtoCreator()
public NodeTemplateToInstanceCreator getProtoCreator()
public void setErrorReporter(ErrorReporter reporter)
reporter - The instance to use or null to clearpublic CRVRMLScene getScene()
public void reset()
VRMLReader.parse() method is called.
The flags set about what to load are not reset by this method.
public void setGlobals(java.util.Map defs,
java.util.Map protos,
java.util.Map externProtos)
defs - The new DEF map to useprotos - The new proto map to useexternProtos - The new externproto map to use
public void setLoadRequirements(boolean useVrml97,
boolean useBackgrounds,
boolean useFogs,
boolean useLights,
boolean useAudio,
boolean useViewpoints,
boolean useExternals)
useVrml97 - true if the semantics should be VRML97 capable rather
than the looser VRML 3.0.useBackgrounds - true if BackgroundNodeTypes should be loadeduseFogs - true if FogNodeTypes should be loadeduseLights - true if LightNodeTypes should be loadeduseAudio - true if AudioClipNodeTypes should be loadeduseViewpoints - true if ViewpointNodeTypes should loadeduseExternals - true if ExternalNodeTypes should be loadedpublic void setFrameStateManager(FrameStateManager fsm)
fsm - The state manager to useprotected final void resizeStack()
| |||||