Class TeXFormula

java.lang.Object
org.scilab.forge.jlatexmath.TeXFormula
Direct Known Subclasses:
ArrayOfAtoms

public class TeXFormula extends Object
Represents a logical mathematical formula that will be displayed (by creating a TeXIcon from it and painting it) using algorithms that are based on the TeX algorithms.

These formula's can be built using the built-in primitive TeX parser (methods with String arguments) or using other TeXFormula objects. Most methods have (an) equivalent(s) where one or more TeXFormula arguments are replaced with String arguments. These are just shorter notations, because all they do is parse the string(s) to TeXFormula's and call an equivalent method with (a) TeXFormula argument(s). Most methods also come in 2 variants. One kind will use this TeXFormula to build another mathematical construction and then change this object to represent the newly build construction. The other kind will only use other TeXFormula's (or parse strings), build a mathematical construction with them and insert this newly build construction at the end of this TeXFormula. Because all the provided methods return a pointer to this (modified) TeXFormula (except for the createTeXIcon method that returns a TeXIcon pointer), method chaining is also possible.

Important: All the provided methods modify this TeXFormula object, but all the TeXFormula arguments of these methods will remain unchanged and independent of this TeXFormula object!

  • Field Details

  • Constructor Details

  • Method Details

    • addSymbolMappings

      public static void addSymbolMappings(InputStream in, String name) throws ResourceParseException
      Throws:
      ResourceParseException
    • setLaTeX

      public void setLaTeX(String ltx) throws ParseException
      Change the text of the TeXFormula and regenerate the root
      Parameters:
      ltx - the latex formula
      Throws:
      ParseException
    • add

      public TeXFormula add(Atom el)
      Inserts an atom at the end of the current formula
    • append

      public TeXFormula append(boolean isPartial, String s) throws ParseException
      Throws:
      ParseException
    • createTeXIcon

      public TeXIcon createTeXIcon(int style, float size)
      Creates a TeXIcon from this TeXFormula using the default TeXFont in the given point size and starting from the given TeX style. If the given integer value does not represent a valid TeX style, the default style TeXConstants.STYLE_DISPLAY will be used.
      Parameters:
      style - a TeX style constant (from TeXConstants) to start from
      size - the default TeXFont's point size
      Returns:
      the created TeXIcon
    • get

      public static TeXFormula get(String name) throws FormulaNotFoundException
      Get a predefined TeXFormula.
      Parameters:
      name - the name of the predefined TeXFormula
      Returns:
      a copy of the predefined TeXFormula
      Throws:
      FormulaNotFoundException - if no predefined TeXFormula is found with the given name