org.jhotdraw.samples.svg.io
Class SVGInputFormat
- java.lang.Object
-
- 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 theSVG-staticfeature string. http://www.w3.org/TR/SVGMobile12/Design pattern:
Name: Abstract Factory.
Role: Client.
Partners:SVGFigureFactoryas Abstract Factory.
-
-
Constructor Summary
Constructors Constructor and Description SVGInputFormat()Creates a new instance.SVGInputFormat(SVGFigureFactory factory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description javax.swing.filechooser.FileFiltergetFileFilter()Return a FileFilter that can be used to identify files which can be read with this input format.javax.swing.JComponentgetInputFormatAccessory()Return a JFileChooser accessory that can be used to customize the input format.booleanisDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.voidread(java.io.File file, Drawing drawing)voidread(java.io.File file, Drawing drawing, boolean replace)voidread(java.io.InputStream in, Drawing drawing, boolean replace)This is the main reading method.voidread(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace)Reads figures from the specified Transferable and adds them to the specified drawing.voidread(java.net.URI uri, Drawing drawing)Reads figures from an URI and replaces the children of the drawing with them.voidread(java.net.URI uri, Drawing drawing, boolean replace)Reads figures from an URI and adds them to the specified drawing.voidread(java.net.URL url, Drawing drawing, boolean replace)static java.lang.String[]toCommaSeparatedArray(java.lang.String str)Returns a value as a String array.static java.lang.String[]toQuotedAndCommaSeparatedArray(java.lang.String str)Returns a value as a String array.static java.awt.geom.AffineTransformtoTransform(IXMLElement elem, java.lang.String str)static java.lang.String[]toWSOrCommaSeparatedArray(java.lang.String str)Returns a value as a String array.
-
-
-
Constructor Detail
-
SVGInputFormat
public SVGInputFormat()
Creates a new instance.
-
SVGInputFormat
public SVGInputFormat(SVGFigureFactory factory)
-
-
Method Detail
-
read
public void read(java.net.URI uri, Drawing drawing) throws java.io.IOExceptionDescription copied from interface:InputFormatReads figures from an URI and replaces the children of the drawing with them.This is a convenience method for calling read(URI,Drawing,true).
- Specified by:
readin interfaceInputFormat- Parameters:
uri- The URI.drawing- The drawing.- Throws:
java.io.IOException
-
read
public void read(java.net.URI uri, Drawing drawing, boolean replace) throws java.io.IOExceptionDescription copied from interface:InputFormatReads figures from an URI and adds them to the specified drawing.- Specified by:
readin interfaceInputFormat- Parameters:
uri- The URI.drawing- The drawing.replace- Set this to true, if the contents of the file replaces the contents of the drawing (for example, when loading a drawing from a file). Set this to false, to add the contents of the file to the drawing (for example, when the file has been dropped into the drawing view).- Throws:
java.io.IOException
-
read
public void read(java.io.File file, Drawing drawing) throws java.io.IOException- Throws:
java.io.IOException
-
read
public void read(java.io.File file, Drawing drawing, boolean replace) throws java.io.IOException- Throws:
java.io.IOException
-
read
public void read(java.net.URL url, Drawing drawing, boolean replace) throws java.io.IOException- Throws:
java.io.IOException
-
read
public void read(java.io.InputStream in, Drawing drawing, boolean replace) throws java.io.IOExceptionThis is the main reading method.- Specified by:
readin interfaceInputFormat- Parameters:
in- The input stream.drawing- The drawing to which this method adds figures.replace- Whether attributes on the drawing object should by changed by this method. Set this to false, when reading individual images from the clipboard.- Throws:
java.io.IOException
-
toCommaSeparatedArray
public static java.lang.String[] toCommaSeparatedArray(java.lang.String str) throws java.io.IOExceptionReturns 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.IOExceptionReturns a value as a String array. The values are separated by whitespace or by commas with optional white space.- Throws:
java.io.IOException
-
toQuotedAndCommaSeparatedArray
public static java.lang.String[] toQuotedAndCommaSeparatedArray(java.lang.String str) throws java.io.IOExceptionReturns a value as a String array. The values are separated by commas with optional quotes and white space.- Throws:
java.io.IOException
-
toTransform
public static java.awt.geom.AffineTransform toTransform(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:InputFormatReturn a FileFilter that can be used to identify files which can be read with this input format. Typically, each input format has its own recognizable file naming convention.- Specified by:
getFileFilterin interfaceInputFormat- Returns:
- FileFilter to be used with a javax.swing.JFileChooser
-
getInputFormatAccessory
public javax.swing.JComponent getInputFormatAccessory()
Description copied from interface:InputFormatReturn a JFileChooser accessory that can be used to customize the input format.- Specified by:
getInputFormatAccessoryin interfaceInputFormat- Returns:
- A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.
-
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Description copied from interface:InputFormatReturns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.- Specified by:
isDataFlavorSupportedin interfaceInputFormat- Parameters:
flavor- A DataFlavor.
-
read
public void read(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOExceptionDescription copied from interface:InputFormatReads figures from the specified Transferable and adds them to the specified drawing.- Specified by:
readin interfaceInputFormat- Parameters:
t- The Transferable.drawing- The drawing.replace- Set this to true, if the contents of the transferable replaces the contents of the drawing (for example, when loading a drawing from a transferable). Set this to false, to add the contents of the transferable to the drawing (for example, when the transferable has been dropped or pasted into the drawing view).- Throws:
java.awt.datatransfer.UnsupportedFlavorExceptionjava.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG