JHotDraw 7.1

org.jhotdraw.draw
Class PictImageInputFormat

java.lang.Object
  extended by org.jhotdraw.draw.PictImageInputFormat
All Implemented Interfaces:
InputFormat

public class PictImageInputFormat
extends java.lang.Object
implements InputFormat

An input format for importing drawings using the image/x-pict format from the Mac OS X clipboard.

This class uses the prototype design pattern. A ImageHolderFigure figure is used as a prototype for creating a figure that holds the imported image.

Author:
Werner Randelshofer  @version 1.0 Mar 18, 2008 Created.

Field Summary
static java.awt.datatransfer.DataFlavor PICT_FLAVOR
          The image/x-pict data flavor is used by the Mac OS X clipboard.
 
Constructor Summary
PictImageInputFormat(ImageHolderFigure prototype)
          Creates a new image output format for Portable Network Graphics PNG.
 
Method Summary
 ImageHolderFigure createImageHolder(java.io.InputStream in)
           
 java.lang.String getFileExtension()
           
 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.
 void read(java.awt.datatransfer.Transferable t, Drawing drawing)
          Reads figures from the specified Transferable and adds them to the specified drawing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PICT_FLAVOR

public static final java.awt.datatransfer.DataFlavor PICT_FLAVOR
The image/x-pict data flavor is used by the Mac OS X clipboard.

Constructor Detail

PictImageInputFormat

public PictImageInputFormat(ImageHolderFigure prototype)
Creates a new image output format for Portable Network Graphics PNG.

Method Detail

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

getFileExtension

public java.lang.String getFileExtension()

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

createImageHolder

public ImageHolderFigure createImageHolder(java.io.InputStream in)
                                    throws java.io.IOException
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.

read

public void read(java.awt.datatransfer.Transferable t,
                 Drawing drawing)
          throws java.awt.datatransfer.UnsupportedFlavorException,
                 java.io.IOException
Description copied from interface: InputFormat
Reads figures from the specified Transferable and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
t - The Transferable.
drawing - The drawing.
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

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