org.jhotdraw.draw.io
Class ImageOutputFormat
- java.lang.Object
-
- 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.
-
-
Constructor Summary
Constructors Constructor and Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.awt.datatransfer.TransferablecreateTransferable(Drawing drawing, java.util.List<Figure> figures, double scaleFactor)Writes the drawing to the specified output stream.java.lang.StringgetFileExtension()Returns the file extension for the output format.javax.swing.filechooser.FileFiltergetFileFilter()Return a FileFilter that can be used to identify files which can be stored with this output format.javax.swing.JComponentgetOutputFormatAccessory()Return a JFileChooser accessory that can be used to customize the output format.java.awt.image.BufferedImagetoImage(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.BufferedImagetoImage(Drawing drawing, java.util.List<Figure> figures, double scaleFactor, boolean clipToFigures)Creates a BufferedImage from the specified list of figures.voidwrite(java.io.File file, Drawing drawing)Writes the drawing to the specified file.voidwrite(java.io.OutputStream out, Drawing drawing)Writes the drawing to the specified output stream.voidwrite(java.io.OutputStream out, Drawing drawing, java.awt.geom.AffineTransform drawingTransform, java.awt.Dimension imageSize)Writes the drawing to the specified output stream.voidwrite(java.io.OutputStream out, Drawing drawing, java.util.List<Figure> figures)Writes the figures to the specified output stream.voidwrite(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.voidwrite(java.net.URI uri, Drawing drawing)Writes a Drawing into an URI.
-
-
-
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:OutputFormatReturn 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:
getFileFilterin interfaceOutputFormat- Returns:
- FileFilter to be used with a javax.swing.JFileChooser
-
getFileExtension
public java.lang.String getFileExtension()
Description copied from interface:OutputFormatReturns 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:
getFileExtensionin interfaceOutputFormat
-
getOutputFormatAccessory
public javax.swing.JComponent getOutputFormatAccessory()
Description copied from interface:OutputFormatReturn a JFileChooser accessory that can be used to customize the output format.- Specified by:
getOutputFormatAccessoryin interfaceOutputFormat- 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.net.URI uri, Drawing drawing) throws java.io.IOExceptionDescription copied from interface:OutputFormatWrites a Drawing into an URI.- Specified by:
writein interfaceOutputFormat- Parameters:
uri- The uri.drawing- The drawing.- Throws:
java.io.IOException
-
write
public void write(java.io.File file, Drawing drawing) throws java.io.IOExceptionWrites the drawing to the specified file. 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) throws java.io.IOExceptionWrites the drawing to the specified output stream. This method ensures that all figures of the drawing are visible on the image.- Specified by:
writein interfaceOutputFormat- 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.IOExceptionWrites 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:
createTransferablein interfaceOutputFormat- 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.IOExceptionWrites 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, @Nullable java.awt.geom.AffineTransform drawingTransform, @Nullable java.awt.Dimension imageSize) throws java.io.IOExceptionWrites 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.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG