org.scilab.forge.jlatexmath
Class TeXIcon

java.lang.Object
  extended by org.scilab.forge.jlatexmath.TeXIcon
All Implemented Interfaces:
javax.swing.Icon

public class TeXIcon
extends java.lang.Object
implements javax.swing.Icon

An 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

Field Summary
static float defaultSize
           
 boolean isColored
           
static float magFactor
           
 
Constructor Summary
protected TeXIcon(Box b, float size)
          Creates a new icon that will paint the given formula box in the given point size.
protected TeXIcon(Box b, float size, boolean trueValues)
           
 
Method Summary
 float getBaseLine()
           
 int getIconDepth()
          Get the total height of the TeXIcon.
 int getIconHeight()
          Get the total height of the TeXIcon.
 int getIconWidth()
          Get the total width of the TeXIcon.
 java.awt.Insets getInsets()
          Get the insets of the TeXIcon.
 float getTrueIconDepth()
          Get the total height of the TeXIcon.
 float getTrueIconHeight()
           
 float getTrueIconWidth()
          Get the total width of the TeXIcon.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paint the TeXFormula that created this icon.
 void setForeground(java.awt.Color fg)
           
 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(java.awt.Insets insets)
          Set the insets of the TeXIcon.
 void setInsets(java.awt.Insets insets, boolean trueValues)
          Set the insets of the TeXIcon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultSize

public static float defaultSize

magFactor

public static float magFactor

isColored

public boolean isColored
Constructor Detail

TeXIcon

protected TeXIcon(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

TeXIcon

protected TeXIcon(Box b,
                  float size,
                  boolean trueValues)
Method Detail

setForeground

public void setForeground(java.awt.Color fg)

getInsets

public java.awt.Insets getInsets()
Get the insets of the TeXIcon.

Returns:
the insets

setInsets

public void setInsets(java.awt.Insets insets,
                      boolean trueValues)
Set the insets of the TeXIcon.

Parameters:
insets - the insets
trueValues - true to force the true values

setInsets

public void setInsets(java.awt.Insets insets)
Set the insets of the TeXIcon.

Parameters:
insets - the insets

setIconWidth

public void setIconWidth(int width,
                         int alignment)
Change the width of the TeXIcon. The new width must be greater than the current width, otherwise the icon will remain unchanged. The formula will be aligned to the left (TeXConstants.ALIGN_LEFT), to the right (TeXConstants.ALIGN_RIGHT) or will be centered in the middle (TeXConstants.ALIGN_CENTER).

Parameters:
width - the new width of the TeXIcon
alignment - a horizontal alignment constant: LEFT, RIGHT or CENTER

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

getIconHeight

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

Specified by:
getIconHeight in interface javax.swing.Icon

getIconDepth

public int getIconDepth()
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.

Specified by:
getIconWidth in interface javax.swing.Icon

getTrueIconHeight

public float getTrueIconHeight()

getTrueIconDepth

public float getTrueIconDepth()
Get the total height of the TeXIcon. This also includes the insets.


getTrueIconWidth

public float getTrueIconWidth()
Get the total width of the TeXIcon. This also includes the insets.


getBaseLine

public float getBaseLine()

paintIcon

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

Specified by:
paintIcon in interface javax.swing.Icon