net.sourceforge.jeuclid.swing
Class JMathComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.sourceforge.jeuclid.swing.JMathComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, SwingConstants

public 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(Document) 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(ParameterKey, String) 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: 433 $
Author:
Unknown, Max Berger
See Also:
MathComponent, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JMathComponent()
          Default constructor.
 
Method Summary
 String getContent()
          Tries to return the content as a String.
 Document getDocument()
           
 String getFontsDoublestruck()
          Font list for Doublestruck.
 String getFontsFraktur()
          Font list for Fraktur.
 float getFontSize()
           
 String getFontsMonospaced()
          Font list for Monospaced.
 String getFontsSanserif()
          Font list for Sans-Serif.
 String getFontsScript()
          Font list for Script.
 String getFontsSerif()
          Font list for Serif (the default MathML font).
 Color getForeground()
          
 int getHorizontalAlignment()
          Horizontal alignment, as defined by JLabel.getHorizontalAlignment().
 Map<ParameterKey,String> getParameters()
           
 Dimension getPreferredSize()
          Gets the preferred size of this component.
 MathComponentUI getUI()
           
 String getUIClassID()
           
 int getVerticalAlignment()
          Vertical alignment, as defined by JLabel.getVerticalAlignment().
 void setBackground(Color c)
          
 void setContent(String contentString)
          Set the content from a String containing the MathML content.
 void setDebug(boolean dbg)
          Enables, or disables the debug mode.
 void setDocument(Document doc)
           
 void setFont(Font f)
          Deprecated.  
 void setFontsDoublestruck(String newFonts)
          Font list for Doublestruck.
 void setFontsFraktur(String newFonts)
          Font list for Fraktur.
 void setFontSize(float fontSize)
          sets the font size used.
 void setFontsMonospaced(String newFonts)
          Font list for Monospaced.
 void setFontsSanserif(String newFonts)
          Font list for Sans-Serif.
 void setFontsScript(String newFonts)
          Font list for Script.
 void setFontsSerif(String newFonts)
          Font list for Serif (the default MathML font).
 void setForeground(Color fg)
          
 void setHorizontalAlignment(int hAlignment)
          Horizontal alignment, as defined by JLabel.setHorizontalAlignment(int).
 void setOpaque(boolean opaque)
          
 void setParameter(ParameterKey key, String value)
          Sets a generic JEuclid rendering parameter.
 void setVerticalAlignment(int vAlignment)
          Vertical alignment, as defined by JLabel.setVerticalAlignment(int).
 void updateUI()
          
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JMathComponent

public JMathComponent()
Default constructor.

Method Detail

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 Document getDocument()
Returns:
the document

getFontsDoublestruck

public String getFontsDoublestruck()
Font list for Doublestruck. Please see ParameterKey.FontsDoublestruck for an explanation of this parameter.

Returns:
The list for Doublestruck.
See Also:
ParameterKey.FontsDoublestruck

getFontsFraktur

public String getFontsFraktur()
Font list for Fraktur. Please see ParameterKey.FontsFraktur for an explanation of this parameter.

Returns:
The list for Fraktur.
See Also:
ParameterKey.FontsFraktur

getFontSize

public float getFontSize()
Returns:
the fontSize

getFontsMonospaced

public String getFontsMonospaced()
Font list for Monospaced. Please see ParameterKey.FontsMonospaced for an explanation of this parameter.

Returns:
The list for monospaced.
See Also:
ParameterKey.FontsMonospaced

getFontsSanserif

public String getFontsSanserif()
Font list for Sans-Serif. Please see ParameterKey.FontsSanserif for an explanation of this parameter.

Returns:
The list for sansserif.
See Also:
ParameterKey.FontsSanserif

getFontsScript

public String getFontsScript()
Font list for Script. Please see ParameterKey.FontsScript for an explanation of this parameter.

Returns:
The list for Script.
See Also:
ParameterKey.FontsScript

getFontsSerif

public String getFontsSerif()
Font list for Serif (the default MathML font). Please see ParameterKey.FontsSerif for an explanation of this parameter.

Returns:
The list for serif.
See Also:
ParameterKey.FontsSerif

getForeground

public Color getForeground()

Overrides:
getForeground in class Component

getHorizontalAlignment

public int getHorizontalAlignment()
Horizontal alignment, as defined by JLabel.getHorizontalAlignment().

Supported are: SwingConstants.LEADING, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.TRAILING, SwingConstants.RIGHT.

Returns:
the horizontalAlignment
See Also:
JLabel.getHorizontalAlignment()

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()
Returns:
the UI implementation.

getUIClassID

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

getVerticalAlignment

public int getVerticalAlignment()
Vertical alignment, as defined by JLabel.getVerticalAlignment().

Supported are: SwingConstants.TOP, SwingConstants.CENTER, SwingConstants.BOTTOM.

Returns:
the verticalAlignment
See Also:
JLabel.getVerticalAlignment()

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(Document doc)
Parameters:
doc - the document to set

setFont

@Deprecated
public void setFont(Font f)
Deprecated. 

Font emulator for standard component behaviour.

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:
setFontSize(float), setFontsSerif(String)

setFontsDoublestruck

public void setFontsDoublestruck(String newFonts)
Font list for Doublestruck. Please see ParameterKey.FontsDoublestruck for an explanation of this parameter.

Parameters:
newFonts - new list for Doublestruck (comma seraparated).
See Also:
ParameterKey.FontsDoublestruck

setFontsFraktur

public void setFontsFraktur(String newFonts)
Font list for Fraktur. Please see ParameterKey.FontsFraktur for an explanation of this parameter.

Parameters:
newFonts - new list for Fraktur (comma seraparated).
See Also:
ParameterKey.FontsFraktur

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 ParameterKey.FontsMonospaced for an explanation of this parameter.

Parameters:
newFonts - new list for Monospaced (comma seraparated).
See Also:
ParameterKey.FontsMonospaced

setFontsSanserif

public void setFontsSanserif(String newFonts)
Font list for Sans-Serif. Please see ParameterKey.FontsSanserif for an explanation of this parameter.

Parameters:
newFonts - new list for sansserif (comma seraparated).
See Also:
ParameterKey.FontsSanserif

setFontsScript

public void setFontsScript(String newFonts)
Font list for Script. Please see ParameterKey.FontsScript for an explanation of this parameter.

Parameters:
newFonts - new list for Script (comma seraparated).
See Also:
ParameterKey.FontsScript

setFontsSerif

public void setFontsSerif(String newFonts)
Font list for Serif (the default MathML font). Please see ParameterKey.FontsSerif for an explanation of this parameter.

Parameters:
newFonts - new list for serif (comma seraparated).
See Also:
ParameterKey.FontsSerif

setForeground

public void setForeground(Color fg)

Overrides:
setForeground in class JComponent

setHorizontalAlignment

public void setHorizontalAlignment(int hAlignment)
Horizontal alignment, as defined by JLabel.setHorizontalAlignment(int).

Supported are: SwingConstants.LEADING, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.TRAILING, SwingConstants.RIGHT.

Parameters:
hAlignment -