com.kitfox.svg
Class SVGElement

java.lang.Object
  extended by com.kitfox.svg.SVGElement
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AnimationElement, ClipPath, Desc, FillElement, Filter, FilterEffects, Font, FontFace, Metadata, Stop, Style, Title, TransformableElement

public abstract class SVGElement
extends java.lang.Object
implements java.io.Serializable

Author:
Mark McKay, Mark McKay
See Also:
Serialized Form

Field Summary
protected  java.util.Vector children
           
protected  java.lang.String cssClass
          CSS class.
protected  SVGDiagram diagram
          The diagram this element belongs to
protected  java.lang.String id
           
protected static java.util.Set ignorePresAttrib
          A list of presentation attributes to not include in the presentation attribute set.
protected  java.util.HashMap inlineStyles
          Styles defined for this elemnt via the style attribute.
protected  SVGElement parent
           
protected  java.util.HashMap presAttribs
          Presentation attributes set for this element.
static long serialVersionUID
           
static java.lang.String SVG_NS
           
protected  TrackManager trackManager
          Link to the universe we reside in
protected  java.net.URI xmlBase
          This element may override the URI we resolve against with an xml:base attribute.
 
Constructor Summary
SVGElement()
          Creates a new instance of SVGElement
SVGElement(java.lang.String id, java.lang.String cssClass, SVGElement parent)
           
SVGElement(java.lang.String id, SVGElement parent)
           
 
Method Summary
 void addAttribute(java.lang.String name, int attribType, java.lang.String value)
           
protected  void build()
          Called by internal processes to rebuild the geometry of this node from it's presentation attributes, style attributes and animated tracks.
protected static java.awt.geom.GeneralPath buildPath(java.lang.String text, int windingRule)
           
 SVGElement getChild(java.lang.String id)
           
 java.util.Vector getChildren(java.util.Vector retVec)
           
 java.lang.String getId()
           
 java.util.Set getInlineAttributes()
           
 SVGElement getParent()
           
protected  SVGElement getParentContext()
           
 java.util.Vector getPath(java.util.Vector retVec)
           
 boolean getPres(StyleAttribute attrib)
          Copies the presentation attribute into the passed one.
 StyleAttribute getPresAbsolute(java.lang.String styName)
           
 java.util.Set getPresentationAttributes()
           
 boolean getStyle(StyleAttribute attrib)
           
 boolean getStyle(StyleAttribute attrib, boolean recursive)
          Copies the current style into the passed style attribute.
 StyleAttribute getStyleAbsolute(java.lang.String styName)
           
 java.net.URI getXMLBase()
           
 boolean hasAttribute(java.lang.String name, int attribType)
           
 int indexOfChild(SVGElement child)
          Searches children for given element.
 void loaderAddChild(SVGLoaderHelper helper, SVGElement child)
          Called after the start element but before the end element to indicate each child tag that has been processed
 void loaderAddText(SVGLoaderHelper helper, java.lang.String text)
          Called during load process to add text scanned within a tag
 void loaderEndElement(SVGLoaderHelper helper)
          Called to indicate that this tag and the tags it contains have been completely processed, and that it should finish any load processes.
 void loaderStartElement(SVGLoaderHelper helper, org.xml.sax.Attributes attrs, SVGElement parent)
          Called during SAX load process to notify that this tag has begun the process of being loaded
protected static float nextFloat(java.util.LinkedList l)
           
protected static PathCommand[] parsePathList(java.lang.String list)
           
static java.awt.geom.AffineTransform parseSingleTransform(java.lang.String val)
           
protected static java.awt.geom.AffineTransform parseTransform(java.lang.String val)
           
protected  SVGElement popParentContext()
           
protected  void pushParentContext(SVGElement context)
          Hack to allow nodes to temporarily change their parents.
 void removeChild(SVGElement child)
           
 void setAttribute(java.lang.String name, int attribType, java.lang.String value)
           
 void swapChildren(int i, int j)
          Swaps 2 elements in children.
abstract  boolean updateTime(double curTime)
          Updates all attributes in this diagram associated with a time event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

SVG_NS

public static final java.lang.String SVG_NS
See Also:
Constant Field Values

parent

protected SVGElement parent

children

protected final java.util.Vector 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 inlineStyles
Styles defined for this elemnt via the style attribute.


presAttribs

protected final java.util.HashMap presAttribs
Presentation attributes set for this element. Ie, any attribute other than the style attribute.


ignorePresAttrib

protected static final java.util.Set 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

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

getParent

public SVGElement getParent()

getPath

public java.util.Vector getPath(java.util.Vector retVec)
Returns:
an ordered list of nodes from the root of the tree to this node

getChildren

public java.util.Vector getChildren(java.util.Vector retVec)
Parameters:
retVec - - A vector to add all children to. If null, a new vector is created and children of this group are added.
Returns:
The vector 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.


swapChildren

public void swapChildren(int i,
                         int j)
                  throws SVGException
Swaps 2 elements in children.

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.
Throws:
org.xml.sax.SAXException

addAttribute

public void addAttribute(java.lang.String name,
                         int attribType,
                         java.lang.String value)
                  throws SVGElementException
Throws:
SVGElementException

hasAttribute

public boolean hasAttribute(java.lang.String name,
                            int attribType)
                     throws SVGElementException
Throws:
SVGElementException

getInlineAttributes

public java.util.Set getInlineAttributes()
Returns:
a set of Strings that corespond to CSS attributes on this element

getPresentationAttributes

public java.util.Set getPresentationAttributes()
Returns:
a set of Strings that corespond to XML attributes on this element

loaderAddChild

public void loaderAddChild(SVGLoaderHelper helper,
                           SVGElement child)
                    throws SVGElementException
Called after the start element but before the end element to indicate each child tag that has been processed

Throws:
SVGElementException

removeChild

public void removeChild(SVGElement child)
                 throws SVGElementException
Throws:
SVGElementException

loaderAddText

public void loaderAddText(SVGLoaderHelper helper,
                          java.lang.String text)
Called during load process to add text scanned within a tag


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.

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.


popParentContext

protected SVGElement popParentContext()

getParentContext

protected SVGElement getParentContext()

getStyle

public boolean getStyle(StyleAttribute attrib)
                 throws SVGException
Throws:
SVGException

setAttribute

public void setAttribute(java.lang.String name,
                         int attribType,
                         java.lang.String value)
                  throws SVGElementException
Throws:
SVGElementException

getStyle

public boolean getStyle(StyleAttribute attrib,
                        boolean recursive)
                 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 abck to root until one found.
Throws:
SVGException

getStyleAbsolute

public StyleAttribute getStyleAbsolute(java.lang.String 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.

Returns:
- True if attribute was read successfully
Throws:
SVGException

getPresAbsolute

public StyleAttribute getPresAbsolute(java.lang.String 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 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.

Returns:
- true if this node has changed state as a result of the time update
Throws:
SVGException