jaxe.equations.element
Class MathElement

java.lang.Object
  extended by jaxe.equations.element.MathElement
Direct Known Subclasses:
MathFrac, MathOperator, MathOver, MathPhantom, MathRoot, MathRootElement, MathRow, MathSqrt, MathSub, MathSubSup, MathSup, MathTable, MathTableData, MathTableRow, MathText, MathUnder, MathUnderOver

public class MathElement
extends java.lang.Object

The basic class the the math elements. From this class elements inherits.

Version:
1.5
Author:
Stephan Michels, Marco Sielaff

Field Summary
private  MathBase base
           
private  java.util.Vector<MathElement> children
           
static java.lang.String FO_URI
          The URI from FO
private  int fontsize
           
private  MathElement parent
           
static java.lang.String SVG_URI
          The URI from SVG
private  java.lang.StringBuilder text
           
static java.lang.String URI
          The URI from MathML
 
Constructor Summary
MathElement()
          Creates a math element
MathElement(MathBase base)
          Creates a math element
MathElement(MathBase base, int fontsize)
          Creates a math element
 
Method Summary
 void addMathElement(MathElement child)
          Add a math element as a child
 void addText(java.lang.String text)
          Add the content of a String to this element
 void debug(java.awt.Graphics g, int posX, int posY)
          Paints a border around this element as debug information
 int getAscentHeight(boolean dynamicParts)
          Return the current height of the upper part of this component from the baseline
 int getDescentHeight(boolean dynamicParts)
          Return the current height of the lower part of this component from the baseline
 java.awt.Font getFont()
          Gets the used font
 java.awt.FontMetrics getFontMetrics()
          Gets the font metrics of the used font
 int getFontSize()
          Gets the used font size
 int getHeight(boolean dynamicParts)
          Return the current height of this element
 MathBase getMathBase()
          Gets the math base
 MathElement getMathElement(int index)
          Gets a child from this element
 int getMathElementCount()
          Returns the count of children from this element
protected  int getMiddleShift()
          Returns the distance of the baseline and the middleline
 MathElement getParent()
          Returns get parent of this element
 java.awt.Font getSymbolFont()
          Gets the used symbol font size
 java.awt.FontMetrics getSymbolFontMetrics()
          Gets the font metrics of the used symbol font
 java.awt.font.GlyphVector getSymbolGlyphVector(java.awt.Graphics2D g2d, char c)
          Get a glyph vector of the symbol font
 java.lang.String getText()
          Returns the text contentof this element
 int getWidth(boolean dynamicParts)
          Return the current width of this element
 void paint(java.awt.Graphics g, int posX, int posY)
          Paints this element
 void setFontSize(int fontsize)
          Sets the font size for this component
 void setMathBase(MathBase base)
          Sets the base for this element
 void setMathElementAt(MathElement child, int index)
          Sets a child from this element
 void setParent(MathElement parent)
          Sets the parent of this element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URI

public static final java.lang.String URI
The URI from MathML

See Also:
Constant Field Values

SVG_URI

public static final java.lang.String SVG_URI
The URI from SVG

See Also:
Constant Field Values

FO_URI

public static final java.lang.String FO_URI
The URI from FO

See Also:
Constant Field Values

base

private MathBase base

parent

private MathElement parent

fontsize

private int fontsize

children

private final java.util.Vector<MathElement> children

text

private final java.lang.StringBuilder text
Constructor Detail

MathElement

public MathElement(MathBase base,
                   int fontsize)
Creates a math element

Parameters:
base - The base for the math element tree
fontsize - The font size for this element

MathElement

public MathElement(MathBase base)
Creates a math element

Parameters:
base - The base for the math element tree

MathElement

public MathElement()
Creates a math element

Method Detail

addMathElement

public void addMathElement(MathElement child)
Add a math element as a child

Parameters:
child - Math element

getMathElement

public MathElement getMathElement(int index)
Gets a child from this element

Parameters:
index - Index of the child
Returns:
The child

setMathElementAt

public void setMathElementAt(MathElement child,
                             int index)
Sets a child from this element

Parameters:
index - Index of the child

getMathElementCount

public int getMathElementCount()
Returns the count of children from this element

Returns:
Count of children

addText

public void addText(java.lang.String text)
Add the content of a String to this element

Parameters:
text - Text

getText

public java.lang.String getText()
Returns the text contentof this element

Returns:
Text content

setMathBase

public void setMathBase(MathBase base)
Sets the base for this element

Parameters:
base - Math base

getMathBase

public MathBase getMathBase()
Gets the math base

Returns:
Math base

setParent

public void setParent(MathElement parent)
Sets the parent of this element

Parameters:
parent - Parent element

getParent

public MathElement getParent()
Returns get parent of this element

Returns:
Parent element

setFontSize

public void setFontSize(int fontsize)
Sets the font size for this component

Parameters:
fontsize - Font size

getFontSize

public int getFontSize()
Gets the used font size

Returns:
Font Size

getFont

public java.awt.Font getFont()
Gets the used font

Returns:
Font

getFontMetrics

public java.awt.FontMetrics getFontMetrics()
Gets the font metrics of the used font

Returns:
Font metrics

getSymbolFont

public java.awt.Font getSymbolFont()
Gets the used symbol font size

Returns:
Font

getSymbolFontMetrics

public java.awt.FontMetrics getSymbolFontMetrics()
Gets the font metrics of the used symbol font

Returns:
Font metrics

getSymbolGlyphVector

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

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

debug

public void debug(java.awt.Graphics g,
                  int posX,
                  int posY)
Paints a border around this element as debug information

Parameters:
g - The graphics context to use for painting
posX - The first left position for painting
posY - The position of the baseline

paint

public void paint(java.awt.Graphics g,
                  int posX,
                  int posY)
Paints this element

Parameters:
g - The graphics context to use for painting
posX - The first left position for painting
posY - The position of the baseline

getWidth

public int getWidth(boolean dynamicParts)
Return the current width of this element

Parameters:
dynamicParts -
Returns:
Width of this element

getHeight

public int getHeight(boolean dynamicParts)
Return the current height of this element

Parameters:
dynamicParts - Should be true, if the calculation consider the elements, which has not fixed sizes
Returns:
Height of this element

getAscentHeight

public int getAscentHeight(boolean dynamicParts)
Return the current height of the upper part of this component from the baseline

Parameters:
dynamicParts - Should be true, if the calculation consider the elements, which has not fixed sizes
Returns:
Height of the upper part

getDescentHeight

public int getDescentHeight(boolean dynamicParts)
Return the current height of the lower part of this component from the baseline

Parameters:
dynamicParts - Should be true, if the calculation consider the elements, which has not fixed sizes
Returns:
Height of the lower part

getMiddleShift

protected int getMiddleShift()
Returns the distance of the baseline and the middleline

Returns:
Distance