net.sourceforge.jeuclid
Class MathBase

java.lang.Object
  extended by net.sourceforge.jeuclid.MathBase

public class MathBase
extends Object

Keeps a MathML Tree and its Rendering attributes.

This is the main class for MathML handling. It stores a MathML Tree and its rendering attributes.

To obtain a renderable MathML tree, create an instance of this class, and fill its tree with the help of DOMBuilder.

Version:
$Revision: 571 $
Author:
Max Berger, Stephan Michels, Marco Sielaff

Field Summary
static float DEFAULT_FONTSIZE
          Default font size.
static int DISPLAY
          Non inline mathematical expression.
static String FALSE
          Constant for string "false".
static int INLINE
          Inline mathematical expression.
static String TRUE
          Constant for string "true".
static String VALUE_ZERO
          Constant for zero-value (0).
 
Constructor Summary
MathBase(Map<ParameterKey,String> params)
          Default constructor.
 
Method Summary
 float getAscender(Graphics2D g)
          Gets the height of the ascender.
static Map<ParameterKey,String> getDefaultParameters()
          Provides a reasonable set of default parameters.
 float getDescender(Graphics2D g)
          Returns the height of the descender.
 float getFontSize()
           
 float getHeight(Graphics2D g)
          Return the current height of this component.
 Map<ParameterKey,String> getParams()
          Retrieves the current set of parametes.
 DocumentElement getRootElement()
           
 float getWidth(Graphics2D g)
          Return the current width of this component.
 boolean isDebug()
          Indicates, weither the debug mode is enabled.
 void paint(Graphics2D g)
          Paints the componet and all of its elements into the top-right corner.
 void paint(Graphics2D g, float x, float y)
          Paints this component and all of its elements.
 void setDebug(boolean debug)
          Enables, or disables the debug mode.
 void setParam(ParameterKey key, String value)
          Sets a rendering parameter.
 void setRootElement(DocumentElement element)
          Set the root element of a math tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

DEFAULT_FONTSIZE

public static final float DEFAULT_FONTSIZE
Default font size.

See Also:
Constant Field Values

TRUE

public static final String TRUE
Constant for string "true".


FALSE

public static final String FALSE
Constant for string "false".


VALUE_ZERO

public static final String VALUE_ZERO
Constant for zero-value (0).

See Also:
Constant Field Values
Constructor Detail

MathBase

public MathBase(Map<ParameterKey,String> params)
Default constructor.

Allocates a new MathBase with the given rendering parameters. You may use getDefaultParameters() to obtain a default set of rendering parameters.

The root element will initially be empty. You may use DOMBuilder or SAXBuilder to fill it.

Parameters:
params - Rendering parameters.
See Also:
ParameterKey, getDefaultParameters()
Method Detail

getAscender

public float getAscender(Graphics2D g)
Gets the height of the ascender.

Parameters:
g - Graphics2D context to use.
Returns:
Ascent height

getDescender

public float getDescender(Graphics2D g)
Returns the height of the descender.

Parameters:
g - Graphics2D context to use.
Returns:
Descent height

setRootElement

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

Parameters:
element - Root element of a math tree

getRootElement

public DocumentElement getRootElement()
Returns:
the Document element associated with this mathbase.

setDebug

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

Parameters:
debug - Debug mode flag.

isDebug

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

Returns:
True, if the debug mode is enabled

paint

public void paint(Graphics2D g,
                  float x,
                  float y)
Paints this component and all of its elements.

Parameters:
g - The graphics context to use for painting.
x - x-offset
y - y-offset

paint

public void paint(Graphics2D g)
Paints the componet and all of its elements into the top-right corner.

Parameters:
g - The graphics context to use for painting.
See Also:
paint(Graphics2D, float, float)

getWidth

public float getWidth(Graphics2D g)
Return the current width of this component.

Parameters:
g - Graphics2D context to use.
Returns:
Width

getHeight

public float getHeight(Graphics2D g)
Return the current height of this component.

Parameters:
g - Graphics2D context to use.
Returns:
Height

getFontSize

public float getFontSize()
Returns:
the fontSize

getParams

public Map<ParameterKey,String> getParams()
Retrieves the current set of parametes.

Please note that it is not recommended to change any of these parameters, but rather to use setParam(ParameterKey, String) instead.

Returns:
The current set of rendering parameters.

setParam

public void setParam(ParameterKey key,
                     String value)
Sets a rendering parameter.

Parameters:
key - Key of the rendering parameter.
value - new value.

getDefaultParameters

public static Map<ParameterKey,String> getDefaultParameters()
Provides a reasonable set of default parameters.

Returns:
a set that can be used in MathBase(Map)


Copyright © 2002-2008 The JEuclid project. All Rights Reserved.