com.dessci.mathflow.sdk.composer
Class EquationComposer

java.lang.Object
  extended by com.dessci.mathflow.sdk.composer.EquationComposer
All Implemented Interfaces:
com.dessci.mathflow.sdk.composer.ComposerConstants, com.dessci.mathflow.sdk.license.LicenseConstants

public class EquationComposer
extends java.lang.Object
implements com.dessci.mathflow.sdk.license.LicenseConstants, com.dessci.mathflow.sdk.composer.ComposerConstants

This class is used to generate equation images from MathML. It can produce EPS (Windows only), GIF, and PNG image types.


Field Summary
 
Fields inherited from interface com.dessci.mathflow.sdk.license.LicenseConstants
debugMode, DESSCI_KEY, DOCUMENT_COMPOSER, DOCUMENT_COMPOSER_FOR_JAVA, DSI_LICENSE_DAEMON, EQUATION_COMPOSER, EQUATION_COMPOSER_FOR_JAVA, EVAL_LICENSE_FOR_APPLETS, FLEXLM_LIB_NAME, FLEXLM_LIC, LICENSE_EXPIRED, LICENSE_FILE_NAME, LICENSE_FOLDER_NAME, LICENSE_ID, LICENSE_INVALID, LICENSE_NOT_AVAILABLE, LICENSE_OK, SIMPLE_EDITOR, STRUCTURE_EDITOR, STYLE_EDITOR
 
Fields inherited from interface com.dessci.mathflow.sdk.composer.ComposerConstants
_IMAGES, _OUT, ANTIALIASINGOFF, BACKGROUND, BG, BLACK, BREAKWIDTH, CHARMAP, DEBUG, DPI, FALSE, FG, FONT_MAPPING_FILE, FONTMAPPING, FONTMETRICS, FOREGROUND, GIF, IMAGEFOLDER, IMAGENAME, IMAGES, IMAGETYPE, IMG, IMGTYPE, INPUTDOC, LICENSE, LOGFILE, MATHML, MATHMLFILE, MUTE, NONE, NORMAL, OPDICT, OPTIONS, OUTPUTDOC, OUTPUTTYPE, PADDING, PNG, POINTSIZE, READOPTIONS, SAVEOPTIONS, SIZE, TAB, TRANSPARENT, TRUE, VERBOSITY, WHITE
 
Constructor Summary
EquationComposer()
           
 
Method Summary
 void ClearLastMessage()
          Clears the last saved error string.
 java.awt.Image GenerateImageData()
          Generates and returns the equation image based on the current settings.
 void GenerateImageFile()
          Generates the equation image file based on the current settings.
 int GetAscent()
          Returns the ascent above the baseline of the last equation image generated or -1 if no image has been generated.
 java.lang.String GetBackground()
          Returns the background color of the equation.
 int GetBaseline()
          Returns the baseline of the last equation image generated or -1 if no image has been generated.
 int GetBreakWidth()
          Returns the width in pixels where line wrapping for long equations should occur, or 0 if line wrapping is disabled.
 java.lang.String GetCharMap()
          Returns the path to the character mapping file.
 int GetDPI()
          Returns the DPI for the equation image.
 java.lang.String GetFontMapping()
          Returns the path to the font mapping file.
 java.lang.String GetForeground()
          Returns the foreground color of the equation.
 int GetHeight()
          Returns the height of the last equation image generated or -1 if no image has been generated.
 java.lang.String GetImageFolder()
          Returns the path to the folder that will contain the image files.
 java.lang.String GetImageName()
          Returns the base file name for the equation image.
 java.lang.String GetImageType()
          Returns the type of the equation image.
 java.lang.String GetLastMessage()
          Returns the last saved error string.
 java.lang.String GetLicense()
          Returns the path to the FlexLM license file or the MathFlow SDK registration key, depending on the license type.
 java.lang.String GetLogFile()
          Returns the path to the log file that we write error messages to.
 java.lang.String GetMathML()
          Returns the MathML for the equation.
 java.lang.String GetOperatorDictionary()
          Returns the path to the operator dictionary file
 int GetPadding()
          Returns the padding around the border of the equation image.
 int GetPointSize()
          Returns the base point size of the equation.
 boolean GetUseAntialias()
          Returns whether anti-aliasing is used.
 java.lang.String GetVerbosity()
          Returns what processing messages should be displayed.
 int GetWidth()
          Returns the width of the last equation image generated or -1 if no image has been generated.
 void LoadMathML(java.lang.String mathmlfile)
          Loads the MathML for the equation from the specified file.
