com.bonevich.erj.xml
Class SVGReader

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.bonevich.erj.xml.SVGReader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class SVGReader
extends org.xml.sax.helpers.DefaultHandler


Field Summary
protected  org.tigris.gef.base.Diagram _diagram
           
protected  java.util.HashMap _figRegistry
           
protected  int _nestedGroups
           
protected  java.util.HashMap _ownerRegistry
           
 
Constructor Summary
protected SVGReader()
          We are a Singleton Pattern, so the default constructor is not publicly available.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
protected  java.awt.Color colorByName(java.lang.String name, java.awt.Color defaultColor)
           
 void endElement(java.lang.String namespace, java.lang.String localName, java.lang.String qualifiedName)
           
protected  org.tigris.gef.presentation.Fig findFig(java.lang.String uri)
           
protected  java.lang.Object findOwner(java.lang.String uri)
           
static SVGReader getInstance()
          Singleton instance accessor.
protected  org.tigris.gef.presentation.FigCircle handleEllipse(org.xml.sax.Attributes attrs)
           
protected  org.tigris.gef.presentation.Fig handleGroup(org.xml.sax.Attributes attrs)
          Returns Fig rather than FigGroups because this is also used for FigEdges.
protected  org.tigris.gef.presentation.FigLine handleLine(org.xml.sax.Attributes attrs)
           
protected  org.tigris.gef.presentation.FigPoly handlePath(org.xml.sax.Attributes attrs)
           
protected  org.tigris.gef.presentation.Fig handlePolyLine(org.xml.sax.Attributes attrs)
           
protected  org.tigris.gef.presentation.FigRect handleRect(org.xml.sax.Attributes attrs)
           
protected  void handleSVG(org.xml.sax.Attributes attrs)
           
protected  org.tigris.gef.presentation.FigText handleText(org.xml.sax.Attributes attrs)
           
protected  void initDiagram(java.lang.String descriptor)
          Instantiate and initialize a diagram given a descriptor.
protected  void lineStateStartElement(java.lang.String tagName, org.xml.sax.Attributes attrs)
           
protected  java.awt.Color parseColor(java.lang.String name, java.awt.Color defaultColor)
           
protected  java.lang.String parseStyle(java.lang.String field, java.lang.String style)
          This method parses the 'style' attribute for a particular field
 org.tigris.gef.base.Diagram readDiagram(org.xml.sax.InputSource source)
          Read a diagram given an SVG InputSource.
 org.tigris.gef.base.Diagram readDiagram(java.io.InputStream is)
          Read a diagram given an InputStream on the SVG source.
 org.tigris.gef.base.Diagram readDiagram(java.net.URL url)
          Read a diagram given an URL to an SVG source.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
protected  void setAttrs(org.tigris.gef.presentation.Fig f, org.xml.sax.Attributes attrs)
           
protected  void setOwnerAttr(org.tigris.gef.presentation.Fig f, org.xml.sax.Attributes attrs)
           
 void setOwnerRegistry(java.util.HashMap owners)
          Initialize the mapping of Fig owner Ids to Fig owner instances.
 void startElement(java.lang.String namespace, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attrs)
           
protected  java.lang.String translateClassName(java.lang.String oldName)
          Translate a given class name into another???
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_diagram

protected org.tigris.gef.base.Diagram _diagram

_figRegistry

protected java.util.HashMap _figRegistry

_ownerRegistry

protected java.util.HashMap _ownerRegistry

_nestedGroups

protected int _nestedGroups
Constructor Detail

SVGReader

protected SVGReader()
We are a Singleton Pattern, so the default constructor is not publicly available.

Method Detail

getInstance

public static SVGReader getInstance()
Singleton instance accessor.


setOwnerRegistry

public void setOwnerRegistry(java.util.HashMap owners)
Initialize the mapping of Fig owner Ids to Fig owner instances.


readDiagram

public org.tigris.gef.base.Diagram readDiagram(java.io.InputStream is)
                                        throws java.io.IOException
Read a diagram given an InputStream on the SVG source. Note: does not close the stream after reading.

java.io.IOException

readDiagram

public org.tigris.gef.base.Diagram readDiagram(org.xml.sax.InputSource source)
                                        throws java.io.IOException
Read a diagram given an SVG InputSource.

java.io.IOException

readDiagram

public org.tigris.gef.base.Diagram readDiagram(java.net.URL url)
                                        throws java.io.IOException
Read a diagram given an URL to an SVG source.

java.io.IOException

initDiagram

protected void initDiagram(java.lang.String descriptor)
Instantiate and initialize a diagram given a descriptor. The descriptor is of the form "{{diagramClassName}}[|{{ownerInstanceId}}]"


startElement

public void startElement(java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.String qualifiedName,
                         org.xml.sax.Attributes attrs)
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String namespace,
                       java.lang.String localName,
                       java.lang.String qualifiedName)
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler

handleSVG

protected void handleSVG(org.xml.sax.Attributes attrs)

handleEllipse

protected org.tigris.gef.presentation.FigCircle handleEllipse(org.xml.sax.Attributes attrs)

handleGroup

protected org.tigris.gef.presentation.Fig handleGroup(org.xml.sax.Attributes attrs)
Returns Fig rather than FigGroups because this is also used for FigEdges.


handlePolyLine

protected org.tigris.gef.presentation.Fig handlePolyLine(org.xml.sax.Attributes attrs)

handleLine

protected org.tigris.gef.presentation.FigLine handleLine(org.xml.sax.Attributes attrs)

handlePath

protected org.tigris.gef.presentation.FigPoly handlePath(org.xml.sax.Attributes attrs)

handleRect

protected org.tigris.gef.presentation.FigRect handleRect(org.xml.sax.Attributes attrs)

handleText

protected org.tigris.gef.presentation.FigText handleText(org.xml.sax.Attributes attrs)

lineStateStartElement

protected void lineStateStartElement(java.lang.String tagName,
                                     org.xml.sax.Attributes attrs)

setAttrs

protected void setAttrs(org.tigris.gef.presentation.Fig f,
                        org.xml.sax.Attributes attrs)

setOwnerAttr

protected void setOwnerAttr(org.tigris.gef.presentation.Fig f,
                            org.xml.sax.Attributes attrs)

findFig

protected org.tigris.gef.presentation.Fig findFig(java.lang.String uri)

findOwner

protected java.lang.Object findOwner(java.lang.String uri)

translateClassName

protected java.lang.String translateClassName(java.lang.String oldName)
Translate a given class name into another???


parseColor

protected java.awt.Color parseColor(java.lang.String name,
                                    java.awt.Color defaultColor)

colorByName

protected java.awt.Color colorByName(java.lang.String name,
                                     java.awt.Color defaultColor)

parseStyle

protected java.lang.String parseStyle(java.lang.String field,
                                      java.lang.String style)
This method parses the 'style' attribute for a particular field

Parameters:
field - java.lang.String
style - java.lang.String
Returns:
java.lang.String


Copyright © 2001-2003 bonevich.com. All Rights Reserved.