org.jhotdraw.draw
Interface OutputFormat

All Known Implementing Classes:
DOMStorableInputOutputFormat, ImageMapOutputFormat, ImageOutputFormat, SerializationInputOutputFormat, SVGOutputFormat, SVGZOutputFormat

public interface OutputFormat

An output format implements a strategy for writing a Drawing using a specific encoding into an OutputStream, a File or a Transferable.

Typically an encoding can be recognized by a Mime type or by a file extension. To identify the encoding used by a file, an appropriate FileFilter for a javax.swing.JFileChooser component can be requested from OutputFormat.

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


Design Patterns

Strategy
OutputFormat encapsulates a strategy for writing drawings to output streams.
Strategy: OutputFormat; Context: Drawing.


Version:
$Id: OutputFormat.java 527 2009-06-07 14:28:19Z rawcoder $
Author:
Werner Randelshofer

Method Summary
 java.awt.datatransfer.Transferable createTransferable(Drawing drawing, java.util.List<Figure> figures, double scaleFactor)
          Creates a Transferable for the specified list of Figures.
 java.lang.String getFileExtension()
          Returns the file extension for the output format.
 javax.swing.filechooser.FileFilter getFileFilter()
          Return a FileFilter that can be used to identify files which can be stored with this output format.
 javax.swing.JComponent getOutputFormatAccessory()
          Return a JFileChooser accessory that can be used to customize the output format.
 void write(java.io.File file, Drawing drawing)
          Writes a Drawing into a file.
 void write(java.io.OutputStream out, Drawing drawing)
          Writes a Drawing into an output stream.
 

Method Detail

getFileFilter

javax.swing.filechooser.FileFilter getFileFilter()
Return a FileFilter that can be used to identify files which can be stored with this output format. Typically, each output format has its own recognizable file extension.

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

getFileExtension

java.lang.String getFileExtension()
Returns the file extension for the output format. The file extension should be appended to a file name when storing a Drawing with the specified file format.


getOutputFormatAccessory

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

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

write

void write(java.io.File file,
           Drawing drawing)
           throws java.io.IOException
Writes a Drawing into a file.

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

write

void write(java.io.OutputStream out,
           Drawing drawing)
           throws java.io.IOException
Writes a Drawing into an output stream.

Parameters:
out - The output stream.
drawing - The drawing.
Throws:
java.io.IOException

createTransferable

java.awt.datatransfer.Transferable createTransferable(Drawing drawing,
                                                      java.util.List<Figure> figures,
                                                      double scaleFactor)
                                                      throws java.io.IOException
Creates a Transferable for the specified list of Figures.

Parameters:
drawing - The drawing.
figures - A list of figures of the drawing.
scaleFactor - The factor to be used, when the Transferable creates an image with a fixed size from the figures.
Returns:
The Transferable.
Throws:
java.io.IOException