net.sourceforge.jeuclid.elements.presentation.script
Class AbstractUnderOver

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.script.AbstractUnderOver
All Implemented Interfaces:
ChangeTrackingInterface, DisplayableNode, JEuclidElement, JEuclidNode, Element, MathMLElement, MathMLPresentationElement, MathMLUnderOverElement, Node
Direct Known Subclasses:
Mover, Munder, Munderover

public abstract class AbstractUnderOver
extends AbstractJEuclidElement
implements MathMLUnderOverElement

Implementation and helper methods for munder, mover, and munderover.

Version:
$Revision: 310 $
Author:
Max Berger
'This needs to be done:'
some operators should "default" to being an accent, but currently they don't

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
static String ATTR_ACCENT
          attribute for accent property.
static String ATTR_ACCENTUNDER
          attribute for accentunder property.
static float NON_ACCENT_MULTIPLIER
          Space for non-accents multiplied by this value.
static String UNDER_OVER_SPACE
          Space between base and under/over for accents.
 
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
AbstractUnderOver(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.
 String getAccent()
          Either true or false if present; a string controlling whether overscript is drawn as an accent or as a limit, if specified; this is the element's accent attribute.
protected  boolean getAccentAsBoolean()
          returns the accent property as boolean.
 String getAccentunder()
          Either true or false if present; a string controlling whether underscript is drawn as an accent or as a limit, if specified; this is the element's accentunder attribute.
protected  boolean getAccentunderAsBoolean()
          returns the accentunder property as boolean.
 JEuclidElement getBase()
          A MathMLElement representing the base of the script.
protected  float getOverBaselineShift(Graphics2D g)
           
abstract  JEuclidElement getOverscript()
          A MathMLElement representing the overscript of the script.
 int getScriptlevelForChild(JEuclidElement child)
          Retrieves the scriptlevel for a certain child.
protected  float getUnderBaselineShift(Graphics2D g)
           
abstract  JEuclidElement getUnderscript()
          A MathMLElement representing the underscript of the script.
 float getXCenter(Graphics2D g)
          Returns the center X coordinate of the content.
 boolean hasChildPostscripts(JEuclidElement child)
          returns true is the child has postscripts attached to it.
 boolean isChildBlock(JEuclidElement child)
          Returns true if the child should be displayed as a block (not inline).
protected  boolean limitsAreMoved()
           
 void paint(Graphics2D g, float posX, float posY)
          Paints this element.
 void setAccent(String accent)
          setter for the accent attribute.
 void setAccentunder(String accentunder)
          setter for the accentunder attribute.
 void setBase(MathMLElement base)
          setter for the base attribute.
 
Methods inherited from class net.sourceforge.jeuclid.elements.AbstractJEuclidElement
addMathElement, addText, calculateHeight, changeHook, 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, getScriptSizeMultiplier, getText, getWidth, getXref, hasChildPrescripts, isCalculatingSize, 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.MathMLUnderOverElement
setOverscript, setUnderscript
 
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
 

Field Detail

UNDER_OVER_SPACE

public static final String UNDER_OVER_SPACE
Space between base and under/over for accents.

See Also:
Constant Field Values

NON_ACCENT_MULTIPLIER

public static final float NON_ACCENT_MULTIPLIER
Space for non-accents multiplied by this value.

See Also:
Constant Field Values

ATTR_ACCENT

public static final String ATTR_ACCENT
attribute for accent property.

See Also:
Constant Field Values

ATTR_ACCENTUNDER

public static final String ATTR_ACCENTUNDER
attribute for accentunder property.

See Also:
Constant Field Values
Constructor Detail

AbstractUnderOver

public AbstractUnderOver(MathBase base)
default constructor.

Parameters:
base - Mathbase to use.
Method Detail

getAccent

public String getAccent()
Either true or false if present; a string controlling whether overscript is drawn as an accent or as a limit, if specified; this is the element's accent attribute. This must return null for an munder.

Specified by:
getAccent in interface MathMLUnderOverElement
Returns:
value of the accent attribute.

getAccentAsBoolean

protected boolean getAccentAsBoolean()
returns the accent property as boolean.

Returns:
accent

limitsAreMoved

protected boolean limitsAreMoved()
Returns:
true if limits are moved (behave like under/over).

getUnderBaselineShift

protected float getUnderBaselineShift(Graphics2D g)
Parameters:
g - Graphics Context.
Returns:
the amount the underbaseline is shifted. Must only be called if an under element exists!

getOverBaselineShift

protected float getOverBaselineShift(Graphics2D g)
Parameters:
g - Graphics Context.
Returns:
the amount the overbaseline is shifted. Must only be called if an over element exists!

calculateAscentHeight

public final 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 final 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.

getXCenter

public float getXCenter(Graphics2D g)
Returns the center X coordinate of the content. In most cases, this will be width/2. In some cases, an element may have extra space on one side, therefore moving the content.

Specified by:
getXCenter in interface DisplayableNode
Overrides:
getXCenter in class AbstractJEuclidElement
Parameters:
g - X-offset of the horizontal center of the actual content.
Returns:
Graphics2D context to use.

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.

paint

public final 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.

getAccentunder

public String getAccentunder()
Either true or false if present; a string controlling whether underscript is drawn as an accent or as a limit, if specified; this is the element's accentunder attribute. This must return null for an mover.

Specified by:
getAccentunder in interface MathMLUnderOverElement
Returns:
value of the accentunder attribute.

getScriptlevelForChild

public int getScriptlevelForChild(JEuclidElement child)
Retrieves the scriptlevel for a certain child. Some attributes increase the scriptlevel for some of their children.

Specified by:
getScriptlevelForChild in interface JEuclidElement
Overrides:
getScriptlevelForChild in class AbstractJEuclidElement
Parameters:
child - element node of the child.
Returns:
the scriptlevel for this particular child.

isChildBlock

public boolean isChildBlock(JEuclidElement child)
Returns true if the child should be displayed as a block (not inline). Roughly corresponds to the "displaystyle" property (3.2.5.9)

Specified by:
isChildBlock in interface JEuclidElement
Overrides:
isChildBlock in class AbstractJEuclidElement
Parameters:
child - child to test
Returns:
true if child is block.

getAccentunderAsBoolean

protected boolean getAccentunderAsBoolean()
returns the accentunder property as boolean.

Returns:
accentunder

getBase

public JEuclidElement getBase()
A MathMLElement representing the base of the script. This is the first child of the element.

Specified by:
getBase in interface MathMLUnderOverElement
Returns:
value of the base attribute.

getOverscript

public abstract JEuclidElement getOverscript()
A MathMLElement representing the overscript of the script. This is the second child of a mover or the third child of a munderover; retrieval must return null for an munder.

Specified by:
getOverscript in interface MathMLUnderOverElement
Returns:
value of the overscript attribute.

getUnderscript

public abstract JEuclidElement getUnderscript()
A MathMLElement representing the underscript of the script. This is the second child of a munder or munderover; retrieval must return null for an mover.

Specified by:
getUnderscript in interface MathMLUnderOverElement
Returns:
value of the underscript attribute.

setAccent

public void setAccent(String accent)
setter for the accent attribute.

Specified by:
setAccent in interface MathMLUnderOverElement
Parameters:
accent - new value for accent.
See Also:
MathMLUnderOverElement.getAccent()

setAccentunder

public void setAccentunder(String accentunder)
setter for the accentunder attribute.

Specified by:
setAccentunder in interface MathMLUnderOverElement
Parameters:
accentunder - new value for accentunder.
See Also:
MathMLUnderOverElement.getAccentunder()

setBase

public void setBase(MathMLElement base)
setter for the base attribute.

Specified by:
setBase in interface MathMLUnderOverElement
Parameters:
base - new value for base.
See Also:
MathMLUnderOverElement.getBase()

hasChildPostscripts

public boolean hasChildPostscripts(JEuclidElement child)
returns true is the child has postscripts attached to it. In this case, there should be no extra space on the left.

Specified by:
hasChildPostscripts in interface JEuclidElement
Overrides:
hasChildPostscripts in class AbstractJEuclidElement
Parameters:
child - child to test
Returns:
true if there are attached postscripts


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