|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jhotdraw.draw.ImageInputFormat
public class ImageInputFormat
An input format for importing drawings using one of the image formats supported by javax.imageio.
This class uses the prototype design pattern. A ImageHolderFigure figure is used as a prototype for creating a figure that holds the imported image.
If the drawing is replaced using the loaded image, the size of the
drawing is set to match the size of the image using the attributes
AttributeKeys.CANVAS_WIDTH and AttributeKeys.CANVAS_HEIGHT.
| Field Summary | |
|---|---|
private java.lang.String |
description
Format description used for the file filter. |
private java.lang.String |
fileExtension
File name extension used for the file filter. |
private java.lang.String |
formatName
Image IO image format name. |
private int |
imageType
The image type must match the output format, for example, PNG supports BufferedImage.TYPE_INT_ARGB whereas GIF needs BufferedImage.TYPE_ |
private ImageHolderFigure |
prototype
The prototype for creating a figure that holds the imported image. |
| Constructor Summary | |
|---|---|
ImageInputFormat(ImageHolderFigure prototype)
Creates a new image output format for Portable Network Graphics PNG. |
|
ImageInputFormat(ImageHolderFigure prototype,
java.lang.String formatName,
java.lang.String description,
java.lang.String fileExtension,
int bufferedImageType)
Creates a new image output format for the specified image format. |
|
| 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 read with this input 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 replaces the children of the drawing with them. |
void |
read(java.io.File file,
Drawing drawing,
boolean replace)
Reads figures from a file and adds them to the specified drawing. |
void |
read(java.io.InputStream in,
Drawing drawing,
boolean replace)
Reads figures from a file and adds them to the specified drawing. |
void |
read(java.awt.datatransfer.Transferable t,
Drawing drawing,
boolean replace)
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 |
|---|
private ImageHolderFigure prototype
private java.lang.String description
private java.lang.String fileExtension
private java.lang.String formatName
private int imageType
| Constructor Detail |
|---|
public ImageInputFormat(ImageHolderFigure prototype)
public ImageInputFormat(ImageHolderFigure prototype,
java.lang.String formatName,
java.lang.String description,
java.lang.String fileExtension,
int bufferedImageType)
formatName - The format name for the javax.imageio.ImageIO object.description - The format description to be used for the file filter.fileExtension - The file extension to be used for file filter.bufferedImageType - The BufferedImage type used to produce the image.
The value of this parameter must match with the format name.| Method Detail |
|---|
public javax.swing.filechooser.FileFilter getFileFilter()
InputFormat
getFileFilter in interface InputFormatpublic java.lang.String getFileExtension()
public javax.swing.JComponent getInputFormatAccessory()
InputFormat
getInputFormatAccessory in interface InputFormat
public void read(java.io.File file,
Drawing drawing,
boolean replace)
throws java.io.IOException
InputFormat
read in interface InputFormatfile - The file.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).
java.io.IOException
public void read(java.io.File file,
Drawing drawing)
throws java.io.IOException
InputFormatThis is a convenience method for calling read(File,Drawing,true).
read in interface InputFormatfile - The file.drawing - The drawing.
java.io.IOException
public void read(java.io.InputStream in,
Drawing drawing,
boolean replace)
throws java.io.IOException
InputFormat
read in interface InputFormatin - The input stream.drawing - The drawing.replace - Set this to true, if the contents of the stream replaces the
contents of the drawing (for example, when loading a drawing from a stream).
Set this to false, to add the contents of the file to the drawing (for
example, when the stream has been dropped into the drawing view).
java.io.IOException
public ImageHolderFigure createImageHolder(java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionpublic boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
InputFormat
isDataFlavorSupported in interface InputFormatflavor - A DataFlavor.
public void read(java.awt.datatransfer.Transferable t,
Drawing drawing,
boolean replace)
throws java.awt.datatransfer.UnsupportedFlavorException,
java.io.IOException
InputFormat
read in interface InputFormatt - 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).
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||