com.kitfox.svg
Class SVGUniverse

java.lang.Object
  extended by com.kitfox.svg.SVGUniverse
All Implemented Interfaces:
java.io.Serializable

public class SVGUniverse
extends java.lang.Object
implements java.io.Serializable

Many SVG files can be loaded at one time. These files will quite likely need to reference one another. The SVG universe provides a container for all these files and the means for them to relate to each other.

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

Field Summary
protected  double curTime
          Current time in this universe.
static java.lang.String INPUTSTREAM_SCHEME
           
static long serialVersionUID
           
 
Constructor Summary
SVGUniverse()
          Creates a new instance of SVGUniverse
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void clear()
          Release all loaded SVG document from memory
 double getCurTime()
          Returns the current animation time in milliseconds.
 Font getDefaultFont()
           
 SVGDiagram getDiagram(java.net.URI xmlBase)
           
 SVGDiagram getDiagram(java.net.URI xmlBase, boolean loadIfAbsent)
          Returns the diagram that has been loaded from this root.
 SVGElement getElement(java.net.URI path)
          Returns the element of the document at the given URI.
 SVGElement getElement(java.net.URI path, boolean loadIfAbsent)
          Looks up a href within our universe.
 SVGElement getElement(java.net.URL path)
           
 Font getFont(java.lang.String fontName)
           
 java.net.URI getStreamBuiltURI(java.lang.String name)
          Synthesize a URI for an SVGDiagram constructed from a stream.
 boolean isVerbose()
           
 java.net.URI loadSVG(java.io.InputStream is, java.lang.String name)
           
 java.net.URI loadSVG(java.io.Reader reader, java.lang.String name)
          This routine allows you to create SVG documents from data streams that may not necessarily have a URL to load from.
protected  java.net.URI loadSVG(java.net.URI xmlBase, java.io.Reader is)
           
 java.net.URI loadSVG(java.net.URL docRoot)
          Loads an SVG file and all the files it references from the URL provided.
static void main(java.lang.String[] argv)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void setCurTime(double curTime)
           
 void setVerbose(boolean verbose)
           
 void updateTime()
          Updates all time influenced style and presentation attributes in all SVG documents in this universe.
 
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

INPUTSTREAM_SCHEME

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

curTime

protected double curTime
Current time in this universe. Used for resolving attributes that are influenced by track information. Time is in milliseconds. Time 0 coresponds to the time of 0 in each member diagram.

Constructor Detail

SVGUniverse

public SVGUniverse()
Creates a new instance of SVGUniverse

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)

clear

public void clear()
Release all loaded SVG document from memory


getCurTime

public double getCurTime()
Returns the current animation time in milliseconds.


setCurTime

public void setCurTime(double curTime)

updateTime

public void updateTime()
                throws SVGException
Updates all time influenced style and presentation attributes in all SVG documents in this universe.

Throws:
SVGException

getDefaultFont

public Font getDefaultFont()

getFont

public Font getFont(java.lang.String fontName)

getElement

public SVGElement getElement(java.net.URI path)
Returns the element of the document at the given URI. If the document is not already loaded, it will be.


getElement

public SVGElement getElement(java.net.URL path)

getElement

public SVGElement getElement(java.net.URI path,
                             boolean loadIfAbsent)
Looks up a href within our universe. If the href refers to a document that is not loaded, it will be loaded. The URL #target will then be checked against the SVG diagram's index and the coresponding element returned. If there is no coresponding index, null is returned.


getDiagram

public SVGDiagram getDiagram(java.net.URI xmlBase)

getDiagram

public SVGDiagram getDiagram(java.net.URI xmlBase,
                             boolean loadIfAbsent)
Returns the diagram that has been loaded from this root. If diagram is not already loaded, returns null.


loadSVG

public java.net.URI loadSVG(java.net.URL docRoot)
Loads an SVG file and all the files it references from the URL provided. If a referenced file already exists in the SVG universe, it is not reloaded.

Parameters:
docRoot - - URL to the location where this SVG file can be found.
Returns:
- The URI that refers to the loaded document

loadSVG

public java.net.URI loadSVG(java.io.InputStream is,
                            java.lang.String name)

loadSVG

public java.net.URI loadSVG(java.io.Reader reader,
                            java.lang.String name)
This routine allows you to create SVG documents from data streams that may not necessarily have a URL to load from. Since every SVG document must be identified by a unique URL, Salamander provides a method to fake this for streams by defining it's own protocol - svgSalamander - for SVG documents without a formal URL.

Parameters:
reader - - A stream containing a valid SVG document
name - -

A unique name for this document. It will be used to construct a unique URI to refer to this document and perform resolution with relative URIs within this document.

For example, a name of "/myScene" will produce the URI svgSalamander:/myScene. "/maps/canada/toronto" will produce svgSalamander:/maps/canada/toronto. If this second document then contained the href "../uk/london", it would resolve by default to svgSalamander:/maps/uk/london. That is, SVG Salamander defines the URI scheme svgSalamander for it's own internal use and uses it for uniquely identfying documents loaded by stream.

If you need to link to documents outside of this scheme, you can either supply full hrefs (eg, href="url(http://www.kitfox.com/index.html)") or put the xml:base attribute in a tag to change the defaultbase URIs are resolved against

If a name does not start with the character '/', it will be automatically prefixed to it.

Returns:
- The URI that refers to the loaded document

getStreamBuiltURI

public java.net.URI getStreamBuiltURI(java.lang.String name)
Synthesize a URI for an SVGDiagram constructed from a stream.

Parameters:
name - - Name given the document constructed from a stream.

loadSVG

protected java.net.URI loadSVG(java.net.URI xmlBase,
                               java.io.Reader is)

main

public static void main(java.lang.String[] argv)

isVerbose

public boolean isVerbose()

setVerbose

public void setVerbose(boolean verbose)