jaxe.equations
Class MathBase

java.lang.Object
  extended by jaxe.equations.MathBase

public class MathBase
extends java.lang.Object

The base for creating a MathElement tree

Version:
%I%, %G%
Author:
Stephan Michels, Marco Sielaff

Field Summary
private  boolean debug
           
static int DISPLAY
          Non inline mathematical expression
private  int displayfontsize
           
private  java.awt.FontMetrics[] fontmetrics
           
private  java.lang.String fontname
           
private  java.awt.Font[] fonts
           
private  int fontstyle
           
private  java.util.Vector<java.awt.Font> goodFonts
           
static int INLINE
          Inline mathematical expression
private  int inlinefontsize
           
private static org.apache.log4j.Logger LOG
          Logger for this class
private  int maxfontsize
           
private  int minfontsize
           
private  int mode
           
private  int[] MS_Symbol_codes
           
private  MathRootElement rootElement
           
private  char[] Symbol_chars
           
private  java.awt.FontMetrics[] symbolFontmetrics
           
private  java.awt.Font[] symbolFonts
           
 boolean windaube
           
 
Constructor Summary
MathBase(MathRootElement element, java.awt.Graphics gcalc)
          Creates a MathBase
MathBase(MathRootElement element, java.lang.String fontname, int fontstyle, int inlinefontsize, int displayfontsize, java.awt.Graphics gcalc)
          Creates a MathBase
MathBase(java.lang.String fontname, int fontstyle, int inlinefontsize, int displayfontsize, java.awt.Graphics gcalc)
          Creates a MathBase
 
Method Summary
 java.lang.String findFont(java.lang.String s, java.awt.Font defaultFont)
           
 int getDefaultDisplayFontSize()
          Get the default font size for non inline equations
 int getDefaultInlineFontSize()
          Get the default font size
 java.awt.Font getFont(int fontsize)
          Get a font specified by the font size
 java.awt.FontMetrics getFontMetrics(int fontsize)
          Get the font metrics specified by the font size
 int getHeight()
          Return the current height of this component
 java.awt.Font getSymbolFont(int fontsize)
          Get a symbol font specified by the font size
 java.awt.FontMetrics getSymbolFontMetrics(int fontsize)
          Get the font metrics of the symbol font specified by the font size
 java.awt.font.GlyphVector getSymbolGlyphVector(java.awt.Graphics2D g2d, int fontsize, char c)
          Get a glyph vector of the symbol font
 int getWidth()
          Return the current width of this component
 boolean isDebug()
          Indicates, if the debug mode is enabled
 void paint(java.awt.Graphics g)
          Paints this component and all of its elements
 void setDebug(boolean debug)
          Enables, or disables the debug mode
 void setDefaultDisplayFontSize(int fontsize)
          Sets the default font size for non inline equations
 void setDefaultFontSize(int fontsize)
          Sets the default font size, which used for the root element
 void setRootElement(MathRootElement element)
          Set the root element of a math tree
