Class Converter


  • public final class Converter
    extends java.lang.Object
    Generic converter which uses the registry to do its conversions.
    Version:
    $Revision: fb73652dbc06 $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EXTENSION_SVG
      File extension for SVG.
      static java.lang.String TYPE_SVG
      Mime type for SVG.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Converter()
      Default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.awt.Dimension convert​(java.io.File inFile, java.io.File outFile, java.lang.String outFileType)
      Converts an existing file from MathML or ODF to the given type.
      java.awt.Dimension convert​(java.io.File inFile, java.io.File outFile, java.lang.String outFileType, LayoutContext params)
      Converts an existing file from MathML or ODF to the given type.
      java.awt.Dimension convert​(org.w3c.dom.Node doc, java.io.File outFile, java.lang.String outFileType, LayoutContext params)
      Converts an existing document from MathML to the given type and store it in a file.
      java.awt.Dimension convert​(org.w3c.dom.Node doc, java.io.OutputStream outStream, java.lang.String outFileType, LayoutContext params)
      Converts an existing file from MathML or ODF to the given type.
      ConverterPlugin.DocumentWithDimension convert​(org.w3c.dom.Node doc, java.lang.String outFileType, LayoutContext params)
      Converts an existing document from MathML to the given XML based type and store it in a DOM document.
      static Converter getConverter()
      Deprecated.
      use getInstance() instead.
      static Converter getInstance()
      Retrieve an instance of the converter singleton class.
      java.awt.image.BufferedImage render​(org.w3c.dom.Node node, LayoutContext context)
      Renders a document into an image.
      java.awt.image.BufferedImage render​(org.w3c.dom.Node node, LayoutContext context, int imageType)
      Renders a document into an image.
      • Methods inherited from class java.lang.Object

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

      • TYPE_SVG

        public static final java.lang.String TYPE_SVG
        Mime type for SVG.
        See Also:
        Constant Field Values
      • EXTENSION_SVG

        public static final java.lang.String EXTENSION_SVG
        File extension for SVG.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Converter

        protected Converter()
        Default constructor.
    • Method Detail

      • getInstance

        public static Converter getInstance()
        Retrieve an instance of the converter singleton class.
        Returns:
        a Converter object.
      • getConverter

        @Deprecated
        public static Converter getConverter()
        Deprecated.
        use getInstance() instead.
        Returns:
        Converter instance
      • convert

        public java.awt.Dimension convert​(java.io.File inFile,
                                          java.io.File outFile,
                                          java.lang.String outFileType)
                                   throws java.io.IOException
        Converts an existing file from MathML or ODF to the given type.
        Parameters:
        inFile - input file.
        outFile - output file.
        outFileType - mimetype for the output file.
        Returns:
        Dimension of converted image upon success, null otherwise
        Throws:
        java.io.IOException - if an I/O error occurred during read or write.
      • convert

        public java.awt.Dimension convert​(java.io.File inFile,
                                          java.io.File outFile,
                                          java.lang.String outFileType,
                                          LayoutContext params)
                                   throws java.io.IOException
        Converts an existing file from MathML or ODF to the given type.
        Parameters:
        inFile - input file.
        outFile - output file.
        outFileType - mimetype for the output file.
        params - rendering parameters.
        Returns:
        Dimension of converted image upon success, null otherwise
        Throws:
        java.io.IOException - if an I/O error occurred during read or write.
      • convert

        public java.awt.Dimension convert​(org.w3c.dom.Node doc,
                                          java.io.File outFile,
                                          java.lang.String outFileType,
                                          LayoutContext params)
                                   throws java.io.IOException
        Converts an existing document from MathML to the given type and store it in a file.
        Parameters:
        doc - input document. See net.sourceforge.jeuclid.DOMBuilder#DOMBuilder(Node, MathBase) for the list of valid node types.
        outFile - output file.
        outFileType - mimetype for the output file.
        params - parameter set to use for conversion.
        Returns:
        Dimension of converted image upon success, null otherwise
        Throws:
        java.io.IOException - if an I/O error occurred during read or write.
      • convert

        public ConverterPlugin.DocumentWithDimension convert​(org.w3c.dom.Node doc,
                                                             java.lang.String outFileType,
                                                             LayoutContext params)
        Converts an existing document from MathML to the given XML based type and store it in a DOM document.
        Parameters:
        doc - input document. See net.sourceforge.jeuclid.DOMBuilder#DOMBuilder(Node, MathBase) for the list of valid node types.
        outFileType - mimetype for the output file.
        params - parameter set to use for conversion.
        Returns:
        an instance of Document, or the appropriate subtype for this format (e.g. SVGDocument). If conversion is not supported to this type, it may return null.
      • convert

        public java.awt.Dimension convert​(org.w3c.dom.Node doc,
                                          java.io.OutputStream outStream,
                                          java.lang.String outFileType,
                                          LayoutContext params)
                                   throws java.io.IOException
        Converts an existing file from MathML or ODF to the given type.
        Parameters:
        doc - input document. See net.sourceforge.jeuclid.DOMBuilder#DOMBuilder(Node, MathBase) for the list of valid node types.
        outStream - output stream.
        outFileType - mimetype for the output file.
        params - parameter set to use for conversion.
        Returns:
        Dimension of converted image upon success, null otherwise
        Throws:
        java.io.IOException - if an I/O error occurred during read or write.
      • render

        public java.awt.image.BufferedImage render​(org.w3c.dom.Node node,
                                                   LayoutContext context)
                                            throws java.io.IOException
        Renders a document into an image.
        Parameters:
        node - Document / Node to render
        context - LayoutContext to use.
        Returns:
        the rendered image
        Throws:
        java.io.IOException - if an I/O error occurred.
      • render

        public java.awt.image.BufferedImage render​(org.w3c.dom.Node node,
                                                   LayoutContext context,
                                                   int imageType)
                                            throws java.io.IOException
        Renders a document into an image.
        Parameters:
        node - Document / Node to render
        context - LayoutContext to use.
        imageType - ImageType as defined by BufferedImage
        Returns:
        the rendered image
        Throws:
        java.io.IOException - if an I/O error occurred.