static void main(java.lang.String[] args)
           
 void PaintEquation(java.awt.Graphics g, int x, int y)
          Renders the equation for the current MathML in the given graphics at the given location.
 void ReadOptions(java.lang.String readoptions)
          Reads all the settings from the specified XML file.
 void SaveOptions(java.lang.String saveoptions)
          Writes all the settings to the specified XML file.
 void SetBackground(java.lang.String bg)
          Sets the background color for the equation.
 void SetBreakWidth(int breakwidth)
          Sets the width where line wrapping for long equations should occur.
 void SetCharMap(java.lang.String charmap)
          Sets the path to the character mapping file.
 void SetDPI(int dpi)
          Sets the DPI for the equation image.
 void SetFontMapping(java.lang.String fontmapping)
          Sets the path to the font mapping file.
 void SetForeground(java.lang.String fg)
          Sets the foreground color for the equation.
 void SetImageFolder(java.lang.String imagefolder)
          Sets the path to the folder that will contain the image files.
 void SetImageName(java.lang.String imagename)
          Sets the base file name for the equation image.
 void SetImageType(java.lang.String imagetype)
          Sets the type of the equation image.
 void SetLicense(java.lang.String license)
          Sets the path to the FlexLM license file or the MathFlow SDK registration key.
 void SetLogFile(java.lang.String logfile)
          Sets the path to the log file that we write error messages to.
 void SetMathML(java.lang.String mathml)
          Sets the MathML for the equation.
 void SetOperatorDictionary(java.lang.String filepath)
          Sets the path to the operator dictionary file
 void SetPadding(int padding)
          Sets the padding around the border of the equation image.
 void SetPointSize(int pointsize)
          Sets the base point size of the equation.
 void SetUseAntialias(boolean b)
          Sets whether to use anti-aliasing.
 void SetVerbosity(java.lang.String verbosity)
          Sets what processing messages should be displayed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EquationComposer

public EquationComposer()
Method Detail

ClearLastMessage

public void ClearLastMessage()
Clears the last saved error string.


GenerateImageData

public java.awt.Image GenerateImageData()
                                 throws com.dessci.mathflow.sdk.license.LicenseException
Generates and returns the equation image based on the current settings.

Returns:
the equation image for the current MathML or null if the MathML is invalid
Throws:
com.dessci.mathflow.sdk.license.LicenseException

GenerateImageFile

public void GenerateImageFile()
                       throws com.dessci.mathflow.sdk.license.LicenseException,
                              java.lang.Exception
Generates the equation image file based on the current settings.

Throws:
com.dessci.mathflow.sdk.license.LicenseException
java.lang.Exception

GetAscent

public int GetAscent()
Returns the ascent above the baseline of the last equation image generated or -1 if no image has been generated.

Returns:
the ascent of equation image in pixels

GetBackground

public java.lang.String GetBackground()
Returns the background color of the equation.

Returns:
the background color of the equation

GetBaseline

public int GetBaseline()
Returns the baseline of the last equation image generated or -1 if no image has been generated.

Returns:
the baseline of equation image in pixels

GetBreakWidth

public int GetBreakWidth()
Returns the width in pixels where line wrapping for long equations should occur, or 0 if line wrapping is disabled.

Returns:
the width where line wrapping for long equations should occur or 0 if line wrapping is disabled

GetCharMap

public java.lang.String GetCharMap()
Returns the path to the character mapping file.

Returns:
the path to the character mapping file

GetDPI

public int GetDPI()
Returns the DPI for the equation image.

Returns:
the DPI for the equation image

GetFontMapping

public java.lang.String GetFontMapping()
Returns the path to the font mapping file.

