Xj3D VRML/X3D Code API

org.web3d.vrml.export.compressors
Class IndexedFaceSetCompressor

java.lang.Object
  extended byorg.web3d.vrml.export.compressors.IndexedFaceSetCompressor
All Implemented Interfaces:
NodeCompressor

public class IndexedFaceSetCompressor
extends java.lang.Object
implements NodeCompressor

A node compressor for IndexedFaceSet nodes. Index fields will be compressed using delta encoding and by removing -1 if the faces are all the same size.. This will use the Java3D compression utilities only if the Coordinate node is not USED.

Version:
$Revision: 1.5 $
Author:
Alan Hudson.

Constructor Summary
IndexedFaceSetCompressor()
           
 
Method Summary
 boolean canSupport(int nodeNumber, int method)
          Can this NodeCompressor support this compression method
 void componentDecl(java.lang.String componentName)
          A component declaration has been found in the code.
 void endDocument()
          Declaration of the end of the document.
 void endField()
          Notification of the end of a field declaration.
 void endNode()
          Notification of the end of a node declaration.
 void exportDecl(java.lang.String defName, java.lang.String exported)
          An EXPORT declaration has been found in the document.
 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 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 reinit(java.io.DataOutputStream dos, VRMLFieldReader vfr)
          Reinitialize this class for a new instance.
 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 startDocument(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 startField(java.lang.String name)
          Notification of a field declaration.
 void startNode(java.lang.String name, java.lang.String defName)
          Notification of the start of a node.
 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
 
Methods inherited from interface org.web3d.vrml.export.compressors.NodeCompressor
compress, decompress, fillData, getEncoderMetadata, handleData
 

Constructor Detail

IndexedFaceSetCompressor

public IndexedFaceSetCompressor()
Method Detail

reinit

public void reinit(java.io.DataOutputStream dos,
                   VRMLFieldReader vfr)
Reinitialize this class for a new instance.

Parameters:
dos - The output stream to use.
vfr - The field parser to use.

canSupport

public boolean canSupport(int nodeNumber,
                          int method)
Can this NodeCompressor support this compression method

Parameters:
nodeNumber - What node, constant defined by Web3D Consortium
method - What method of compression. 0-127 defined by Web3D Consortium.

setDocumentLocator

public 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. This method is called by the parser to your code to give you a locator to work with. If this has not been set by the time startDocument() has been called, you can assume that you will not have one available.

Parameters:
loc - The locator instance to use

startDocument

public void startDocument(java.lang.String url,
                          java.lang.String encoding,
                          java.lang.String type,
                          java.lang.String version,
                          java.lang.String comment)
                   throws SAVException,
                          VRMLException
Declaration of the start of the document. The parameters are all of the values that are declared on the header line of the file after the # 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.

Parameters:
url - The base URL of the file for resolving relative URIs contained in the file
encoding - The encoding of this document - utf8 or binary
type - The bytes of the first part of the file header
version - The full VRML version string of this document
comment - Any trailing text on this line. If there is none, this is null.
Throws:
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.

profileDecl

public void profileDecl(java.lang.String profileName)
                 throws SAVException,
                        VRMLException
A profile declaration has been found in the code. IAW the X3D specification, this method will only ever be called once in the lifetime of the parser for this document. The name is the name of the profile for the document to use.

Parameters:
profileName - The name of the profile to use
Throws:
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.

componentDecl

public void componentDecl(java.lang.String componentName)
                   throws SAVException,
                          VRMLException
A component declaration has been found in the code. There may be zero or more component declarations in the file, appearing just after the profile declaration. The textual information after the COMPONENT keyword is left unparsed and presented through this call. It is up to the user application to parse the component information.

Parameters:
componentName - The name of the component to use
Throws:
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.

metaDecl

public void metaDecl(java.lang.String key,
                     java.lang.String value)
              throws SAVException,
                     VRMLException
A META declaration has been found in the code. There may be zero or more meta declarations in the file, appearing just after the component declaration. Each meta declaration has a key and value strings. No information is to be implied from this. It is for extra data only.

Parameters:
key - The value of the key string
value - The value of the value string
Throws:
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.

importDecl

public void importDecl(java.lang.String inline,
                       java.lang.String exported,
                       java.lang.String imported)
                throws SAVException,
                       VRMLException
An IMPORT declaration has been found in the document. All three parameters will always be provided, regardless of whether the AS keyword has been used or not. The parser implementation will automatically set the local import name as needed.

Parameters:
inline - The name of the inline DEF nodes
exported - The exported name from the inlined file
imported - The local name to use for the exported name
Throws:
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.

exportDecl

public void exportDecl(java.lang.String defName,
                       java.lang.String exported)
                throws SAVException,
                       VRMLException
An EXPORT declaration has been found in the document. Both paramters will always be provided regardless of whether the AS keyword has been used. The parser implementation will automatically set the exported name as needed.

Parameters:
defName - The DEF name of the nodes to be exported
exported - The name to be exported as
Throws:
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.

endDocument

public void endDocument()
                 throws SAVException,
                        VRMLException
Declaration of the end of the document. There will be no further parsing and hence events after this.

Throws:
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.

startNode

public void startNode(java.lang.String name,
                      java.lang.String defName)
               throws SAVException,
                      VRMLException
Notification of the start of a node. This is the opening statement of a node and it's DEF name. USE declarations are handled in a separate method.

Parameters:
name - The name of the node that we are about to parse
defName - The string associated with the DEF name. Null if not given for this node.
Throws:
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.

endNode

public void endNode()
             throws SAVException,
                    VRMLException
Notification of the end of a node declaration.

Throws:
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.

startField

public void startField(java.lang.String name)
                throws SAVException,
                       VRMLException
Notification of a field declaration. This notification is only called if it is a standard node. If the node is a script or PROTO declaration then the ScriptHandler or ProtoHandler methods are used.

Parameters:
name - The name of the field declared
Throws:
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.

fieldValue

public void fieldValue(java.lang.String value)
                throws SAVException,
                       VRMLException
The value of a normal field. This is a string that represents the entire value of the field. MFStrings will have to be parsed. This is a terminating call for startField as well. The next call will either be another 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. If the SFNode is empty the value returned here will be "NULL".

There are times where we have an MFField that is declared in the file to be empty. To signify this case, this method will be called with a parameter value of null. A lot of the time this is because we can't really determine if the incoming node is an MFNode or not.

Parameters:
value - The value of this field
Throws:
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.

fieldValue

public void fieldValue(java.lang.String[] values)
                throws SAVException,
                       VRMLException
The value of an MFField where the underlying parser knows about how the values are broken up. The parser is not required to support this callback, but implementors of this interface should understand it. The most likely time we will have this method called is for MFString or URL lists. If called, it is guaranteed to split the strings along the SF node type boundaries.

Parameters:
values - The list of string representing the values
Throws:
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.

useDecl

public void useDecl(java.lang.String defName)
             throws SAVException,
                    VRMLException
The field value is a USE for the given node name. This is a terminating call for startField as well. The next call will either be another startField() or endNode().

Parameters:
defName - The name of the DEF string to use
Throws:
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.

endField

public void endField()
              throws SAVException,
                     VRMLException
Notification of the end of a field declaration. This is called only at the end of an MFNode declaration. All other fields are terminated by either useDecl(String) or fieldValue(String). This will only ever be called if there have been nodes declared. If no nodes have been declared (ie "[]") then you will get a fieldValue(). call with the parameter value of null.

Throws:
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.

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium