Class JMathComponent

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, SwingConstants

public final class JMathComponent extends JComponent implements SwingConstants
Displays MathML content in a Swing Component.

There are two properties which expose the actual content, accessible though getDocument() / setDocument(org.w3c.dom.Node) for content already available as a DOM model, and getContent() and setContent(String) for content available as a String.

This class exposes most of the rendering parameters as standard bean attributes. If you need to set additional attributes, you may use the setParameter(Parameter, Object) function.

Please use only the attributes exposed through the attached JMathComponentBeanInfo class. Additional attributes, such as Component.getFont() and setFont(Font) are provided for Swing compatibility, but they may not work exactly as expected.

Version:
$Revision: 5a7becda9147 $
See Also:
  • Constructor Details

    • JMathComponent

      public JMathComponent()
      Default constructor.
  • Method Details

    • getContent

      public String getContent()
      Tries to return the content as a String.

      This transforms the internal DOM tree back into a string, which may is not guaranteed to be the literally same as the original content. However, it will represent the same XML document.

      Returns:
      the content string.
    • getDocument

      public Node getDocument()
      Returns:
      the document
    • getFontsDoublestruck

      public String getFontsDoublestruck()
      Font list for Doublestruck. Please see
      invalid reference
      Parameter#FontsDoublestruck
      for an explanation of this parameter.
      Returns:
      The list for Doublestruck.
      See Also:
      • invalid reference
        Parameter#FontsDoublestruck
    • getFontsFraktur

      public String getFontsFraktur()
      Font list for Fraktur. Please see
      invalid reference
      Parameter#FontsFraktur
      for an explanation of this parameter.
      Returns:
      The list for Fraktur.
      See Also:
      • invalid reference
        Parameter#FontsFraktur
    • getFontSize

      public float getFontSize()
      Returns:
      the fontSize
    • getFontsMonospaced

      public String getFontsMonospaced()
      Font list for Monospaced. Please see
      invalid reference
      Parameter#FontsMonospaced
      for an explanation of this parameter.
      Returns:
      The list for monospaced.
      See Also:
      • invalid reference
        Parameter#FontsMonospaced
    • getFontsSanserif

      public String getFontsSanserif()
      Font list for Sans-Serif. Please see
      invalid reference
      Parameter#FontsSanserif
      for an explanation of this parameter.
      Returns:
      The list for sansserif.
      See Also:
      • invalid reference
        Parameter#FontsSanserif
    • getFontsScript

      public String getFontsScript()
      Font list for Script. Please see
      invalid reference
      Parameter#FontsScript
      for an explanation of this parameter.
      Returns:
      The list for Script.
      See Also:
      • invalid reference
        Parameter#FontsScript
    • getFontsSerif

      public String getFontsSerif()
      Font list for Serif (the default MathML font). Please see
      invalid reference
      Parameter#FontsSerif
      for an explanation of this parameter.
      Returns:
      The list for serif.
      See Also:
      • invalid reference
        Parameter#FontsSerif
    • getForeground

      public Color getForeground()
      Overrides:
      getForeground in class Component
    • getHorizontalAlignment

      public int getHorizontalAlignment()
      Returns:
      the horizontalAlignment
      See Also:
    • getPreferredSize

      public Dimension getPreferredSize()
      Gets the preferred size of this component.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      A dimension object indicating this component's preferred size.
    • getUI

      public MathComponentUI getUI()
      Overrides:
      getUI in class JComponent
      Returns:
      the UI implementation.
    • getUIClassID

      public String getUIClassID()
      Overrides:
      getUIClassID in class JComponent
      Returns:
      The default UI class
    • getVerticalAlignment

      public int getVerticalAlignment()
      Returns:
      the verticalAlignment
      See Also:
    • setBackground

      public void setBackground(Color c)
      Overrides:
      setBackground in class JComponent
    • setContent

      public void setContent(String contentString)
      Set the content from a String containing the MathML content.
      Parameters:
      contentString - the content to set.
    • setDebug

      public void setDebug(boolean dbg)
      Enables, or disables the debug mode.
      Parameters:
      dbg - Debug mode.
    • setDocument

      public void setDocument(Node doc)
      Parameters:
      doc - the document to set
    • setFont

      @Deprecated public void setFont(Font f)
      Deprecated.
      use separate setters.
      Font emulator for standard component behavior.

      Emulates the standard setFont function by setting the font Size and adding the font to the front of the serif font list.

      Please use the separate setters if possible.

      Overrides:
      setFont in class JComponent
      Parameters:
      f - font to set.
      See Also:
    • setFontsDoublestruck

      public void setFontsDoublestruck(String newFonts)
      Font list for Doublestruck. Please see Parameter.FONTS_DOUBLESTRUCK for an explanation of this parameter.
      Parameters:
      newFonts - new list for Doublestruck (comma seraparated).
      See Also:
    • setFontsFraktur

      public void setFontsFraktur(String newFonts)
      Font list for Fraktur. Please see Parameter.FONTS_FRAKTUR for an explanation of this parameter.
      Parameters:
      newFonts - new list for Fraktur (comma seraparated).
      See Also:
    • setParameter

      public void setParameter(Parameter key, Object newValue)
      Sets a generic rendering parameter.
      Parameters:
      key - Key for the parameter
      newValue - newValue
    • setParameters

      public void setParameters(Map<Parameter,Object> newValues)
      Sets generic rendering parameters.
      Parameters:
      newValues - map of parameter keys to new values
    • setFontSize

      public void setFontSize(float fontSize)
      sets the font size used.
      Parameters:
      fontSize - the font size.
    • setFontsMonospaced

      public void setFontsMonospaced(String newFonts)
      Font list for Monospaced. Please see Parameter.FONTS_MONOSPACED for an explanation of this parameter.
      Parameters:
      newFonts - new list for Monospaced (comma seraparated).
      See Also:
    • setFontsSanserif

      public void setFontsSanserif(String newFonts)
      Font list for Sans-Serif. Please see Parameter.FONTS_SANSSERIF for an explanation of this parameter.
      Parameters:
      newFonts - new list for sansserif (comma seraparated).
      See Also:
    • setFontsScript

      public void setFontsScript(String newFonts)
      Font list for Script. Please see Parameter.FONTS_SCRIPT for an explanation of this parameter.
      Parameters:
      newFonts - new list for Script (comma seraparated).
      See Also:
    • setFontsSerif

      public void setFontsSerif(String newFonts)
      Font list for Serif (the default MathML font). Please see Parameter.FONTS_SERIF for an explanation of this parameter.
      Parameters:
      newFonts - new list for serif (comma seraparated).
      See Also:
    • setForeground

      public void setForeground(Color fg)
      Overrides:
      setForeground in class JComponent
    • setHorizontalAlignment

      public void setHorizontalAlignment(int hAlignment)
      Parameters:
      hAlignment - the horizontalAlignment to set
      See Also:
    • setOpaque

      public void setOpaque(boolean opaque)
      Overrides:
      setOpaque in class JComponent
    • setVerticalAlignment

      public void setVerticalAlignment(int vAlignment)
      Parameters:
      vAlignment - the verticalAlignment to set
      See Also:
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JComponent
    • getParameters

      public MutableLayoutContext getParameters()
      Returns:
      the parameters
    • setSize

      public void setSize(int width, int height)
      Overrides:
      setSize in class Component