Class FileSurfaceXML_J3D.SurfaceXMLHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
    Enclosing class:
    FileSurfaceXML_J3D

    private class FileSurfaceXML_J3D.SurfaceXMLHandler
    extends org.xml.sax.helpers.DefaultHandler
    Used by the XML Parser to parse the Surface.XML header.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.String currentKey
      Current XML keyword:.
      (package private) java.lang.String elementBuffer
      Current buffer:.
      (package private) FileInfoSurfaceXML_J3D fileInfo
      fileInfo data structure for reading the surface information into:.
      private int[] m_aiIndex
      Triangle mesh connectivity (index) array.
      private javax.vecmath.Color4f[] m_akColors
      Triangle mesh colors (may be null).
      private javax.vecmath.Vector3f[] m_akNormals
      Triangle mesh normals (may be null).
      private javax.vecmath.Point3f[] m_akVertices
      Vertex, Normal, and Connectivity arrays to read into from the file:.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int length)
      Text data callback from parser.
      void endDocument()
      Do nothing.
      void endElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
      Called by parser when the end of an element is reached in the document.
      private javax.vecmath.Color3f getColor​(java.lang.String kParseString)
      Called when reading the input surface.xml file: Parses the input string into a Color3f variable:
      private void getColors​(java.lang.String kParseString)
      Called when reading the input surface.xml file: Parses the input string into a an array of Color4f[], representing the mesh per-vertex colors:
      java.lang.String getColorString​(javax.vecmath.Color3f kColor)
      Called when writing the surface.xml file: Converts the input Color3f to a String for writing:
      java.lang.String getColorString​(javax.vecmath.Color4f[] akColors)
      Called when writing the surface.xml file: Converts the input array of Color4f[] to a String for writing:
      private void getConnectivity​(java.lang.String kParseString)
      Called when reading the input surface.xml file: Parses the input string into a an array of int[] to represent the mesh connectivity:
      java.lang.String getIndexString​(int[] aiConnectivity)
      Called when writing the surface.xml file: Converts the input array of int[] to a String for writing:
      private void getNormals​(java.lang.String kParseString)
      Called when reading the input surface.xml file: Parses the input string into a an array of Vector3f[], representing the mesh normals:
      java.lang.String getNormalString​(javax.vecmath.Vector3f[] akNormals)
      Called when writing the surface.xml file: Converts the input array of Vector3f[] to a String for writing:
      java.lang.String getVertexString​(javax.vecmath.Point3f[] akVertices)
      Called when writing the surface.xml file: Converts the input array of Point3f[] to a String for writing:
      private void getVertices​(java.lang.String kParseString)
      Called when reading the input surface.xml file: Parses the input string into a an array of Point3f[], representing the mesh vertices:
      void skippedEntity​(java.lang.String name)
      Do nothing but show the entity we skipped.
      void startElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
      Parser calls this for the beginning of each element in the document.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • currentKey

        java.lang.String currentKey
        Current XML keyword:.
      • elementBuffer

        java.lang.String elementBuffer
        Current buffer:.
      • m_aiIndex

        private int[] m_aiIndex
        Triangle mesh connectivity (index) array.
      • m_akColors

        private javax.vecmath.Color4f[] m_akColors
        Triangle mesh colors (may be null).
      • m_akNormals

        private javax.vecmath.Vector3f[] m_akNormals
        Triangle mesh normals (may be null).
      • m_akVertices

        private javax.vecmath.Point3f[] m_akVertices
        Vertex, Normal, and Connectivity arrays to read into from the file:.
    • Constructor Detail

      • SurfaceXMLHandler

        public SurfaceXMLHandler​(FileInfoSurfaceXML_J3D fInfo)
        Creates a new SurfaceXMLHandler object.
        Parameters:
        fInfo - FileInfo for storing the file data into.
    • Method Detail

      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
        Text data callback from parser. If the parser is not validating, this method can report whitespace. We ignore strings that are entirely whitespace.
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        ch - Character array
        start - Start of data in array.
        length - Length of data in array.
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Do nothing.
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException - never happens
      • endElement

        public void endElement​(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Called by parser when the end of an element is reached in the document.
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        namespaceURI - the namespace uri
        localName - the element name
        qName - the qualified name
        Throws:
        org.xml.sax.SAXException - if a problem is encountered during parsing
      • getColorString

        public java.lang.String getColorString​(javax.vecmath.Color3f kColor)
        Called when writing the surface.xml file: Converts the input Color3f to a String for writing:
        Parameters:
        kColor - color object
        Returns:
        the color in string format
      • getColorString

        public java.lang.String getColorString​(javax.vecmath.Color4f[] akColors)
        Called when writing the surface.xml file: Converts the input array of Color4f[] to a String for writing:
        Parameters:
        akColors - array of Color4f, representing the surface triangle mesh per-vertex colors.
        Returns:
        colors array in string format
      • getIndexString

        public java.lang.String getIndexString​(int[] aiConnectivity)
        Called when writing the surface.xml file: Converts the input array of int[] to a String for writing:
        Parameters:
        aiConnectivity - the connectivity array
        Returns:
        the connectivity array in string format
      • getNormalString

        public java.lang.String getNormalString​(javax.vecmath.Vector3f[] akNormals)
        Called when writing the surface.xml file: Converts the input array of Vector3f[] to a String for writing:
        Parameters:
        akNormals - normals array
        Returns:
        normals array in string format
      • getVertexString

        public java.lang.String getVertexString​(javax.vecmath.Point3f[] akVertices)
        Called when writing the surface.xml file: Converts the input array of Point3f[] to a String for writing:
        Parameters:
        akVertices - mesh coordinate array
        Returns:
        mesh coordinate array in string format
      • skippedEntity

        public void skippedEntity​(java.lang.String name)
        Do nothing but show the entity we skipped.
        Specified by:
        skippedEntity in interface org.xml.sax.ContentHandler
        Overrides:
        skippedEntity in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        name - the skipped entity name
      • startElement

        public void startElement​(java.lang.String namespaceURI,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
        Parser calls this for the beginning of each element in the document.
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        namespaceURI - the namespace uri
        localName - the element name
        qName - the qualified name
        atts - the attached attributes
        Throws:
        org.xml.sax.SAXException - if a problem is encountered during parsing
      • getColor

        private javax.vecmath.Color3f getColor​(java.lang.String kParseString)
        Called when reading the input surface.xml file: Parses the input string into a Color3f variable:
        Parameters:
        kParseString - input string containing the material color
        Returns:
        the material color in Color3f format
      • getColors

        private void getColors​(java.lang.String kParseString)
        Called when reading the input surface.xml file: Parses the input string into a an array of Color4f[], representing the mesh per-vertex colors:
        Parameters:
        kParseString - input sting containing per-vertex color information.
      • getConnectivity

        private void getConnectivity​(java.lang.String kParseString)
        Called when reading the input surface.xml file: Parses the input string into a an array of int[] to represent the mesh connectivity:
        Parameters:
        kParseString - the string containing the connectivity information
      • getNormals

        private void getNormals​(java.lang.String kParseString)
        Called when reading the input surface.xml file: Parses the input string into a an array of Vector3f[], representing the mesh normals:
        Parameters:
        kParseString - string containing mesh normals
      • getVertices

        private void getVertices​(java.lang.String kParseString)
        Called when reading the input surface.xml file: Parses the input string into a an array of Point3f[], representing the mesh vertices:
        Parameters:
        kParseString - string containing mesh coordinates