private  void setupFontMetrics(java.awt.Graphics gcalc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG
Logger for this class


fontname

private java.lang.String fontname

fontstyle

private int fontstyle

inlinefontsize

private int inlinefontsize

displayfontsize

private int displayfontsize

minfontsize

private final int minfontsize
See Also:
Constant Field Values

maxfontsize

private final int maxfontsize
See Also:
Constant Field Values

fonts

private final java.awt.Font[] fonts

fontmetrics

private java.awt.FontMetrics[] fontmetrics

symbolFonts

private final java.awt.Font[] symbolFonts

symbolFontmetrics

private java.awt.FontMetrics[] symbolFontmetrics

debug

private boolean debug

INLINE

public static final int INLINE
Inline mathematical expression

See Also:
Constant Field Values

DISPLAY

public static final int DISPLAY
Non inline mathematical expression

See Also:
Constant Field Values

mode

private final int mode
See Also:
Constant Field Values

rootElement

private MathRootElement rootElement

windaube

public boolean windaube

Symbol_chars

private final char[] Symbol_chars

MS_Symbol_codes

private final int[] MS_Symbol_codes

goodFonts

private final java.util.Vector<java.awt.Font> goodFonts
Constructor Detail

MathBase

public MathBase(MathRootElement element,
                java.lang.String fontname,
                int fontstyle,
                int inlinefontsize,
                int displayfontsize,
                java.awt.Graphics gcalc)
Creates a MathBase

Parameters:
element - Root element of a math tree
fontname - Name of the preferred font
fontstyle - Style of the preferred font, see java.awt.Font
inlinefontsize - Size of the preferred font used by inline equations
displayfontsize - Size of the preferred font used by non inline equations
gcalc - Graphics object to use to calculate character sizes (nothing will be painted on it)

MathBase

public MathBase(MathRootElement element,
                java.awt.Graphics gcalc)
Creates a MathBase

Parameters:
element - Root element of a math tree
gcalc - Graphics object to use to calculate character sizes (nothing will be painted on it)

MathBase

public MathBase(java.lang.String fontname,
                int fontstyle,
                int inlinefontsize,
                int displayfontsize,
                java.awt.Graphics gcalc)
Creates a MathBase

Parameters:
fontname - Name of the preferred font
fontstyle - Style of the preferred font, see java.awt.Font
inlinefontsize - Size of the preferred font used by inline equations
displayfontsize - Size of the preferred font used by non inline equations
gcalc - Graphics object to use to calculate character sizes (nothing will be painted on it)
Method Detail

setupFontMetrics

private void setupFontMetrics(java.awt.Graphics gcalc)

setRootElement

public void setRootElement(MathRootElement element)
Set the root element of a math tree

Parameters:
element - Root element of a math tree

setDebug

public void setDebug(boolean debug)
Enables, or disables the debug mode

Parameters:
debug - Debug mode

isDebug

public boolean isDebug()
Indicates, if the debug mode is enabled

Returns:
True, if the debug mode is enabled

setDefaultFontSize

public void setDefaultFontSize(int fontsize)
Sets the default font size, which used for the root element

Parameters:
fontsize - Font size

getDefaultInlineFontSize

public int getDefaultInlineFontSize()
Get the default font size

Returns:
Default font size

setDefaultDisplayFontSize

public void setDefaultDisplayFontSize(int fontsize)
Sets the default font size for non inline equations

Parameters:
fontsize - Default font size

getDefaultDisplayFontSize

public int getDefaultDisplayFontSize()
Get the default font size for non inline equations

Returns:
Default display font size

getFont

public java.awt.Font getFont(int fontsize)
Get a font specified by the font size

Parameters:
fontsize - Font size
Returns:
Font

getSymbolFont

public java.awt.Font getSymbolFont(int fontsize)
Get a symbol font specified by the font size

Parameters:
fontsize - Font Size
Returns:
Font

findFont

public java.lang.String findFont(java.lang.String s,
                                 java.awt.Font defaultFont)

getFontMetrics

public java.awt.FontMetrics getFontMetrics(int fontsize)
Get the font metrics specified by the font size

Parameters:
fontsize - Font size
Returns:
Font metrics

getSymbolFontMetrics

public java.awt.FontMetrics getSymbolFontMetrics(int fontsize)
Get the font metrics of the symbol font specified by the font size

Parameters:
fontsize - Font size
Returns:
Font metrics

getSymbolGlyphVector

public java.awt.font.GlyphVector getSymbolGlyphVector(java.awt.Graphics2D g2d,
                                                      int fontsize,
                                                      char c)
Get a glyph vector of the symbol font

Parameters:
g2d - The graphic context presented by a Graphics2D
fontsize - Font size
index - Index of the glyph vector
Returns:
Glyph vector

paint

public void paint(java.awt.Graphics g)
Paints this component and all of its elements

Parameters:
g - The graphics context to use for painting

getWidth

public int getWidth()
Return the current width of this component

Returns:
Width

getHeight

public int getHeight()
Return the current height of this component

Returns:
Height