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 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: f1695c1926a6 $
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.
JMathComponent(CursorListener listener)
          Default constructor with cursor listener.
 
Method Summary
 String getContent()
          Tries to return the content as a String.
 CursorListener getCursorListener()
          gets cursor listener instance.
 Node 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().
 MutableLayoutContext getParameters()
           
 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(Node doc)
           
 void setFont(Font f)
          Deprecated. use separate setters.
 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(Parameter key, Object newValue)
          Sets a generic rendering parameter.
 void setParameters(Map<Parameter,Object> newValues)
          Sets generic rendering parameters.
 void setSize(int width, int height)
          
 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, getPreferredSize, 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, 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.


JMathComponent

public JMathComponent(CursorListener listener)
Default constructor with cursor listener.

Parameters:
listener - cursor listener instance
Method Detail

getCursorListener

public CursorListener getCursorListener()
gets cursor listener instance.

Returns:
cursor listener instance

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 Parameter#FontsDoublestruck for an explanation of this parameter.

Returns:
The list for Doublestruck.
See Also:
Parameter#FontsDoublestruck

getFontsFraktur

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

Returns:
The list for Fraktur.
See Also:
Parameter#FontsFraktur

getFontSize

public float getFontSize()
Returns:
the fontSize

getFontsMonospaced

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

Returns:
The list for monospaced.
See Also:
Parameter#FontsMonospaced

getFontsSanserif

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

Returns:
The list for sansserif.
See Also:
Parameter#FontsSanserif

getFontsScript

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

Returns:
The list for Script.
See Also:
Parameter#FontsScript

getFontsSerif

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

Returns:
The list for serif.
See Also:
Parameter#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()

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

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:
Parameter.FONTS_DOUBLESTRUCK

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:
Parameter.FONTS_FRAKTUR

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:
Parameter.FONTS_MONOSPACED

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:
Parameter.FONTS_SANSSERIF

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:
Parameter.FONTS_SCRIPT

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:
Parameter.FONTS_SERIF

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 - the horizontalAlignment to set
See Also:
JLabel.setHorizontalAlignment(int)

setOpaque

public void setOpaque(boolean opaque)

Overrides:
setOpaque in class JComponent

setVerticalAlignment

public void setVerticalAlignment(int vAlignment)
Vertical alignment, as defined by JLabel.setVerticalAlignment(int).

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

Parameters:
vAlignment - the verticalAlignment to set
See Also:
JLabel.setVerticalAlignment(int)

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


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