Class SVGElement

    • Field Detail

      • children

        protected final java.util.ArrayList<SVGElement> children
      • id

        protected java.lang.String id
      • cssClass

        protected java.lang.String cssClass
        CSS class. Used for applying style sheet information.
      • inlineStyles

        protected final java.util.HashMap<java.lang.String,​StyleAttribute> inlineStyles
        Styles defined for this elemnt via the style attribute.
      • presAttribs

        protected final java.util.HashMap<java.lang.String,​StyleAttribute> presAttribs
        Presentation attributes set for this element. Ie, any attribute other than the style attribute.
      • ignorePresAttrib

        protected static final java.util.Set<java.lang.String> ignorePresAttrib
        A list of presentation attributes to not include in the presentation attribute set.
      • xmlBase

        protected java.net.URI xmlBase
        This element may override the URI we resolve against with an xml:base attribute. If so, a copy is placed here. Otherwise, we defer to our parent for the reolution base
      • diagram

        protected SVGDiagram diagram
        The diagram this element belongs to
      • trackManager

        protected final TrackManager trackManager
        Link to the universe we reside in
      • dirty

        boolean dirty
      • contexts

        java.util.LinkedList<SVGElement> contexts
      • TRANSFORM_PATTERN

        private static final java.util.regex.Pattern TRANSFORM_PATTERN
      • WORD_PATTERN

        private static final java.util.regex.Pattern WORD_PATTERN
      • COMMAND_PATTERN

        private static final java.util.regex.Pattern COMMAND_PATTERN
    • Constructor Detail

      • SVGElement

        public SVGElement()
        Creates a new instance of SVGElement
      • SVGElement

        public SVGElement​(java.lang.String id,
                          SVGElement parent)
      • SVGElement

        public SVGElement​(java.lang.String id,
                          java.lang.String cssClass,
                          SVGElement parent)
    • Method Detail

      • getTagName

        public abstract java.lang.String getTagName()
      • setParent

        void setParent​(SVGElement parent)
      • getPath

        public java.util.List<SVGElement> getPath​(java.util.List<SVGElement> retVec)
        Parameters:
        retVec -
        Returns:
        an ordered list of nodes from the root of the tree to this node
      • getChildren

        public java.util.List<SVGElement> getChildren​(java.util.List<SVGElement> retVec)
        Parameters:
        retVec - - A list to add all children to. If null, a new list is created and children of this group are added.
        Returns:
        The list containing the children of this group
      • getChild

        public SVGElement getChild​(java.lang.String id)
        Parameters:
        id - - Id of svg element to return
        Returns:
        the child of the given id, or null if no such child exists.
      • indexOfChild

        public int indexOfChild​(SVGElement child)
        Searches children for given element. If found, returns index of child. Otherwise returns -1.
        Parameters:
        child -
        Returns:
        index of child
      • swapChildren

        public void swapChildren​(int i,
                                 int j)
                          throws SVGException
        Swaps 2 elements in children.
        Parameters:
        i - index of first child
        j - index of second child
        Throws:
        SVGException
      • loaderStartElement

        public void loaderStartElement​(SVGLoaderHelper helper,
                                       org.xml.sax.Attributes attrs,
                                       SVGElement parent)
                                throws org.xml.sax.SAXException
        Called during SAX load process to notify that this tag has begun the process of being loaded
        Parameters:
        attrs - - Attributes of this tag
        helper - - An object passed to all SVG elements involved in this build process to aid in sharing information.
        parent -
        Throws:
        org.xml.sax.SAXException
      • removeAttribute

        public void removeAttribute​(java.lang.String name,
                                    int attribType)
      • getInlineAttributes

        public java.util.Set<java.lang.String> getInlineAttributes()
        Returns:
        a set of Strings that corespond to CSS attributes on this element
      • getPresentationAttributes

        public java.util.Set<java.lang.String> getPresentationAttributes()
        Returns:
        a set of Strings that corespond to XML attributes on this element
      • setDiagram

        protected void setDiagram​(SVGDiagram diagram)
      • loaderAddText

        public void loaderAddText​(SVGLoaderHelper helper,
                                  java.lang.String text)
        Called during load process to add text scanned within a tag
        Parameters:
        helper -
        text -
      • loaderEndElement

        public void loaderEndElement​(SVGLoaderHelper helper)
                              throws SVGParseException
        Called to indicate that this tag and the tags it contains have been completely processed, and that it should finish any load processes.
        Parameters:
        helper -
        Throws:
        SVGParseException
      • build

        protected void build()
                      throws SVGException
        Called by internal processes to rebuild the geometry of this node from it's presentation attributes, style attributes and animated tracks.
        Throws:
        SVGException
      • getXMLBase

        public java.net.URI getXMLBase()
      • getId

        public java.lang.String getId()
        Returns:
        the id assigned to this node. Null if no id explicitly set.
      • pushParentContext

        protected void pushParentContext​(SVGElement context)
        Hack to allow nodes to temporarily change their parents. The Use tag will need this so it can alter the attributes that a particular node uses.
        Parameters:
        context -
      • popParentContext

        protected SVGElement popParentContext()
      • getParentContext

        protected SVGElement getParentContext()
      • getRoot

        public SVGRoot getRoot()
      • getStyle

        public boolean getStyle​(StyleAttribute attrib,
                                boolean recursive,
                                boolean evalAnimation)
                         throws SVGException
        Copies the current style into the passed style attribute. Checks for inline styles first, then internal and extranal style sheets, and finally checks for presentation attributes. Recursively checks parents.
        Parameters:
        attrib - - Attribute to write style data to. Must have it's name set to the name of the style being queried.
        recursive - - If true and this object does not contain the named style attribute, checks attributes of parents back to root until one found.
        evalAnimation -
        Returns:
        Throws:
        SVGException
      • getStyleAbsolute

        public StyleAttribute getStyleAbsolute​(java.lang.String styName)
        Parameters:
        styName -
        Returns:
        the raw style value of this attribute. Does not take the presentation value or animation into consideration. Used by animations to determine the base to animate from.
      • getPres

        public boolean getPres​(StyleAttribute attrib)
                        throws SVGException
        Copies the presentation attribute into the passed one.
        Parameters:
        attrib -
        Returns:
        - True if attribute was read successfully
        Throws:
        SVGException
      • getPresAbsolute

        public StyleAttribute getPresAbsolute​(java.lang.String styName)
        Parameters:
        styName -
        Returns:
        the raw presentation value of this attribute. Ignores any modifications applied by style attributes or animation. Used by animations to determine the starting point to animate from
      • parseTransform

        protected static java.awt.geom.AffineTransform parseTransform​(java.lang.String val)
                                                               throws SVGException
        Throws:
        SVGException
      • parseSingleTransform

        public static java.awt.geom.AffineTransform parseSingleTransform​(java.lang.String val)
                                                                  throws SVGException
        Throws:
        SVGException
      • nextFloat

        protected static float nextFloat​(java.util.LinkedList<java.lang.String> l)
      • parsePathList

        protected static PathCommand[] parsePathList​(java.lang.String list)
      • buildPath

        protected static java.awt.geom.GeneralPath buildPath​(java.lang.String text,
                                                             int windingRule)
      • updateTime

        public abstract boolean updateTime​(double curTime)
                                    throws SVGException
        Updates all attributes in this diagram associated with a time event. Ie, all attributes with track information.
        Parameters:
        curTime -
        Returns:
        - true if this node has changed state as a result of the time update
        Throws:
        SVGException
      • getNumChildren

        public int getNumChildren()
      • getChild

        public SVGElement getChild​(int i)
      • lerp

        public double lerp​(double t0,
                           double t1,
                           double alpha)