Package net.sourceforge.jeuclid.elements
Class AbstractJEuclidElement
java.lang.Object
org.apache.batik.dom.AbstractNode
org.apache.batik.dom.AbstractParentNode
org.apache.batik.dom.AbstractParentChildNode
org.apache.batik.dom.AbstractElement
org.apache.batik.dom.AbstractElementNS
org.apache.batik.dom.GenericElementNS
net.sourceforge.jeuclid.elements.AbstractJEuclidElement
- All Implemented Interfaces:
Serializable,JEuclidElement,JEuclidNode,LayoutableNode,org.apache.batik.dom.events.NodeEventTarget,org.apache.batik.dom.ExtendedNode,org.apache.batik.dom.xbl.NodeXBL,org.apache.batik.dom.xbl.XBLManagerData,org.apache.batik.w3c.dom.ElementTraversal,Element,EventTarget,MathMLElement,Node
- Direct Known Subclasses:
AbstractContainer,AbstractInvisibleJEuclidElement,AbstractRoot,AbstractScriptElement,AbstractTokenWithTextLayout,AbstractUnderOver,ForeignElement,Mfrac,Mo,Mspace
public abstract class AbstractJEuclidElement
extends org.apache.batik.dom.GenericElementNS
implements JEuclidElement
The basic class for all math elements. Every element class inherits from this
class. It provides basic functionality for drawing.
- Version:
- $Revision: 62d8defc665e $
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.batik.dom.AbstractElement
org.apache.batik.dom.AbstractElement.ElementTypeInfo, org.apache.batik.dom.AbstractElement.Entry, org.apache.batik.dom.AbstractElement.NamedNodeHashMapNested classes/interfaces inherited from class org.apache.batik.dom.AbstractParentNode
org.apache.batik.dom.AbstractParentNode.ChildNodes, org.apache.batik.dom.AbstractParentNode.ElementsByTagName, org.apache.batik.dom.AbstractParentNode.ElementsByTagNameNS -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant for class attribute.static final StringConstant for background attribute.static final StringConstant for color attribute.static final StringConstant for fontfamily attribute.static final StringConstant for fontsize attribute.static final StringConstant for fontstyle attribute.static final StringConstant for fontweight attribute.static final StringConstant for href attribute.static final StringConstant for id attribute.static final StringThe mathbackground attribute.static final StringConstant for mathcolor attribute.static final StringConstant for mathsize attribute.static final StringConstant for mathvariant attribute.static final StringConstant for style attribute.static final StringConstant for xref attribute.static final intlargest value for all trivial spaces (= spaces that can be ignored / shortened).static final StringThe URI from MathML.Fields inherited from class org.apache.batik.dom.GenericElementNS
nodeName, readonlyFields inherited from class org.apache.batik.dom.AbstractElementNS
namespaceURIFields inherited from class org.apache.batik.dom.AbstractElement
attributes, typeInfoFields inherited from class org.apache.batik.dom.AbstractParentChildNode
nextSibling, parentNode, previousSiblingFields inherited from class org.apache.batik.dom.AbstractParentNode
childNodesFields inherited from class org.apache.batik.dom.AbstractNode
DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, EMPTY_NODE_LIST, eventSupport, managerData, ownerDocument, userData, userDataHandlersFields 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
ConstructorsConstructorDescriptionAbstractJEuclidElement(String nsUri, String qname, org.apache.batik.dom.AbstractDocument odoc) Constructor to explicitly set the namespace.AbstractJEuclidElement(String qname, org.apache.batik.dom.AbstractDocument odoc) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddMathElement(MathMLElement child) Add a math element as a child.Retrieve the LayoutContext valid for the current node.protected voidOverride this function to get notified whenever the contents of this element have changed.booleandispatchEvent(Event evt) getChildLayoutContext(int childNum, LayoutContext context) get the layout context for the given child.The class attribute of the element.Returns the children as a MathML NodeList.getFont(LayoutContext context) Gets the used font.getFontMetrics(Graphics2D g, LayoutContext context) Gets the font metrics of the used font.getHref()The xlink:href attribute of the element.getId()The element's identifier.intgetIndexOfMathElement(JEuclidElement element) Gets index of child element.protected StringgetMathAttribute(String attrName) retrieve an attribute from the MathML or default name space, returning the default value if the attribute is not set.protected StringgetMathAttribute(String attrName, boolean useDefault) retrieve an attribute from the MathML or default name space.Returns value of mathbackground attribute.Returns value of mathcolor attribute.protected JEuclidElementgetMathElement(int index) Gets a child from this element.intReturns the count of children for this element.A string identifying the element's style attribute.Retrieve the mathsize attribute.Returns value of mathvariant attribute (style of the element).Gets the current mathvariant.floatgetMiddleShift(Graphics2D g, LayoutContext context) Returns the distance of the baseline and the middleline.The MathMLMathElement corresponding to the nearest math element ancestor of this element.Returns parent of this element.getText()Returns the text content of this element.getXref()The xref attribute of the element.booleanhasChildPostscripts(JEuclidElement child, LayoutContext context) returns true is the child has postscripts attached to it.booleanhasChildPrescripts(JEuclidElement child) returns true is the child has prescripts attached to it.voidlayoutStage1(LayoutView view, LayoutInfo info, LayoutStage childMinStage, LayoutContext context) context insensitive layout.voidlayoutStage2(LayoutView view, LayoutInfo info, LayoutContext context) context sensitive layout.protected voidlayoutStageInvariant(LayoutView view, LayoutInfo info, LayoutStage stage, LayoutContext context) Layout for elements which are stage independent.voidsetClassName(String className) setter for the className attribute.protected voidsetDefaultMathAttribute(String key, String value) Sets default values for math attributes.voidsetFakeParent(JEuclidElement parent) Sets the parent of this element.voidsetter for the href attribute.voidsetter for the id attribute.voidsetMathbackground(String mathbackground) Sets the value of the machbackground attribute.voidsetMathcolor(String mathcolor) Sets value of math color attribute.protected voidsetMathElement(int index, MathMLElement newElement) Sets a specific child to the newElement, creating other subelements as necessary.voidsetMathElementStyle(String mathElementStyle) setter for the mathElementStyle attribute.voidsetMathsize(String mathsize) Sets mathsize to a new value.voidsetMathvariant(String mathvariant) Sets value of mathvariant attribute (style of the element).voidsetter for the xref attribute.Methods inherited from class org.apache.batik.dom.GenericElementNS
copyInto, deepCopyInto, deepExport, export, getNodeName, isReadonly, newNode, setNodeName, setReadonlyMethods inherited from class org.apache.batik.dom.AbstractElementNS
getNamespaceURIMethods inherited from class org.apache.batik.dom.AbstractElement
attrAdded, attrModified, attrRemoved, checkChildType, createAttributes, fireDOMAttrModifiedEvent, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildElementCount, getFirstElementChild, getIdAttribute, getLastElementChild, getNextElementSibling, getNodeType, getPreviousElementSibling, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, hasAttributes, nodeAdded, nodeToBeRemoved, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNSMethods inherited from class org.apache.batik.dom.AbstractParentChildNode
getNextSibling, getParentNode, getPreviousSibling, setNextSibling, setParentNode, setPreviousSiblingMethods inherited from class org.apache.batik.dom.AbstractParentNode
appendChild, checkAndRemove, fireDOMNodeInsertedEvent, fireDOMNodeInsertedIntoDocumentEvent, fireDOMNodeRemovedEvent, fireDOMNodeRemovedFromDocumentEvent, fireDOMSubtreeModifiedEvent, getChildNodes, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getLastChild, getTextContent, hasChildNodes, insertBefore, removeChild, replaceChildMethods inherited from class org.apache.batik.dom.AbstractNode
addEventListener, addEventListenerNS, cloneNode, compareDocumentPosition, compareNamedNodeMaps, compareStrings, createDOMException, fireDOMCharacterDataModifiedEvent, fireUserDataHandlers, getBaseURI, getBaseURI, getCascadedXMLBase, getCurrentDocument, getEventSupport, getFeature, getLocalName, getManagerData, getNodeValue, getOwnerDocument, getParentNodeEventTarget, getPrefix, getUserData, getXblBoundElement, getXblChildNodes, getXblDefinitions, getXblFirstChild, getXblFirstElementChild, getXblLastChild, getXblLastElementChild, getXblNextElementSibling, getXblNextSibling, getXblParentNode, getXblPreviousElementSibling, getXblPreviousSibling, getXblScopedChildNodes, getXblShadowTree, hasEventListenerNS, initializeEventSupport, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespacePrefix, lookupNamespaceURI, lookupPrefix, removeEventListener, removeEventListenerNS, setManagerData, setNodeValue, setOwnerDocument, setPrefix, setSpecified, setTextContent, setUserData, willTriggerNSMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, setIdAttributeNSMethods 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
-
Field Details
-
ATTR_MATHVARIANT
Constant for mathvariant attribute.- See Also:
-
ATTR_MATHCOLOR
Constant for mathcolor attribute.- See Also:
-
ATTR_MATHSIZE
Constant for mathsize attribute.- See Also:
-
ATTR_DEPRECATED_FONTFAMILY
Constant for fontfamily attribute.- See Also:
-
ATTR_DEPRECATED_FONTSTYLE
Constant for fontstyle attribute.- See Also:
-
ATTR_DEPRECATED_FONTWEIGHT
Constant for fontweight attribute.- See Also:
-
ATTR_DEPRECATED_FONTSIZE
Constant for fontsize attribute.- See Also:
-
ATTR_DEPRECATED_COLOR
Constant for color attribute.- See Also:
-
ATTR_DEPRECATED_BACKGROUND
Constant for background attribute.- See Also:
-
ATTR_CLASS
Constant for class attribute.- See Also:
-
ATTR_STYLE
Constant for style attribute.- See Also:
-
ATTR_ID
Constant for id attribute.- See Also:
-
ATTR_HREF
Constant for href attribute.- See Also:
-
ATTR_XREF
Constant for xref attribute.- See Also:
-
ATTR_MATHBACKGROUND
The mathbackground attribute.- See Also:
-
TRIVIAL_SPACE_MAX
public static final int TRIVIAL_SPACE_MAXlargest value for all trivial spaces (= spaces that can be ignored / shortened).- See Also:
-
URI
The URI from MathML.- See Also:
-
-
Constructor Details
-
AbstractJEuclidElement
Default constructor. Sets MathML Namespace.- Parameters:
qname- Qualified name.odoc- Owner Document.
-
AbstractJEuclidElement
public AbstractJEuclidElement(String nsUri, String qname, org.apache.batik.dom.AbstractDocument odoc) Constructor to explicitly set the namespace.- Parameters:
nsUri- Namespace URI.qname- Qualified name.odoc- Owner Document.
-
-
Method Details
-
getFont
Gets the used font. Everything regardes font, processed by MathBase object.- Parameters:
context- LayoutContext to use.- Returns:
- Font Font object.
-
getMathvariantAsVariant
Gets the current mathvariant.- Specified by:
getMathvariantAsVariantin interfaceJEuclidElement- Returns:
- the current MathVariant
-
addMathElement
Add a math element as a child.- Parameters:
child- Math element object.
-
getMathElement
Gets a child from this element.Please note, that unlike the MathML DOM model functions this function uses a 0-based index.
- Parameters:
index- Index of the child (0-based).- Returns:
- The child MathElement object.
-
setMathElement
Sets a specific child to the newElement, creating other subelements as necessary.- Parameters:
index- the index to set (0=the first child)newElement- new element to be set as child.
-
getIndexOfMathElement
Gets index of child element.- Specified by:
getIndexOfMathElementin interfaceJEuclidElement- Parameters:
element- Child element.- Returns:
- Index of the element, -1 if element was not found
-
getMathElementCount
public int getMathElementCount()Returns the count of children for this element.- Specified by:
getMathElementCountin interfaceJEuclidElement- Returns:
- number of children.
-
getText
Returns the text content of this element.- Returns:
- Text content.
-
setFakeParent
Sets the parent of this element.- Specified by:
setFakeParentin interfaceJEuclidElement- Parameters:
parent- Parent element
-
getParent
Returns parent of this element.- Specified by:
getParentin interfaceJEuclidElement- Returns:
- Parent element.
-
setMathvariant
Sets value of mathvariant attribute (style of the element).- Parameters:
mathvariant- Value of mathvariant.
-
getMathvariant
Returns value of mathvariant attribute (style of the element).- Returns:
- Value of mathvariant.
-
getFontMetrics
Gets the font metrics of the used font.- Parameters:
g- Graphics2D context to use.context- LayoutContext to use.- Returns:
- Font metrics.
-
setMathcolor
Sets value of math color attribute.- Parameters:
mathcolor- Color object.
-
getMathcolor
Returns value of mathcolor attribute.- Returns:
- Color as string.
-
getMathsize
Retrieve the mathsize attribute.- Returns:
- the mathsize attribute.
-
setMathsize
Sets mathsize to a new value.- Parameters:
mathsize- value of mathsize.
-
setDefaultMathAttribute
Sets default values for math attributes. Default values are returned through getMathAttribute, but not stored in the actual DOM tree. This is necessary to support proper serialization.- Parameters:
key- the attribute to set.value- value of the attribute.
-
getMathAttribute
retrieve an attribute from the MathML or default name space, returning the default value if the attribute is not set.- Parameters:
attrName- the name of the attribute- Returns:
- attribute value or null if not set.
- See Also:
-
getMathAttribute
retrieve an attribute from the MathML or default name space.- Parameters:
attrName- the name of the attributeuseDefault- is true, the default value is used if the attribute is not set.- Returns:
- attribute value or null if not set.
- See Also:
-
getMathbackground
Returns value of mathbackground attribute.- Returns:
- Color as string.
-
setMathbackground
Sets the value of the machbackground attribute.- Parameters:
mathbackground- a string to be used as background color.
-
getMiddleShift
Returns the distance of the baseline and the middleline.- Parameters:
g- Graphics2D context to use.context- Layout Context to use- Returns:
- Distance baseline - middleline.
-
getClassName
The class attribute of the element. See the discussion elsewhere in this document of the class attribute; see also the HTML definition of this attribute.- Specified by:
getClassNamein interfaceMathMLElement- Returns:
- value of the className attribute.
-
setClassName
setter for the className attribute.- Specified by:
setClassNamein interfaceMathMLElement- Parameters:
className- new value for className.- See Also:
-
getMathElementStyle
A string identifying the element's style attribute.- Specified by:
getMathElementStylein interfaceMathMLElement- Returns:
- value of the mathElementStyle attribute.
-
setMathElementStyle
setter for the mathElementStyle attribute.- Specified by:
setMathElementStylein interfaceMathMLElement- Parameters:
mathElementStyle- new value for mathElementStyle.- See Also:
-
getId
The element's identifier. See the discussion elsewhere in this document of the id attribute; see also the HTML definition.- Specified by:
getIdin interfaceMathMLElement- Overrides:
getIdin classorg.apache.batik.dom.AbstractElement- Returns:
- value of the id attribute.
-
setId
setter for the id attribute.- Specified by:
setIdin interfaceMathMLElement- Parameters:
id- new value for id.- See Also:
-
getXref
The xref attribute of the element. See the discussion elsewhere in this document of the xref attribute.- Specified by:
getXrefin interfaceMathMLElement- Returns:
- value of the xref attribute.
-
setXref
setter for the xref attribute.- Specified by:
setXrefin interfaceMathMLElement- Parameters:
xref- new value for xref.- See Also:
-
getHref
The xlink:href attribute of the element. See the discussion elsewhere in this document of the xlink:href attribute; see also the definition of this attribute in the XLink specification.- Specified by:
getHrefin interfaceMathMLElement- Returns:
- value of the href attribute.
-
setHref
setter for the href attribute.- Specified by:
setHrefin interfaceMathMLElement- Parameters:
href- new value for href.- See Also:
-
getOwnerMathElement
The MathMLMathElement corresponding to the nearest math element ancestor of this element. Should be null if this element is a top-level math element.- Specified by:
getOwnerMathElementin interfaceMathMLElement- Returns:
- value of the ownerMathElement attribute.
-
hasChildPrescripts
returns true is the child has prescripts attached to it. In this case, there should be no extra space on the left.- Specified by:
hasChildPrescriptsin interfaceJEuclidElement- Parameters:
child- child to test- Returns:
- true if there are attached prescripts
-
hasChildPostscripts
returns true is the child has postscripts attached to it. In this case, there should be no extra space on the left.- Specified by:
hasChildPostscriptsin interfaceJEuclidElement- Parameters:
child- child to testcontext- current layout context.- Returns:
- true if there are attached postscripts
-
getContents
Returns the children as a MathML NodeList.- Returns:
- a list of children
-
getChildLayoutContext
get the layout context for the given child.- Specified by:
getChildLayoutContextin interfaceJEuclidNode- Parameters:
childNum- 0-based number of the child to check.context- external context.- Returns:
- layout context to use.
-
applyLocalAttributesToContext
Retrieve the LayoutContext valid for the current node.- Parameters:
context- external context.- Returns:
- the current layout context.
-
getChildrenToLayout
- Specified by:
getChildrenToLayoutin interfaceLayoutableNode- Returns:
- List of children to Layout. Normally, all children.
-
getChildrenToDraw
- Specified by:
getChildrenToDrawin interfaceLayoutableNode- Returns:
- List of children to Draw. Normally, all children.
-
layoutStageInvariant
protected void layoutStageInvariant(LayoutView view, LayoutInfo info, LayoutStage stage, LayoutContext context) Layout for elements which are stage independent.This function will layout an element which is layed out the same no matter what stage it is in. This is the case for most elements.
Notable exceptions are mo and tables.
- Parameters:
view- View Object for this layout.info- An info object which will be filled during layout.stage- current layout stage.context- current LayoutContext.
-
layoutStage1
public void layoutStage1(LayoutView view, LayoutInfo info, LayoutStage childMinStage, LayoutContext context) context insensitive layout.- Specified by:
layoutStage1in interfaceLayoutableNode- Parameters:
view- LayoutView to use.info- LayoutInfo to manipulate.childMinStage- minimum stage of children. Either STAGE1 or STAGE2.context- LayoutContext for this element.
-
layoutStage2
context sensitive layout.- Specified by:
layoutStage2in interfaceLayoutableNode- Parameters:
view- LayoutView to use.info- LayoutInfo to manipulate.context- LayoutContext for this element.
-
changeHook
protected void changeHook()Override this function to get notified whenever the contents of this element have changed. -
dispatchEvent
- Specified by:
dispatchEventin interfaceEventTarget- Specified by:
dispatchEventin interfaceorg.apache.batik.dom.events.NodeEventTarget- Overrides:
dispatchEventin classorg.apache.batik.dom.AbstractNode
-