JHotDraw 7.0.9

org.jhotdraw.samples.svg.io
Class SVGInputFormat

java.lang.Object
  extended by org.jhotdraw.samples.svg.io.SVGInputFormat
All Implemented Interfaces:
InputFormat
Direct Known Subclasses:
SVGZInputFormat

public class SVGInputFormat
extends java.lang.Object
implements InputFormat

SVGInputFormat. This format is aimed to comply to the Scalable Vector Graphics (SVG) Tiny 1.2 Specification supporting the SVG-static feature string. http://www.w3.org/TR/SVGMobile12/

Version:
1.1.1 2007-04-23 Fixed reading of "transform" attribute, fixed reading of "textArea" element.
1.1 2007-04-22 Added support for "a" element.
0.2 2007-04-10 Fixed default attribute values for RadialGradient element.
0.1 November 25, 2006 Created (Experimental).
Author:
Werner Randelshofer

Constructor Summary
SVGInputFormat()
          Creates a new instance.
SVGInputFormat(SVGFigureFactory factory)
           
 
Method Summary
 javax.swing.filechooser.FileFilter getFileFilter()
          Return a FileFilter that can be used to identify files which can be restored with this Storage Format.
 javax.swing.JComponent getInputFormatAccessory()
          Return a JFileChooser accessory that can be used to customize the input format.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.
 void read(java.io.File file, Drawing drawing)
          Reads figures from a file and adds them to the specified drawing.
 void read(java.io.InputStream in, Drawing drawing)
          Reads figures from a file and adds them to the specified drawing.
 java.util.LinkedList<Figure> readFigures(java.io.InputStream in)
          This is the mean reading method.
 java.util.LinkedList<Figure> readFigures(java.awt.datatransfer.Transferable t)
          Reads figures from the specified Transferable.
static java.lang.String[] toCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
static java.awt.geom.AffineTransform toTransform(net.n3.nanoxml.IXMLElement elem, java.lang.String str)
           
static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGInputFormat

public SVGInputFormat()
Creates a new instance.


SVGInputFormat

public SVGInputFormat(SVGFigureFactory factory)
Method Detail

readFigures

public java.util.LinkedList<Figure> readFigures(java.io.InputStream in)
                                         throws java.io.IOException
This is the mean reading method.

Throws:
java.io.IOException

toCommaSeparatedArray

public static java.lang.String[] toCommaSeparatedArray(java.lang.String str)
                                                throws java.io.IOException
Returns a value as a String array. The values are separated by commas with optional white space.

Throws:
java.io.IOException

toWSOrCommaSeparatedArray

public static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
                                                    throws java.io.IOException
Returns a value as a String array. The values are separated by whitespace or by commas with optional white space.

Throws:
java.io.IOException

toTransform

public static java.awt.geom.AffineTransform toTransform(net.n3.nanoxml.IXMLElement elem,
                                                        java.lang.String str)
                                                 throws java.io.IOException
Throws:
java.io.IOException

getFileFilter

public javax.swing.filechooser.FileFilter getFileFilter()
Description copied from interface: InputFormat
Return a FileFilter that can be used to identify files which can be restored with this Storage Format. Typically, each input format has its own recognizable file naming convention.

Specified by:
getFileFilter in interface InputFormat
Returns:
FileFilter to be used with a javax.swing.JFileChooser

getInputFormatAccessory

public javax.swing.JComponent getInputFormatAccessory()
Description copied from interface: InputFormat
Return a JFileChooser accessory that can be used to customize the input format.

Specified by:
getInputFormatAccessory in interface InputFormat
Returns:
A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.

read

public void read(java.io.File file,
                 Drawing drawing)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
file - The file.
drawing - The drawing.
Throws:
java.io.IOException

read

public void read(java.io.InputStream in,
                 Drawing drawing)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
in - The input stream.
drawing - The drawing.
Throws:
java.io.IOException

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Description copied from interface: InputFormat
Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.

Specified by:
isDataFlavorSupported in interface InputFormat
Parameters:
flavor - A DataFlavor.

readFigures

public java.util.LinkedList<Figure> readFigures(java.awt.datatransfer.Transferable t)
                                         throws java.awt.datatransfer.UnsupportedFlavorException,
                                                java.io.IOException
Description copied from interface: InputFormat
Reads figures from the specified Transferable.

Specified by:
readFigures in interface InputFormat
Parameters:
t - The Transferable.
Returns:
The figures that were readFigures from the Transferable.
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.