Returns:
the path to the font mapping file

GetForeground

public java.lang.String GetForeground()
Returns the foreground color of the equation.

Returns:
the foreground color of the equation

GetHeight

public int GetHeight()
Returns the height of the last equation image generated or -1 if no image has been generated.

Returns:
the height of equation image in pixels

GetImageFolder

public java.lang.String GetImageFolder()
Returns the path to the folder that will contain the image files.

Returns:
the path to the folder that will contain the image files

GetImageName

public java.lang.String GetImageName()
Returns the base file name for the equation image.

Returns:
the base file name for the equation image

GetImageType

public java.lang.String GetImageType()
Returns the type of the equation image. The valid values are "png" and "gif".

Returns:
the image type

GetLastMessage

public java.lang.String GetLastMessage()
Returns the last saved error string.

Returns:
the last saved error string

GetLicense

public java.lang.String GetLicense()
Returns the path to the FlexLM license file or the MathFlow SDK registration key, depending on the license type.

Returns:
the path to the FlexLM license file or the MathFlow SDK registration key, depending on the license type.

GetLogFile

public java.lang.String GetLogFile()
Returns the path to the log file that we write error messages to.

Returns:
the path to the log file

GetMathML

public java.lang.String GetMathML()
Returns the MathML for the equation.

Returns:
the MathML for the equation

GetOperatorDictionary

public java.lang.String GetOperatorDictionary()
Returns the path to the operator dictionary file

Returns:
the path to the operator dictionary file

GetPadding

public int GetPadding()
Returns the padding around the border of the equation image.

Returns:
the padding around the border of the equation image

GetPointSize

public int GetPointSize()
Returns the base point size of the equation.

Returns:
the base point size of the equation

GetUseAntialias

public boolean GetUseAntialias()
Returns whether anti-aliasing is used.

Returns:
true if anti-aliasing is use, false otherwise

GetVerbosity

public java.lang.String GetVerbosity()
Returns what processing messages should be displayed. The valid values are "mute", "normal", and "debug".

Returns:
the level of processing information that should be displayed

GetWidth

public int GetWidth()
Returns the width of the last equation image generated or -1 if no image has been generated.

Returns:
the width of equation image in pixels

LoadMathML

public void LoadMathML(java.lang.String mathmlfile)
                throws java.lang.IllegalArgumentException,
                       java.io.IOException
Loads the MathML for the equation from the specified file.

Parameters:
mathmlfile - the file that contains the MathML for the equation
Throws:
java.lang.IllegalArgumentException
java.io.IOException

main

public static void main(java.lang.String[] args)

PaintEquation

public void PaintEquation(java.awt.Graphics g,
                          int x,
                          int y)
                   throws com.dessci.mathflow.sdk.license.LicenseException
Renders the equation for the current MathML in the given graphics at the given location. The location is that of the positioning point for the equation, i.e. the left end point of the equation's baseline.

Parameters:
g - the graphics object to paint the equation
x - the x coordinate for the positioning point
y - the y coordinate for the positioning point
Throws:
com.dessci.mathflow.sdk.license.LicenseException

ReadOptions

public void ReadOptions(java.lang.String readoptions)
                 throws java.lang.Exception
Reads all the settings from the specified XML file.

Parameters:
readoptions - the XML file that we read the settings from
Throws:
java.lang.Exception

SaveOptions

public void SaveOptions(java.lang.String saveoptions)
                 throws java.lang.Exception
Writes all the settings to the specified XML file.

Parameters:
saveoptions - the XML file that we write the settings to
Throws:
java.lang.Exception

SetBackground

public void SetBackground(java.lang.String bg)
                   throws java.lang.IllegalArgumentException
Sets the background color for the equation.

Parameters:
bg - the background color of the equation, in the format of #rgb, #rrggbb or the HTML color name
Throws:
java.lang.IllegalArgumentException

SetBreakWidth

public void SetBreakWidth(int breakwidth)
                   throws java.lang.IllegalArgumentException
Sets the width where line wrapping for long equations should occur.

