JHotDraw 7.4.1

org.jhotdraw.draw.io
Class ImageOutputFormat

java.lang.Object
  extended by org.jhotdraw.draw.io.ImageOutputFormat
All Implemented Interfaces:
OutputFormat

public class ImageOutputFormat
extends java.lang.Object
implements OutputFormat

An output format for exporting drawings using one of the image formats supported by javax.imageio.

Version:
$Id: ImageOutputFormat.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer

Constructor Summary
ImageOutputFormat()
          Creates a new image output format for Portable Network Graphics PNG.
ImageOutputFormat(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
 java.awt.datatransfer.Transferable createTransferable(Drawing drawing, java.util.List<Figure> figures, double scaleFactor)
          Writes the drawing to the specified output stream.
 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.
protected  void setRenderingHints(java.awt.Graphics2D g)
           
 java.awt.image.BufferedImage toImage(Drawing drawing, java.util.List<Figure> figures, java.awt.geom.AffineTransform transform, java.awt.Dimension imageSize)
          Creates a BufferedImage from the specified list of figures.
 java.awt.image.BufferedImage toImage(Drawing drawing, java.util.List<Figure> figures, double scaleFactor, boolean clipToFigures)
          Creates a BufferedImage from the specified list of figures.
 void write(java.io.File file, Drawing drawing)
          Writes the drawing to the specified file.
 void write(java.io.OutputStream out, Drawing drawing)
          Writes the drawing to the specified output stream.
 void write(java.io.OutputStream out, Drawing drawing, java.awt.geom.AffineTransform drawingTransform, java.awt.Dimension imageSize)
          Writes the drawing to the specified output stream.
 void write(java.io.OutputStream out, Drawing drawing, java.util.List<Figure> figures)
          Writes the figures to the specified output stream.
 void write(java.io.OutputStream out, Drawing drawing, java.util.List<Figure> figures, java.awt.geom.AffineTransform drawingTransform, java.awt.Dimension imageSize)
          Writes the figures to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageOutputFormat

public ImageOutputFormat()
Creates a new image output format for Portable Network Graphics PNG.


ImageOutputFormat

public ImageOutputFormat(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.

Parameters:
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

getFileFilter

public javax.swing.filechooser.FileFilter getFileFilter()
Description copied from interface: OutputFormat
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.

Specified by:
getFileFilter in interface OutputFormat
Returns:
FileFilter to be used with a javax.swing.JFileChooser

getFileExtension

public java.lang.String getFileExtension()
Description copied from interface: OutputFormat
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.

Specified by:
getFileExtension in interface OutputFormat

getOutputFormatAccessory

public javax.swing.JComponent getOutputFormatAccessory()
Description copied from interface: OutputFormat
Return a JFileChooser accessory that can be used to customize the output format.

Specified by:
getOutputFormatAccessory in interface OutputFormat
Returns:
A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.

write

public void write(java.io.File file,
                  Drawing drawing)
           throws java.io.IOException
Writes the drawing to the specified file. This method ensures that all figures of the drawing are visible on the image.

Specified by:
write in interface OutputFormat
Parameters:
file - The file.
drawing - The drawing.
Throws:
java.io.IOException

write

public void write(java.io.OutputStream out,
                  Drawing drawing)
           throws java.io.IOException
Writes the drawing to the specified output stream. This method ensures that all figures of the drawing are visible on the image.

Specified by:
write in interface OutputFormat
Parameters:
out - The output stream.
drawing - The drawing.
Throws:
java.io.IOException

write

public void write(java.io.OutputStream out,
                  Drawing drawing,
                  java.awt.geom.AffineTransform drawingTransform,
                  java.awt.Dimension imageSize)
           throws java.io.IOException
Writes the drawing to the specified output stream. This method applies the specified transform to the drawing, and draws it on an image of the specified size.

Throws:
java.io.IOException

createTransferable

public java.awt.datatransfer.Transferable createTransferable(Drawing drawing,
                                                             java.util.List<Figure> figures,
                                                             double scaleFactor)
                                                      throws java.io.IOException
Writes the drawing to the specified output stream. This method ensures that all figures of the drawing are visible on the image.

Specified by:
createTransferable in interface OutputFormat
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

write

public void write(java.io.OutputStream out,
                  Drawing drawing,
                  java.util.List<Figure> figures)
           throws java.io.IOException
Writes the figures to the specified output stream. This method ensures that all figures of the drawing are visible on the image.

Throws:
java.io.IOException

write

public void write(java.io.OutputStream out,
                  Drawing drawing,
                  java.util.List<Figure> figures,
                  java.awt.geom.AffineTransform drawingTransform,
                  java.awt.Dimension imageSize)
           throws java.io.IOException
Writes the figures to the specified output stream. This method applies the specified transform to the drawing, and draws it on an image of the specified size.

Throws:
java.io.IOException

toImage

public java.awt.image.BufferedImage toImage(Drawing drawing,
                                            java.util.List<Figure> figures,
                                            double scaleFactor,
                                            boolean clipToFigures)
Creates a BufferedImage from the specified list of figures.

The images are drawn using the specified scale factor. If some figures have a drawing area located at negative coordinates, then the drawing coordinates are translated, so that all figures are visible on the image.

Parameters:
drawing - The drawing.
figures - A list of figures of the drawing.
scaleFactor - The scale factor used when drawing the figures.
clipToFigures - If this is true, the image is clipped to the figures. If this is false, the image includes the drawing area,

toImage

public java.awt.image.BufferedImage toImage(Drawing drawing,
                                            java.util.List<Figure> figures,
                                            java.awt.geom.AffineTransform transform,
                                            java.awt.Dimension imageSize)
Creates a BufferedImage from the specified list of figures.

Parameters:
drawing - The drawing.
figures - A list of figures of the drawing.
transform - The AffineTransform to be used when drawing the figures.
imageSize - The width and height of the image.

setRenderingHints

protected void setRenderingHints(java.awt.Graphics2D g)

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.