be.ugent.caagt.jmathtex

Class TeXIcon

Implemented Interfaces:
Icon

public class TeXIcon
extends java.lang.Object
implements Icon

An javax.swing.Icon implementation that will paint the TeXFormula that created it.

This class cannot be instantiated directly. It can be constructed from a TeXFormula using the TeXFormula.createTeXIcon(int,float) method.

Author:
Kurt Vermeulen

Constructor Summary

TeXIcon(be.ugent.caagt.jmathtex.Box b, float size)
Creates a new icon that will paint the given formula box in the given point size.

Method Summary

float
getBaseLine()
int
getIconHeight()
Get the total height of the TeXIcon.
int
getIconWidth()
Get the total width of the TeXIcon.
Insets
getInsets()
Get the insets of the TeXIcon.
void
paintIcon(Component c, Graphics g, int x, int y)
Paint the TeXFormula that created this icon.
void
setIconHeight(int height, int alignment)
Change the height of the TeXIcon.
void
setIconWidth(int width, int alignment)
Change the width of the TeXIcon.
void
setInsets(Insets insets)
Set the insets of the TeXIcon.

Constructor Details

TeXIcon

protected TeXIcon(be.ugent.caagt.jmathtex.Box b,
                  float size)
Creates a new icon that will paint the given formula box in the given point size.
Parameters:
b - the formula box to be painted
size - the point size

Method Details

getBaseLine

public float getBaseLine()

getIconHeight

public int getIconHeight()
Get the total height of the TeXIcon. This also includes the insets.

getIconWidth

public int getIconWidth()
Get the total width of the TeXIcon. This also includes the insets.

getInsets

public Insets getInsets()
Get the insets of the TeXIcon.
Returns:
the insets

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Paint the TeXFormula that created this icon.

setIconHeight

public void setIconHeight(int height,
                          int alignment)
Change the height of the TeXIcon. The new height must be greater than the current height, otherwise the icon will remain unchanged. The formula will be aligned on top (TeXConstants.TOP), at the bottom (TeXConstants.BOTTOM) or will be centered in the middle (TeXConstants.CENTER).
Parameters:
height - the new height of the TeXIcon
alignment - a vertical alignment constant: TOP, BOTTOM or CENTER

setIconWidth

public void setIconWidth(int width,
                         int alignment)
Parameters:
width - the new width of the TeXIcon
alignment - a horizontal alignment constant: LEFT, RIGHT or CENTER

setInsets

public void setInsets(Insets insets)
Set the insets of the TeXIcon.
Parameters:
insets - the insets