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:
  • Field Details

  • Constructor Details

    • AbstractJEuclidElement

      public AbstractJEuclidElement(String qname, org.apache.batik.dom.AbstractDocument odoc)
      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

      public Font getFont(LayoutContext context)
      Gets the used font. Everything regardes font, processed by MathBase object.
      Parameters:
      context - LayoutContext to use.
      Returns:
      Font Font object.
    • getMathvariantAsVariant

      public MathVariant getMathvariantAsVariant()
      Gets the current mathvariant.
      Specified by:
      getMathvariantAsVariant in interface JEuclidElement
      Returns:
      the current MathVariant
    • addMathElement

      public final void addMathElement(MathMLElement child)
      Add a math element as a child.
      Parameters:
      child - Math element object.
    • getMathElement

      protected JEuclidElement getMathElement(int index)
      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

      protected void setMathElement(int index, MathMLElement newElement)
      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

      public int getIndexOfMathElement(JEuclidElement element)
      Gets index of child element.
      Specified by:
      getIndexOfMathElement in interface JEuclidElement
      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:
      getMathElementCount in interface JEuclidElement
      Returns:
      number of children.
    • getText

      public String getText()
      Returns the text content of this element.
      Returns:
      Text content.
    • setFakeParent

      public void setFakeParent(JEuclidElement parent)
      Sets the parent of this element.
      Specified by:
      setFakeParent in interface JEuclidElement
      Parameters:
      parent - Parent element
    • getParent

      public JEuclidElement getParent()
      Returns parent of this element.
      Specified by:
      getParent in interface JEuclidElement
      Returns:
      Parent element.
    • setMathvariant

      public void setMathvariant(String mathvariant)
      Sets value of mathvariant attribute (style of the element).
      Parameters:
      mathvariant - Value of mathvariant.
    • getMathvariant

      public String getMathvariant()
      Returns value of mathvariant attribute (style of the element).
      Returns:
      Value of mathvariant.
    • getFontMetrics

      public FontMetrics getFontMetrics(Graphics2D g, LayoutContext context)
      Gets the font metrics of the used font.
      Parameters:
      g - Graphics2D context to use.
      context - LayoutContext to use.
      Returns:
      Font metrics.
    • setMathcolor

      public void setMathcolor(String mathcolor)
      Sets value of math color attribute.
      Parameters:
      mathcolor - Color object.
    • getMathcolor

      public String getMathcolor()
      Returns value of mathcolor attribute.
      Returns:
      Color as string.
    • getMathsize

      public String getMathsize()
      Retrieve the mathsize attribute.
      Returns:
      the mathsize attribute.
    • setMathsize

      public void setMathsize(String mathsize)
      Sets mathsize to a new value.
      Parameters:
      mathsize - value of mathsize.
    • setDefaultMathAttribute

      protected void setDefaultMathAttribute(String key, String value)
      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

      protected String getMathAttribute(String attrName)
      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

      protected String getMathAttribute(String attrName, boolean useDefault)
      retrieve an attribute from the MathML or default name space.
      Parameters:
      attrName - the name of the attribute
      useDefault - is true, the default value is used if the attribute is not set.
      Returns:
      attribute value or null if not set.
      See Also:
    • getMathbackground

      public String getMathbackground()
      Returns value of mathbackground attribute.
      Returns:
      Color as string.
    • setMathbackground

      public void setMathbackground(String mathbackground)
      Sets the value of the machbackground attribute.
      Parameters:
      mathbackground - a string to be used as background color.
    • getMiddleShift

      public float getMiddleShift(Graphics2D g, LayoutContext context)
      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

      public String 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:
      getClassName in interface MathMLElement
      Returns:
      value of the className attribute.
    • setClassName

      public void setClassName(String className)
      setter for the className attribute.
      Specified by:
      setClassName in interface MathMLElement
      Parameters:
      className - new value for className.
      See Also:
    • getMathElementStyle

      public String getMathElementStyle()
      A string identifying the element's style attribute.
      Specified by:
      getMathElementStyle in interface MathMLElement
      Returns:
      value of the mathElementStyle attribute.
    • setMathElementStyle

      public void setMathElementStyle(String mathElementStyle)
      setter for the mathElementStyle attribute.
      Specified by:
      setMathElementStyle in interface MathMLElement
      Parameters:
      mathElementStyle - new value for mathElementStyle.
      See Also:
    • getId

      public String getId()
      The element's identifier. See the discussion elsewhere in this document of the id attribute; see also the HTML definition.
      Specified by:
      getId in interface MathMLElement
      Overrides:
      getId in class org.apache.batik.dom.AbstractElement
      Returns:
      value of the id attribute.
    • setId

      public void setId(String id)
      setter for the id attribute.
      Specified by:
      setId in interface MathMLElement
      Parameters:
      id - new value for id.
      See Also:
    • getXref

      public String getXref()
      The xref attribute of the element. See the discussion elsewhere in this document of the xref attribute.
      Specified by:
      getXref in interface MathMLElement
      Returns:
      value of the xref attribute.
    • setXref

      public void setXref(String xref)
      setter for the xref attribute.
      Specified by:
      setXref in interface MathMLElement
      Parameters:
      xref - new value for xref.
      See Also:
    • getHref

      public String 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:
      getHref in interface MathMLElement
      Returns:
      value of the href attribute.
    • setHref

      public void setHref(String href)
      setter for the href attribute.
      Specified by:
      setHref in interface MathMLElement
      Parameters:
      href - new value for href.
      See Also:
    • getOwnerMathElement

      public MathMLMathElement 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:
      getOwnerMathElement in interface MathMLElement
      Returns:
      value of the ownerMathElement attribute.
    • hasChildPrescripts

      public boolean hasChildPrescripts(JEuclidElement child)
      returns true is the child has prescripts attached to it. In this case, there should be no extra space on the left.
      Specified by:
      hasChildPrescripts in interface JEuclidElement
      Parameters:
      child - child to test
      Returns:
      true if there are attached prescripts
    • hasChildPostscripts

      public boolean hasChildPostscripts(JEuclidElement child, LayoutContext context)
      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
      Parameters:
      child - child to test
      context - current layout context.
      Returns:
      true if there are attached postscripts
    • getContents

      public MathMLNodeList getContents()
      Returns the children as a MathML NodeList.
      Returns:
      a list of children
    • getChildLayoutContext

      public LayoutContext getChildLayoutContext(int childNum, LayoutContext context)
      get the layout context for the given child.
      Specified by:
      getChildLayoutContext in interface JEuclidNode
      Parameters:
      childNum - 0-based number of the child to check.
      context - external context.
      Returns:
      layout context to use.
    • applyLocalAttributesToContext

      public LayoutContext applyLocalAttributesToContext(LayoutContext context)
      Retrieve the LayoutContext valid for the current node.
      Parameters:
      context - external context.
      Returns:
      the current layout context.
    • getChildrenToLayout

      public List<LayoutableNode> getChildrenToLayout()
      Specified by:
      getChildrenToLayout in interface LayoutableNode
      Returns:
      List of children to Layout. Normally, all children.
    • getChildrenToDraw

      public List<LayoutableNode> getChildrenToDraw()
      Specified by:
      getChildrenToDraw in interface LayoutableNode
      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:
      layoutStage1 in interface LayoutableNode
      Parameters:
      view - LayoutView to use.
      info - LayoutInfo to manipulate.
      childMinStage - minimum stage of children. Either STAGE1 or STAGE2.
      context - LayoutContext for this element.
    • layoutStage2

      public void layoutStage2(LayoutView view, LayoutInfo info, LayoutContext context)
      context sensitive layout.
      Specified by:
      layoutStage2 in interface LayoutableNode
      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

      public boolean dispatchEvent(Event evt)
      Specified by:
      dispatchEvent in interface EventTarget
      Specified by:
      dispatchEvent in interface org.apache.batik.dom.events.NodeEventTarget
      Overrides:
      dispatchEvent in class org.apache.batik.dom.AbstractNode