Class TeXFormula
- Direct Known Subclasses:
ArrayOfAtoms
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!
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassApply the Builder pattern instead of using the createTeXIcon(...) factories -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic Map<Character.UnicodeBlock, org.scilab.forge.jlatexmath.TeXFormula.FontInfos> booleanstatic final intstatic floatprotected static final floatstatic Map<String, TeXFormula> static final intstatic final intstatic final intstatic String[]static String[]static String[]static final intstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates an empty TeXFormula.TeXFormula(String s) Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).TeXFormula(String s, boolean firstpass) TeXFormula(String s, String textStyle) TeXFormula(String s, String textStyle, boolean firstpass, boolean space) TeXFormula(String s, Map<String, String> map) Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).Creates a new TeXFormula that is a copy of the given TeXFormula.protectedTeXFormula(TeXParser tp) Creates an empty TeXFormula.protectedTeXFormula(TeXParser tp, String s) Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).protectedTeXFormula(TeXParser tp, String s, boolean firstpass) protectedTeXFormula(TeXParser tp, String s, String textStyle) protectedTeXFormula(TeXParser tp, String s, String textStyle, boolean firstpass, boolean space) -
Method Summary
Modifier and TypeMethodDescriptionParses the given string and inserts the resulting formula at the end of the current TeXFormula.Inserts an atom at the end of the current formulaadd(TeXFormula f) Inserts the given TeXFormula at the end of the current TeXFormula.static voidaddPredefinedCommands(InputStream xmlFile) static voidaddPredefinedTeXFormula(InputStream xmlFile) addStrut(int type) Inserts a strut box (whitespace) with the given width, height and depth (in the given unit) at the end of the current TeXFormula.addStrut(int unit, float width, float height, float depth) Inserts a strut box (whitespace) with the given width, height and depth (in the given unit) at the end of the current TeXFormula.addStrut(int widthUnit, float width, int heightUnit, float height, int depthUnit, float depth) Inserts a strut box (whitespace) with the given width (in widthUnits), height (in heightUnits) and depth (in depthUnits) at the end of the current TeXFormula.static voidaddSymbolMappings(InputStream in, String name) static voidaddSymbolMappings(String file) Centers the current TeXformula vertically on the axis (defined by the parameter "axisheight" in the resource "DefaultTeXFont.xml".createBufferedImage(int style, float size, Color fg, Color bg) static ImagecreateBufferedImage(String formula, int style, float size, Color fg, Color bg) voidvoidcreateImage(String format, int style, float size, String out, Color bg, Color fg, boolean transparency) voidcreateJPEG(int style, float size, String out, Color bg, Color fg) voidcreateTeXIcon(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.createTeXIcon(int style, float size, boolean trueValues) createTeXIcon(int style, float size, int type) createTeXIcon(int style, float size, int widthUnit, float textwidth, int align) createTeXIcon(int style, float size, int widthUnit, float textwidth, int align, int interlineUnit, float interline) createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align) createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align, int interlineUnit, float interline) createTeXIcon(int style, float size, int type, Color fgcolor) static TeXFormulaGet a predefined TeXFormula.static TeXFormulastatic org.scilab.forge.jlatexmath.TeXFormula.FontInfosbooleanstatic TeXFormulagetPartialTeXFormula(String formula) static booleanstatic voidregisterExternalFont(Character.UnicodeBlock block, String fontName) static voidregisterExternalFont(Character.UnicodeBlock block, String sansserif, String serif) static voidregisterFonts(boolean b) Changes the background color of the current TeXFormula into the given color.Changes the (foreground) color of the current TeXFormula into the given color.voidsetDEBUG(boolean b) static voidSet the default target DPI to the screen dpi (only if we're in non-headless mode)static voidsetDPITarget(float dpi) Set the DPI of targetsetFixedTypes(int leftType, int rightType) Sets a fixed left and right type of the current TeXFormula.voidChange the text of the TeXFormula and regenerate the rootvoidsetLookAtLastAtom(boolean b)
-
Field Details
-
VERSION
- See Also:
-
SERIF
public static final int SERIF- See Also:
-
SANSSERIF
public static final int SANSSERIF- See Also:
-
BOLD
public static final int BOLD- See Also:
-
ITALIC
public static final int ITALIC- See Also:
-
ROMAN
public static final int ROMAN- See Also:
-
TYPEWRITER
public static final int TYPEWRITER- See Also:
-
PIXELS_PER_POINT
public static float PIXELS_PER_POINT -
PREC
protected static final float PREC- See Also:
-
predefinedTeXFormulas
-
predefinedTeXFormulasAsString
-
symbolMappings
-
symbolTextMappings
-
symbolFormulaMappings
-
externalFontMap
public static Map<Character.UnicodeBlock, org.scilab.forge.jlatexmath.TeXFormula.FontInfos> externalFontMap -
middle
-
jlmXMLMap
-
root
-
textStyle
-
isColored
public boolean isColored
-
-
Constructor Details
-
TeXFormula
public TeXFormula()Creates an empty TeXFormula. -
TeXFormula
Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).- Parameters:
s- the string to be parsed- Throws:
ParseException- if the string could not be parsed correctly
-
TeXFormula
Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).- Parameters:
s- the string to be parsed- Throws:
ParseException- if the string could not be parsed correctly
-
TeXFormula
- Throws:
ParseException
-
TeXFormula
- Throws:
ParseException
-
TeXFormula
public TeXFormula(String s, String textStyle, boolean firstpass, boolean space) throws ParseException - Throws:
ParseException
-
TeXFormula
Creates a new TeXFormula that is a copy of the given TeXFormula.Both TeXFormula's are independent of one another!
- Parameters:
f- the formula to be copied
-
TeXFormula
Creates an empty TeXFormula. -
TeXFormula
Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).- Parameters:
s- the string to be parsed- Throws:
ParseException- if the string could not be parsed correctly
-
TeXFormula
- Throws:
ParseException
-
TeXFormula
- Throws:
ParseException
-
TeXFormula
protected TeXFormula(TeXParser tp, String s, String textStyle, boolean firstpass, boolean space) throws ParseException - Throws:
ParseException
-
-
Method Details
-
addSymbolMappings
- Throws:
ResourceParseException
-
addSymbolMappings
- Throws:
ResourceParseException
-
isRegisteredBlock
-
getExternalFont
public static org.scilab.forge.jlatexmath.TeXFormula.FontInfos getExternalFont(Character.UnicodeBlock block) -
registerExternalFont
public static void registerExternalFont(Character.UnicodeBlock block, String sansserif, String serif) -
registerExternalFont
-
setDPITarget
public static void setDPITarget(float dpi) Set the DPI of target- Parameters:
dpi- the target DPI
-
setDefaultDPI
public static void setDefaultDPI()Set the default target DPI to the screen dpi (only if we're in non-headless mode) -
getAsText
- Throws:
ParseException
-
getPartialTeXFormula
- Parameters:
a- formula- Returns:
- a partial TeXFormula containing the valid part of formula
-
registerFonts
public static void registerFonts(boolean b) - Parameters:
b- true if the fonts should be registered (Java 1.6 only) to be used with FOP.
-
setLaTeX
Change the text of the TeXFormula and regenerate the root- Parameters:
ltx- the latex formula- Throws:
ParseException
-
add
Inserts an atom at the end of the current formula -
add
Parses the given string and inserts the resulting formula at the end of the current TeXFormula.- Parameters:
s- the string to be parsed and inserted- Returns:
- the modified TeXFormula
- Throws:
ParseException- if the string could not be parsed correctly
-
append
- Throws:
ParseException
-
append
- Throws:
ParseException
-
add
Inserts the given TeXFormula at the end of the current TeXFormula.- Parameters:
f- the TeXFormula to be inserted- Returns:
- the modified TeXFormula
-
setLookAtLastAtom
public void setLookAtLastAtom(boolean b) -
getLookAtLastAtom
public boolean getLookAtLastAtom() -
centerOnAxis
Centers the current TeXformula vertically on the axis (defined by the parameter "axisheight" in the resource "DefaultTeXFont.xml".- Returns:
- the modified TeXFormula
-
addPredefinedTeXFormula
- Throws:
ResourceParseException
-
addPredefinedCommands
- Throws:
ResourceParseException
-
addStrut
public TeXFormula addStrut(int unit, float width, float height, float depth) throws InvalidUnitException Inserts a strut box (whitespace) with the given width, height and depth (in the given unit) at the end of the current TeXFormula.- Parameters:
unit- a unit constant (fromTeXConstants)width- the width of the strut boxheight- the height of the strut boxdepth- the depth of the strut box- Returns:
- the modified TeXFormula
- Throws:
InvalidUnitException- if the given integer value does not represent a valid unit
-
addStrut
Inserts a strut box (whitespace) with the given width, height and depth (in the given unit) at the end of the current TeXFormula.- Parameters:
type- thinmuskip, medmuskip or thickmuskip (fromTeXConstants)- Returns:
- the modified TeXFormula
- Throws:
InvalidUnitException- if the given integer value does not represent a valid unit
-
addStrut
public TeXFormula addStrut(int widthUnit, float width, int heightUnit, float height, int depthUnit, float depth) throws InvalidUnitException Inserts a strut box (whitespace) with the given width (in widthUnits), height (in heightUnits) and depth (in depthUnits) at the end of the current TeXFormula.- Parameters:
widthUnit- a unit constant used for the width (fromTeXConstants)width- the width of the strut boxheightUnit- a unit constant used for the height (from TeXConstants)height- the height of the strut boxdepthUnit- a unit constant used for the depth (from TeXConstants)depth- the depth of the strut box- Returns:
- the modified TeXFormula
- Throws:
InvalidUnitException- if the given integer value does not represent a valid unit
-
createTeXIcon
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 (fromTeXConstants) to start fromsize- the default TeXFont's point size- Returns:
- the created TeXIcon
-
createTeXIcon
-
createTeXIcon
-
createTeXIcon
-
createTeXIcon
-
createTeXIcon
public TeXIcon createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align) -
createTeXIcon
public TeXIcon createTeXIcon(int style, float size, int widthUnit, float textwidth, int align, int interlineUnit, float interline) -
createTeXIcon
public TeXIcon createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align, int interlineUnit, float interline) -
createImage
-
createPNG
-
createGIF
-
createJPEG
-
createBufferedImage
public static Image createBufferedImage(String formula, int style, float size, Color fg, Color bg) throws ParseException - Parameters:
formula- the formulastyle- the stylesize- the sizetransparency- , if true the background is transparent- Returns:
- the generated image
- Throws:
ParseException
-
createBufferedImage
- Parameters:
style- the stylesize- the sizeformula- the formulatransparency- , if true the background is transparent- Returns:
- the generated image
- Throws:
ParseException
-
setDEBUG
public void setDEBUG(boolean b) -
setBackground
Changes the background color of the current TeXFormula into the given color. By default, a TeXFormula has no background color, it's transparent. The backgrounds of subformula's will be painted on top of the background of the whole formula! Any changes that will be made to this TeXFormula after this background color was set, will have the default background color (unless it will also be changed into another color afterwards)!- Parameters:
c- the desired background color for the current TeXFormula- Returns:
- the modified TeXFormula
-
setColor
Changes the (foreground) color of the current TeXFormula into the given color. By default, the foreground color of a TeXFormula is the foreground color of the component on which the TeXIcon (created from this TeXFormula) will be painted. The color of subformula's overrides the color of the whole formula. Any changes that will be made to this TeXFormula after this color was set, will be painted in the default color (unless the color will also be changed afterwards into another color)!- Parameters:
c- the desired foreground color for the current TeXFormula- Returns:
- the modified TeXFormula
-
setFixedTypes
Sets a fixed left and right type of the current TeXFormula. This has an influence on the glue that will be inserted before and after this TeXFormula.- Parameters:
leftType- atom type constant (fromTeXConstants)rightType- atom type constant (from TeXConstants)- Returns:
- the modified TeXFormula
- Throws:
InvalidAtomTypeException- if the given integer value does not represent a valid atom type
-
get
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
-