public class TeXFormula extends Object
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!
| Modifier and Type | Class and Description |
|---|---|
class |
TeXFormula.TeXIconBuilder
Apply the Builder pattern instead of using the createTeXIcon(...) factories
|
| Modifier and Type | Field and Description |
|---|---|
static int |
BOLD |
static Map<Character.UnicodeBlock,org.scilab.forge.jlatexmath.TeXFormula.FontInfos> |
externalFontMap |
static float |
FONT_SCALE_FACTOR |
boolean |
isColored |
static int |
ITALIC |
protected Map<String,String> |
jlmXMLMap |
List<MiddleAtom> |
middle |
static float |
PIXELS_PER_POINT |
protected static float |
PREC |
static Map<String,TeXFormula> |
predefinedTeXFormulas |
static Map<String,String> |
predefinedTeXFormulasAsString |
static int |
ROMAN |
Atom |
root |
static int |
SANSSERIF |
static int |
SERIF |
static String[] |
symbolFormulaMappings |
static String[] |
symbolMappings |
static String[] |
symbolTextMappings |
String |
textStyle |
static int |
TYPEWRITER |
static String |
VERSION |
| Modifier | Constructor and Description |
|---|---|
|
TeXFormula()
Creates 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,
Map<String,String> map)
Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).
|
|
TeXFormula(String s,
String textStyle) |
|
TeXFormula(String s,
String textStyle,
boolean firstpass,
boolean space) |
|
TeXFormula(TeXFormula f)
Creates a new TeXFormula that is a copy of the given TeXFormula.
|
protected |
TeXFormula(TeXParser tp)
Creates an empty TeXFormula.
|
protected |
TeXFormula(TeXParser tp,
String s)
Creates a new TeXFormula by parsing the given string (using a primitive TeX parser).
|
protected |
TeXFormula(TeXParser tp,
String s,
boolean firstpass) |
protected |
TeXFormula(TeXParser tp,
String s,
String textStyle) |
protected |
TeXFormula(TeXParser tp,
String s,
String textStyle,
boolean firstpass,
boolean space) |
| Modifier and Type | Method and Description |
|---|---|
TeXFormula |
add(Atom el)
Inserts an atom at the end of the current formula
|
TeXFormula |
add(String s)
Parses the given string and inserts the resulting formula
at the end of the current TeXFormula.
|
TeXFormula |
add(TeXFormula f)
Inserts the given TeXFormula at the end of the current TeXFormula.
|
static void |
addPredefinedCommands(InputStream xmlFile) |
static void |
addPredefinedTeXFormula(InputStream xmlFile) |
TeXFormula |
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.
|
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.
|
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 void |
addSymbolMappings(InputStream in,
String name) |
static void |
addSymbolMappings(String file) |
TeXFormula |
append(boolean isPartial,
String s) |
TeXFormula |
append(String s) |
TeXFormula |
centerOnAxis()
Centers the current TeXformula vertically on the axis (defined by the parameter
"axisheight" in the resource "DefaultTeXFont.xml".
|
Image |
createBufferedImage(int style,
float size,
Color fg,
Color bg) |
static Image |
createBufferedImage(String formula,
int style,
float size,
Color fg,
Color bg) |
void |
createGIF(int style,
float size,
String out,
Color bg,
Color fg) |
void |
createImage(String format,
int style,
float size,
String out,
Color bg,
Color fg,
boolean transparency) |
void |
createJPEG(int style,
float size,
String out,
Color bg,
Color fg) |
void |
createPNG(int style,
float size,
String out,
Color bg,
Color fg) |
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.
|
TeXIcon |
createTeXIcon(int style,
float size,
boolean trueValues) |
TeXIcon |
createTeXIcon(int style,
float size,
int type) |
TeXIcon |
createTeXIcon(int style,
float size,
int type,
Color fgcolor) |
TeXIcon |
createTeXIcon(int style,
float size,
int widthUnit,
float textwidth,
int align) |
TeXIcon |
createTeXIcon(int style,
float size,
int widthUnit,
float textwidth,
int align,
int interlineUnit,
float interline) |
TeXIcon |
createTeXIcon(int style,
float size,
int type,
int widthUnit,
float textwidth,
int align) |
TeXIcon |
createTeXIcon(int style,
float size,
int type,
int widthUnit,
float textwidth,
int align,
int interlineUnit,
float interline) |
static TeXFormula |
get(String name)
Get a predefined TeXFormula.
|
static TeXFormula |
getAsText(String text,
int alignment) |
static org.scilab.forge.jlatexmath.TeXFormula.FontInfos |
getExternalFont(Character.UnicodeBlock block) |
boolean |
getLookAtLastAtom() |
static TeXFormula |
getPartialTeXFormula(String formula) |
static boolean |
isRegisteredBlock(Character.UnicodeBlock block) |
static void |
registerExternalFont(Character.UnicodeBlock block,
String fontName) |
static void |
registerExternalFont(Character.UnicodeBlock block,
String sansserif,
String serif) |
static void |
registerFonts(boolean b) |
TeXFormula |
setBackground(Color c)
Changes the background color of the current TeXFormula into the given color.
|
TeXFormula |
setColor(Color c)
Changes the (foreground) color of the current TeXFormula into the given color.
|
void |
setDEBUG(boolean b) |
static void |
setDefaultDPI()
Set the default target DPI to the screen dpi (only if we're in non-headless mode)
|
static void |
setDPITarget(float dpi)
Set the DPI of target
|
TeXFormula |
setFixedTypes(int leftType,
int rightType)
Sets a fixed left and right type of the current TeXFormula.
|
void |
setLaTeX(String ltx)
Change the text of the TeXFormula and regenerate the root
|
void |
setLookAtLastAtom(boolean b) |
public static final String VERSION
public static final int SERIF
public static final int SANSSERIF
public static final int BOLD
public static final int ITALIC
public static final int ROMAN
public static final int TYPEWRITER
public static float PIXELS_PER_POINT
public static float FONT_SCALE_FACTOR
protected static final float PREC
public static Map<String,TeXFormula> predefinedTeXFormulas
public static String[] symbolMappings
public static String[] symbolTextMappings
public static String[] symbolFormulaMappings
public static Map<Character.UnicodeBlock,org.scilab.forge.jlatexmath.TeXFormula.FontInfos> externalFontMap
public List<MiddleAtom> middle
public Atom root
public String textStyle
public boolean isColored
public TeXFormula()
public TeXFormula(String s, Map<String,String> map) throws ParseException
s - the string to be parsedParseException - if the string could not be parsed correctlypublic TeXFormula(String s) throws ParseException
s - the string to be parsedParseException - if the string could not be parsed correctlypublic TeXFormula(String s, boolean firstpass) throws ParseException
ParseExceptionpublic TeXFormula(String s, String textStyle) throws ParseException
ParseExceptionpublic TeXFormula(String s, String textStyle, boolean firstpass, boolean space) throws ParseException
ParseExceptionpublic TeXFormula(TeXFormula f)
Both TeXFormula's are independent of one another!
f - the formula to be copiedprotected TeXFormula(TeXParser tp)
protected TeXFormula(TeXParser tp, String s) throws ParseException
s - the string to be parsedParseException - if the string could not be parsed correctlyprotected TeXFormula(TeXParser tp, String s, boolean firstpass) throws ParseException
ParseExceptionprotected TeXFormula(TeXParser tp, String s, String textStyle) throws ParseException
ParseExceptionprotected TeXFormula(TeXParser tp, String s, String textStyle, boolean firstpass, boolean space) throws ParseException
ParseExceptionpublic static void addSymbolMappings(String file) throws ResourceParseException
ResourceParseExceptionpublic static void addSymbolMappings(InputStream in, String name) throws ResourceParseException
ResourceParseExceptionpublic static boolean isRegisteredBlock(Character.UnicodeBlock block)
public static org.scilab.forge.jlatexmath.TeXFormula.FontInfos getExternalFont(Character.UnicodeBlock block)
public static void registerExternalFont(Character.UnicodeBlock block, String sansserif, String serif)
public static void registerExternalFont(Character.UnicodeBlock block, String fontName)
public static void setDPITarget(float dpi)
dpi - the target DPIpublic static void setDefaultDPI()
public static TeXFormula getAsText(String text, int alignment) throws ParseException
ParseExceptionpublic static TeXFormula getPartialTeXFormula(String formula)
a - formulapublic static void registerFonts(boolean b)
b - true if the fonts should be registered (Java 1.6 only) to be used
with FOP.public void setLaTeX(String ltx) throws ParseException
ltx - the latex formulaParseExceptionpublic TeXFormula add(Atom el)
public TeXFormula add(String s) throws ParseException
s - the string to be parsed and insertedParseException - if the string could not be parsed correctlypublic TeXFormula append(String s) throws ParseException
ParseExceptionpublic TeXFormula append(boolean isPartial, String s) throws ParseException
ParseExceptionpublic TeXFormula add(TeXFormula f)
f - the TeXFormula to be insertedpublic void setLookAtLastAtom(boolean b)
public boolean getLookAtLastAtom()
public TeXFormula centerOnAxis()
public static void addPredefinedTeXFormula(InputStream xmlFile) throws ResourceParseException
ResourceParseExceptionpublic static void addPredefinedCommands(InputStream xmlFile) throws ResourceParseException
ResourceParseExceptionpublic TeXFormula addStrut(int unit, float width, float height, float depth) throws InvalidUnitException
unit - a unit constant (from TeXConstants)width - the width of the strut boxheight - the height of the strut boxdepth - the depth of the strut boxInvalidUnitException - if the given integer value does not represent
a valid unitpublic TeXFormula addStrut(int type) throws InvalidUnitException
type - thinmuskip, medmuskip or thickmuskip (from TeXConstants)InvalidUnitException - if the given integer value does not represent
a valid unitpublic TeXFormula addStrut(int widthUnit, float width, int heightUnit, float height, int depthUnit, float depth) throws InvalidUnitException
widthUnit - a unit constant used for the width (from TeXConstants)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 boxInvalidUnitException - if the given integer value does not represent
a valid unitpublic TeXIcon createTeXIcon(int style, float size)
style - a TeX style constant (from TeXConstants) to start fromsize - the default TeXFont's point sizepublic TeXIcon createTeXIcon(int style, float size, int type)
public TeXIcon createTeXIcon(int style, float size, boolean trueValues)
public TeXIcon createTeXIcon(int style, float size, int widthUnit, float textwidth, int align)
public TeXIcon createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align)
public TeXIcon createTeXIcon(int style, float size, int widthUnit, float textwidth, int align, int interlineUnit, float interline)
public TeXIcon createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align, int interlineUnit, float interline)
public void createImage(String format, int style, float size, String out, Color bg, Color fg, boolean transparency)
public static Image createBufferedImage(String formula, int style, float size, Color fg, Color bg) throws ParseException
formula - the formulastyle - the stylesize - the sizetransparency, - if true the background is transparentParseExceptionpublic Image createBufferedImage(int style, float size, Color fg, Color bg) throws ParseException
formula - the formulastyle - the stylesize - the sizetransparency, - if true the background is transparentParseExceptionpublic void setDEBUG(boolean b)
public TeXFormula setBackground(Color c)
c - the desired background color for the current TeXFormulapublic TeXFormula setColor(Color c)
c - the desired foreground color for the current TeXFormulapublic TeXFormula setFixedTypes(int leftType, int rightType) throws InvalidAtomTypeException
leftType - atom type constant (from TeXConstants)rightType - atom type constant (from TeXConstants)InvalidAtomTypeException - if the given integer value does not represent
a valid atom typepublic static TeXFormula get(String name) throws FormulaNotFoundException
name - the name of the predefined TeXFormulaFormulaNotFoundException - if no predefined TeXFormula is found with the
given nameCopyright © 2014–2018. All rights reserved.