Parameters:
breakwidth - the width where line wrapping for long equations should occur or 0 if line wrapping is disabled
Throws:
java.lang.IllegalArgumentException

SetCharMap

public void SetCharMap(java.lang.String charmap)
                throws java.lang.IllegalArgumentException
Sets the path to the character mapping file.

Parameters:
charmap - the full path to the character mapping file
Throws:
java.lang.IllegalArgumentException

SetDPI

public void SetDPI(int dpi)
            throws java.lang.IllegalArgumentException
Sets the DPI for the equation image.

Parameters:
dpi - the DPI for the equation image
Throws:
java.lang.IllegalArgumentException

SetFontMapping

public void SetFontMapping(java.lang.String fontmapping)
Sets the path to the font mapping file.

Parameters:
fontmapping - the path to the font mapping file

SetForeground

public void SetForeground(java.lang.String fg)
                   throws java.lang.IllegalArgumentException
Sets the foreground color for the equation.

Parameters:
fg - the foreground color for the equation, in the format of #rgb, #rrggbb or the HTML color name
Throws:
java.lang.IllegalArgumentException

SetImageFolder

public void SetImageFolder(java.lang.String imagefolder)
Sets the path to the folder that will contain the image files. The folder will be created if it does not already exist.

Parameters:
imagefolder - the path to the folder that will contain the image files

SetImageName

public void SetImageName(java.lang.String imagename)
                  throws java.lang.IllegalArgumentException
Sets the base file name for the equation image. The file will be overwritten if it already exists.

Parameters:
imagename - the base file name for the equation image
Throws:
java.lang.IllegalArgumentException

SetImageType

public void SetImageType(java.lang.String imagetype)
                  throws java.lang.IllegalArgumentException
Sets the type of the equation image. The valid values are "png" and "gif".

Parameters:
imagetype - the image type
Throws:
java.lang.IllegalArgumentException

SetLicense

public void SetLicense(java.lang.String license)
                throws com.dessci.mathflow.sdk.license.LicenseException,
                       java.lang.StringIndexOutOfBoundsException
Sets the path to the FlexLM license file or the MathFlow SDK registration key.

Parameters:
license - the path to the FlexLM license file or the MathFlow SDK registration key
Throws:
com.dessci.mathflow.sdk.license.LicenseException
java.lang.StringIndexOutOfBoundsException

SetLogFile

public void SetLogFile(java.lang.String logfile)
                throws java.lang.IllegalArgumentException
Sets the path to the log file that we write error messages to.

Parameters:
logfile - the path to the log file
Throws:
java.lang.IllegalArgumentException

SetMathML

public void SetMathML(java.lang.String mathml)
               throws java.lang.IllegalArgumentException
Sets the MathML for the equation.

Parameters:
mathml - the MathML for the equation
Throws:
java.lang.IllegalArgumentException

SetOperatorDictionary

public void SetOperatorDictionary(java.lang.String filepath)
                           throws java.lang.IllegalArgumentException
Sets the path to the operator dictionary file

Parameters:
filepath - the full path to the operator dictionary file
Throws:
java.lang.IllegalArgumentException

SetPadding

public void SetPadding(int padding)
                throws java.lang.IllegalArgumentException
Sets the padding around the border of the equation image.

Parameters:
padding - the padding around the border of the equation image
Throws:
java.lang.IllegalArgumentException

SetPointSize

public void SetPointSize(int pointsize)
                  throws java.lang.IllegalArgumentException
Sets the base point size of the equation.

Parameters:
pointsize - the base point size of the equation
Throws:
java.lang.IllegalArgumentException

SetUseAntialias

public void SetUseAntialias(boolean b)
Sets whether to use anti-aliasing.

Parameters:
b - true if to use anti-aliasing, false otherwise

SetVerbosity

public void SetVerbosity(java.lang.String verbosity)
                  throws java.lang.IllegalArgumentException
Sets what processing messages should be displayed. The valid values are "mute", "normal", and "debug".

Parameters:
verbosity - the level of processing information that should be displayed
Throws:
java.lang.IllegalArgumentException

Copyright (c) 2015 Design Science
All rights reserved