Package xj3d.filter.importer
Class AC3DFileParser
java.lang.Object
xj3d.filter.importer.AC3DFileParser
- All Implemented Interfaces:
org.j3d.loaders.ac3d.Ac3dParseObserver
,NonWeb3DFileParser
public class AC3DFileParser
extends Object
implements NonWeb3DFileParser, org.j3d.loaders.ac3d.Ac3dParseObserver
File parser implementation that reads AC3D files and generates an X3D stream
of events.
- Version:
- 1.0
- Author:
- Ben Yarger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
closeObjectTag
(org.j3d.loaders.ac3d.Ac3dObject obj) Closes the appropriate x3d tags at the end of object processing.void
Adds closing transform tags.boolean
createMaterial
(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the appearance and material.boolean
createObjectTag
(org.j3d.loaders.ac3d.Ac3dObject obj) Create opening tags for the basic object types.boolean
createPolyGeometry
(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the geometry for poly objects.boolean
createPolyLineGeometry
(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the geometry for poly line and line objects.void
createTransformTag
(org.j3d.loaders.ac3d.Ac3dObject obj) Creates transform data.Fetch the locator used by this parser.void
Initialise the internals of the parser at start up.boolean
materialComplete
(org.j3d.loaders.ac3d.Ac3dMaterial mat) A material block has been read from the file.boolean
objectComplete
(org.j3d.loaders.ac3d.Ac3dObject parent, org.j3d.loaders.ac3d.Ac3dObject obj) Callback for when an object has been loaded by the parser.Checks the object stack to create the correct parent child relationship and then passes the object along for processing.parse
(InputSource input, String[] style) Begins processing the input stream from the parser.void
Set the content handler instance.void
setDocumentUrl
(String url) Set the base URL of the document that is about to be parsed.void
Set the error handler instance.void
setErrorReporter
(org.j3d.util.ErrorReporter eh) Set the error reporter instance.void
Set the proto handler instance.void
Set the route handler instance.void
Set the script handler instance.boolean
surfaceComplete
(org.j3d.loaders.ac3d.Ac3dObject obj, org.j3d.loaders.ac3d.Ac3dSurface surf) Callback for when a surface definition from the parser has been read.
-
Constructor Details
-
AC3DFileParser
public AC3DFileParser()Create a new instance of this parser.
-
-
Method Details
-
initialize
public void initialize()Initialise the internals of the parser at start up. If you are not using the detailed constructors, this needs to be called to ensure that all internal states are correctly set up.- Specified by:
initialize
in interfaceNonWeb3DFileParser
-
setDocumentUrl
Set the base URL of the document that is about to be parsed. Users should always call this to make sure we have correct behaviour for the ContentHandler'sstartDocument()
call.The URL is cleared at the end of each document run. Therefore it is imperative that it gets called each time you use the parser.
- Specified by:
setDocumentUrl
in interfaceNonWeb3DFileParser
- Parameters:
url
- The document url to set
-
getDocumentLocator
Fetch the locator used by this parser. This is here so that the user of this parser can ask for it and set it before calling startDocument(). Once the scene has started parsing in this class it is too late for the locator to be set. This parser does set it internally when asked for aX3DRelaxedParser.Scene()
but there may be other times when it is not set.- Specified by:
getDocumentLocator
in interfaceNonWeb3DFileParser
- Returns:
- The locator used for syntax errors
-
setContentHandler
Set the content handler instance.- Specified by:
setContentHandler
in interfaceNonWeb3DFileParser
- Parameters:
ch
- The content handler instance to use
-
setRouteHandler
Set the route handler instance.- Specified by:
setRouteHandler
in interfaceNonWeb3DFileParser
- Parameters:
rh
- The route handler instance to use
-
setScriptHandler
Set the script handler instance.- Specified by:
setScriptHandler
in interfaceNonWeb3DFileParser
- Parameters:
sh
- The script handler instance to use
-
setProtoHandler
Set the proto handler instance.- Specified by:
setProtoHandler
in interfaceNonWeb3DFileParser
- Parameters:
ph
- The proto handler instance to use
-
setErrorHandler
Set the error handler instance.- Specified by:
setErrorHandler
in interfaceNonWeb3DFileParser
- Parameters:
eh
- The error handler instance to use
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter eh) Set the error reporter instance. If this is also an ErrorHandler instance, the document locator will also be set.- Specified by:
setErrorReporter
in interfaceNonWeb3DFileParser
- Parameters:
eh
- The error handler instance to use
-
materialComplete
public boolean materialComplete(org.j3d.loaders.ac3d.Ac3dMaterial mat) A material block has been read from the file. Callback to handle materials as they are found.- Specified by:
materialComplete
in interfaceorg.j3d.loaders.ac3d.Ac3dParseObserver
- Parameters:
mat
- The material definition- Returns:
- true if to keep reading
-
objectComplete
public boolean objectComplete(org.j3d.loaders.ac3d.Ac3dObject parent, org.j3d.loaders.ac3d.Ac3dObject obj) Callback for when an object has been loaded by the parser.Checks the object stack to create the correct parent child relationship and then passes the object along for processing.- Specified by:
objectComplete
in interfaceorg.j3d.loaders.ac3d.Ac3dParseObserver
- Parameters:
parent
- The parent object that contains this surfaceobj
- The object that was just read- Returns:
- true if to keep reading
-
surfaceComplete
public boolean surfaceComplete(org.j3d.loaders.ac3d.Ac3dObject obj, org.j3d.loaders.ac3d.Ac3dSurface surf) Callback for when a surface definition from the parser has been read.- Specified by:
surfaceComplete
in interfaceorg.j3d.loaders.ac3d.Ac3dParseObserver
- Parameters:
obj
- The parent object that contains this surfacesurf
- The surface object that has been read- Returns:
- true if to keep reading
-
createTransformTag
public void createTransformTag(org.j3d.loaders.ac3d.Ac3dObject obj) Creates transform data.- Parameters:
obj
- The object definition.
-
closeTransformTag
public void closeTransformTag()Adds closing transform tags. -
createObjectTag
public boolean createObjectTag(org.j3d.loaders.ac3d.Ac3dObject obj) Create opening tags for the basic object types.- Parameters:
obj
- The Object definition.- Returns:
-
createMaterial
public boolean createMaterial(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the appearance and material.- Parameters:
obj
- The object definition.- Returns:
-
createPolyGeometry
public boolean createPolyGeometry(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the geometry for poly objects.- Parameters:
obj
- The object definition.- Returns:
-
createPolyLineGeometry
public boolean createPolyLineGeometry(org.j3d.loaders.ac3d.Ac3dObject obj) Creates the geometry for poly line and line objects.- Parameters:
obj
- The object definition.- Returns:
-
closeObjectTag
public boolean closeObjectTag(org.j3d.loaders.ac3d.Ac3dObject obj) Closes the appropriate x3d tags at the end of object processing.- Parameters:
obj
- The object definition.- Returns:
-
parse
Begins processing the input stream from the parser.- Specified by:
parse
in interfaceNonWeb3DFileParser
- Parameters:
input
- The stream to read fromstyle
- The style or null or no styling- Returns:
- Null if no parsing issues or a messages detailing the issues
- Throws:
IOException
- An I/O error while reading the streamVRMLParseException
- A parsing error occurred in the fileSAVNotSupportedException
- The input file is not VRML97 UTF8 encoded.VRMLException
-