JHotDraw 7.0.9

org.jhotdraw.draw
Interface InputFormat

All Known Implementing Classes:
DOMStorableInputOutputFormat, ImageInputFormat, ODGInputFormat, SVGInputFormat, SVGZInputFormat, TextInputFormat

public interface InputFormat

Interface to define an input format for a Drawing. An InputFormat is a strategy that knows how to restore a Drawing according to a specific encoding. Typically it can be recognized by a Mime type or by a file extension. To identify a valid file format for a Drawing an appropriate FileFilter for a javax.swing.JFileChooser component can be requested.

This interface intentionally contains many identical operations like OutputFormat to make it easy, to write classes that implement both interfaces.

Version:
1.0 December 12, 2006 Created.
Author:
Werner Randelshofer

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.List<Figure> readFigures(java.awt.datatransfer.Transferable t)
          Reads figures from the specified Transferable.
 

Method Detail

getFileFilter

javax.swing.filechooser.FileFilter getFileFilter()
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.

Returns:
FileFilter to be used with a javax.swing.JFileChooser

getInputFormatAccessory

javax.swing.JComponent getInputFormatAccessory()
Return a JFileChooser accessory that can be used to customize the input format.

Returns:
A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.

read

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

Parameters:
file - The file.
drawing - The drawing.
Throws:
java.io.IOException

read

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

Parameters:
in - The input stream.
drawing - The drawing.
Throws:
java.io.IOException

isDataFlavorSupported

boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.

Parameters:
flavor - A DataFlavor.

readFigures

java.util.List<Figure> readFigures(java.awt.datatransfer.Transferable t)
                                   throws java.awt.datatransfer.UnsupportedFlavorException,
                                          java.io.IOException
Reads figures from the specified Transferable.

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.