net.sourceforge.jeuclid.converter
Class Converter

java.lang.Object
  extended by net.sourceforge.jeuclid.converter.Converter

public final class Converter
extends Object

Generic converter which uses the registry to do its conversions.

Version:
$Revision: 0bed7fec74b0 $

Field Summary
static String EXTENSION_SVG
          File extension for SVG.
static String TYPE_SVG
          Mime type for SVG.
 
Constructor Summary
protected Converter()
          Default constructor.
 
Method Summary
 Dimension convert(File inFile, File outFile, String outFileType)
          Converts an existing file from MathML or ODF to the given type.
 Dimension convert(File inFile, File outFile, String outFileType, LayoutContext params)
          Converts an existing file from MathML or ODF to the given type.
 Dimension convert(Node doc, File outFile, String outFileType, LayoutContext params)
          Converts an existing document from MathML to the given type and store it in a file.
 Dimension convert(Node doc, OutputStream outStream, String outFileType, LayoutContext params)
          Converts an existing document from MathML to the given XML based type and writes it to the provided output stream.
 ConverterPlugin.DocumentWithDimension convert(Node doc, String outFileType, LayoutContext params)
          Converts an existing document from MathML to the given XML based type and store it in a DOM document.
 Dimension convert(String docString, OutputStream outStream, String outFileType, LayoutContext params)
          Converts an XML string from MathML to the given XML based type and writes it to the provided output stream.
static Converter getConverter()
          Deprecated. use getInstance() instead.
static Converter getInstance()
          Retrieve an instance of the converter singleton class.
 BufferedImage render(Node node, LayoutContext context)
          Renders a document into an image.
 BufferedImage render(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 String TYPE_SVG
Mime type for SVG.

See Also:
Constant Field Values

EXTENSION_SVG

public static final 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 Dimension convert(File inFile,
                         File outFile,
                         String outFileType)
                  throws 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:
IOException - if an I/O error occurred during read or write.

convert

public Dimension convert(File inFile,
                         File outFile,
                         String outFileType,
                         LayoutContext params)
                  throws 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:
IOException - if an I/O error occurred during read or write.

convert

public Dimension convert(Node doc,
                         File outFile,
                         String outFileType,
                         LayoutContext params)
                  throws 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:
IOException - if an I/O error occurred during read or write.

convert

public ConverterPlugin.DocumentWithDimension convert(Node doc,
                                                     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 Dimension convert(Node doc,
                         OutputStream outStream,
                         String outFileType,
                         LayoutContext params)
                  throws IOException
Converts an existing document from MathML to the given XML based type and writes it to the provided output stream.

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:
IOException - if an I/O error occurred during read or write.

convert

public Dimension convert(String docString,
                         OutputStream outStream,
                         String outFileType,
                         LayoutContext params)
                  throws IOException
Converts an XML string from MathML to the given XML based type and writes it to the provided output stream.

Parameters:
docString - XML string representing a valid document
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:
IOException - if an I/O error occurred during read or write.

render

public BufferedImage render(Node node,
                            LayoutContext context)
                     throws IOException
Renders a document into an image.

Parameters:
node - Document / Node to render
context - LayoutContext to use.
Returns:
the rendered image
Throws:
IOException - if an I/O error occurred.

render

public BufferedImage render(Node node,
                            LayoutContext context,
                            int imageType)
                     throws 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:
IOException - if an I/O error occurred.


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.