net.sourceforge.jeuclid.elements.presentation.token
Class AbstractTokenWithTextLayout

java.lang.Object
  extended by net.sourceforge.jeuclid.dom.AbstractPartialNodeImpl
      extended by net.sourceforge.jeuclid.dom.AbstractPartialElementImpl
          extended by net.sourceforge.jeuclid.dom.AbstractChangeTrackingElement
              extended by net.sourceforge.jeuclid.elements.AbstractJEuclidElement
                  extended by net.sourceforge.jeuclid.elements.presentation.token.AbstractTokenWithTextLayout
All Implemented Interfaces:
ChangeTrackingInterface, DisplayableNode, JEuclidElement, JEuclidNode, Element, MathMLElement, MathMLPresentationElement, MathMLPresentationToken, Node
Direct Known Subclasses:
AbstractTokenWithStandardLayout, Mglyph, Ms

public abstract class AbstractTokenWithTextLayout
extends AbstractJEuclidElement
implements MathMLPresentationToken

Common functionality for all tokens based on a text layout.

Version:
$Revision: 369 $
Author:
Max Berger

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.jeuclid.dom.AbstractPartialElementImpl
AbstractPartialElementImpl.AttributeNodeMap, AbstractPartialElementImpl.AttrImpl
 
Nested classes/interfaces inherited from class net.sourceforge.jeuclid.dom.AbstractPartialNodeImpl
AbstractPartialNodeImpl.NodeList
 
Field Summary
 
Fields inherited from class net.sourceforge.jeuclid.elements.AbstractJEuclidElement
ALIGN_AXIS, ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TOP, ATTR_CLASS, ATTR_DEPRECATED_BACKGROUND, ATTR_DEPRECATED_COLOR, ATTR_DEPRECATED_FONTFAMILY, ATTR_DEPRECATED_FONTSIZE, ATTR_DEPRECATED_FONTSTYLE, ATTR_DEPRECATED_FONTWEIGHT, ATTR_HREF, ATTR_ID, ATTR_MATHBACKGROUND, ATTR_MATHCOLOR, ATTR_MATHSIZE, ATTR_MATHVARIANT, ATTR_STYLE, ATTR_XREF, TRIVIAL_SPACE_MAX, URI
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
AbstractTokenWithTextLayout(MathBase base)
          Default constructor.
 
Method Summary
 float calculateAscentHeight(Graphics2D g)
          Returns the current height of the upper part (over the base line).
 float calculateDescentHeight(Graphics2D g)
          Calculates descent height (under the base line) of the element.
 float calculateWidth(Graphics2D g)
          Caculates width of the element.
protected  void changeHook()
          Called on any change.
 TextLayout getLayout()
          Returns TextLayout used to paint text of this element.
protected abstract  boolean isEmpty()
          Checks if this element is empty.
 void paint(Graphics2D g, float posX, float posY)
          Paints this element.
protected abstract  AttributedString textContentAsAttributedString()
          Retrieve the text content as attributed string.
 
Methods inherited from class net.sourceforge.jeuclid.elements.AbstractJEuclidElement
addMathElement, addText, calculateHeight, debug, getAbsoluteScriptLevel, getAscentHeight, getBackgroundColor, getClassName, getContents, getDescentHeight, getFont, getFontMetrics, getFontsizeInPoint, getForegroundColor, getGlobalLineCorrector, getHeight, getHref, getId, getIndexOfMathElement, getInheritedScriptlevel, getMathAttribute, getMathbackground, getMathBase, getMathcolor, getMathElement, getMathElementCount, getMathElementStyle, getMathsize, getMathsizeInPoint, getMathvariant, getMathvariantAsVariant, getMiddleShift, getOwnerMathElement, getPaintedPosX, getPaintedPosY, getParent, getScriptlevelForChild, getScriptSizeMultiplier, getText, getWidth, getXCenter, getXref, hasChildPostscripts, hasChildPrescripts, isCalculatingSize, isChildBlock, recalculateSize, setCalculatingSize, setClassName, setDefaultMathAttribute, setFakeParent, setGlobalLineCorrector, setHref, setId, setMathAttributes, setMathbackground, setMathBase, setMathcolor, setMathElement, setMathElementStyle, setMathsize, setMathvariant, setScriptSizeMultiplier, setXref
 
Methods inherited from class net.sourceforge.jeuclid.dom.AbstractChangeTrackingElement
addListener, appendChild, fireChanged, fireChangeForSubTree, replaceChild, setAttribute, setTextContent
 
Methods inherited from class net.sourceforge.jeuclid.dom.AbstractPartialElementImpl
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getElementsByTagName, getElementsByTagNameNS, getLocalName, getNodeName, getNodeType, getSchemaTypeInfo, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS, toString
 
Methods inherited from class net.sourceforge.jeuclid.dom.AbstractPartialNodeImpl
cloneNode, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, setNodeValue, setPrefix, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.mathml.MathMLPresentationToken
getContents, getMathbackground, getMathcolor, getMathsize, getMathvariant, setMathbackground, setMathcolor, setMathsize, setMathvariant
 
Methods inherited from interface org.w3c.dom.mathml.MathMLElement
getClassName, getHref, getId, getMathElementStyle, getOwnerMathElement, getXref, setClassName, setHref, setId, setMathElementStyle, setXref
 
Methods inherited from interface org.w3c.dom.Element
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 
Methods inherited from interface net.sourceforge.jeuclid.dom.ChangeTrackingInterface
addListener, fireChanged, fireChangeForSubTree
 

Constructor Detail

AbstractTokenWithTextLayout

public AbstractTokenWithTextLayout(MathBase base)
Default constructor.

Parameters:
base - The base for the math element tree.
Method Detail

paint

public void paint(Graphics2D g,
                  float posX,
                  float posY)
Paints this element.

Specified by:
paint in interface DisplayableNode
Overrides:
paint in class AbstractJEuclidElement
Parameters:
g - The graphics context to use for painting.
posX - The first left position for painting.
posY - The position of the baseline.

textContentAsAttributedString

protected abstract AttributedString textContentAsAttributedString()
Retrieve the text content as attributed string. Should be overridden

Returns:
an AttributedString

isEmpty

protected abstract boolean isEmpty()
Checks if this element is empty.

Returns:
true if empty.

getLayout

public TextLayout getLayout()
Returns TextLayout used to paint text of this element.

Returns:
TextLayout instance or null, if layout was not computed yet

calculateWidth

public float calculateWidth(Graphics2D g)
Caculates width of the element.

Specified by:
calculateWidth in class AbstractJEuclidElement
Parameters:
g - Graphics2D context to use.
Returns:
Width of the element.

calculateAscentHeight

public float calculateAscentHeight(Graphics2D g)
Returns the current height of the upper part (over the base line).

Specified by:
calculateAscentHeight in interface JEuclidElement
Specified by:
calculateAscentHeight in class AbstractJEuclidElement
Parameters:
g - Graphics2D context to use.
Returns:
Height of the upper part.

calculateDescentHeight

public float calculateDescentHeight(Graphics2D g)
Calculates descent height (under the base line) of the element.

Specified by:
calculateDescentHeight in interface JEuclidElement
Specified by:
calculateDescentHeight in class AbstractJEuclidElement
Parameters:
g - Graphics2D context to use.
Returns:
Descent height value.

changeHook

protected void changeHook()
Called on any change. Please override!

Overrides:
changeHook in class AbstractJEuclidElement


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