java.lang.Object
org.jhotdraw8.draw.io.AbstractExportOutputFormat
org.jhotdraw8.draw.io.BitmapExportOutputFormat
- All Implemented Interfaces:
ClipboardOutputFormat,ExportOutputFormat,OutputFormat
public class BitmapExportOutputFormat
extends AbstractExportOutputFormat
implements ClipboardOutputFormat, OutputFormat
BitmapExportOutputFormat.
- Author:
- Werner Randelshofer
-
Field Summary
FieldsFields inherited from interface org.jhotdraw8.draw.io.ExportOutputFormat
EXPORT_DRAWING_DPI_KEY, EXPORT_DRAWING_KEY, EXPORT_PAGES_DPI_KEY, EXPORT_PAGES_KEY, EXPORT_SLICES_DPI_KEY, EXPORT_SLICES_KEY, EXPORT_SLICES_RESOLUTION_2X_KEY, EXPORT_SLICES_RESOLUTION_3X_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable BufferedImagefromFXImage(@NonNull javafx.scene.image.Image img, @Nullable BufferedImage bimg) Snapshots the specified JavaFXImageobject and stores a copy of its pixels into aBufferedImageobject, creating a new object if needed.protected booleanvoidwrite(@NonNull OutputStream out, @Nullable URI documentHome, @NonNull Drawing drawing, @NonNull WorkState<Void> workState) Writes a Drawing into an output stream.voidWrites the drawing to the specified file.voidwrite(@NonNull Map<javafx.scene.input.DataFormat, Object> out, @NonNull Drawing drawing, @NonNull Collection<Figure> selection) Writes a selection of figures from a Drawing into a clipboardprotected voidwritePage(@NonNull Path file, @NonNull Page page, @NonNull javafx.scene.Node node, int pageCount, int pageNumber, int internalPageNumber) Writes a page.protected booleanWrites the node to the specified file as a Slice.Methods inherited from class org.jhotdraw8.draw.io.AbstractExportOutputFormat
getOptions, isExportDrawing, isExportPages, isExportSlices, isExportSlices2x, isExportSlices3x, setOptions, writePages, writePages, writeSlicesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.draw.input.ClipboardOutputFormat
writeMethods inherited from interface org.jhotdraw8.draw.io.OutputFormat
getOptions, setOptions, write
-
Field Details
-
JPEG_MIME_TYPE
- See Also:
-
PNG_MIME_TYPE
- See Also:
-
-
Constructor Details
-
BitmapExportOutputFormat
public BitmapExportOutputFormat()
-
-
Method Details
-
getExtension
- Specified by:
getExtensionin classAbstractExportOutputFormat
-
isResolutionIndependent
protected boolean isResolutionIndependent()- Specified by:
isResolutionIndependentin classAbstractExportOutputFormat
-
write
public void write(@NonNull Map<javafx.scene.input.DataFormat, Object> out, @NonNull Drawing drawing, @NonNull Collection<Figure> selection) throws IOExceptionDescription copied from interface:ClipboardOutputFormatWrites a selection of figures from a Drawing into a clipboard- Specified by:
writein interfaceClipboardOutputFormat- Parameters:
out- The clipboarddrawing- The drawing.selection- A selection- Throws:
IOException- if an IO error occurs
-
write
public void write(@NonNull OutputStream out, @Nullable URI documentHome, @NonNull Drawing drawing, @NonNull WorkState<Void> workState) throws IOException Description copied from interface:OutputFormatWrites a Drawing into an output stream.- Specified by:
writein interfaceOutputFormat- Parameters:
out- The output stream.documentHome- Document home URI for creating relative URIs in the document if this URI is null, all URIs in the document will be absolutedrawing- The drawing.workState- for progress monitoring and cancelling the operation- Throws:
IOException- if an IO error occurs
-
write
public void write(@NonNull Path file, @NonNull Drawing drawing, @NonNull WorkState<Void> workState) throws IOException Description copied from interface:OutputFormatWrites the drawing to the specified file. This method ensures that all figures of the drawing are visible on the image.- Specified by:
writein interfaceOutputFormat- Parameters:
file- the filedrawing- the drawingworkState- for progress monitoring and cancelling the operation- Throws:
IOException- if an IO error occurs
-
writePage
protected void writePage(@NonNull Path file, @NonNull Page page, @NonNull javafx.scene.Node node, int pageCount, int pageNumber, int internalPageNumber) throws IOException Description copied from class:AbstractExportOutputFormatWrites a page.- Specified by:
writePagein classAbstractExportOutputFormat- Parameters:
file- the output file or nullpage- the page figurenode- the node of the drawingpageCount- the page countpageNumber- the page numberinternalPageNumber- the internal page number of the page figure- Throws:
IOException- if writing fails
-
writeSlice
protected boolean writeSlice(@NonNull Path file, @NonNull Slice slice, @NonNull javafx.scene.Node node, double dpi) throws IOException Description copied from class:AbstractExportOutputFormatWrites the node to the specified file as a Slice. May destroy the state of the node in the process!- Specified by:
writeSlicein classAbstractExportOutputFormat- Parameters:
file- a fileslice- the Slicenode- a nodedpi- dots per inch- Returns:
- returns true if the state of the node was destroyed
- Throws:
IOException- in case of failure
-
fromFXImage
public static @Nullable BufferedImage fromFXImage(@NonNull javafx.scene.image.Image img, @Nullable BufferedImage bimg) Snapshots the specified JavaFXImageobject and stores a copy of its pixels into aBufferedImageobject, creating a new object if needed. The method will only convert a JavaFXImagethat is readable as per the conditions on theImage.getPixelReader()method. If theImageis not readable, as determined by itsgetPixelReader()method, then this method will return null. If theImageis a writable, or other dynamic image, then theBufferedImagewill only be set to the current state of the pixels in the image as determined by itsPixelReader. Further changes to the pixels of theImagewill not be reflected in the returnedBufferedImage.The optional
BufferedImageparameter may be reused to store the copy of the pixels. A newBufferedImagewill be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.- Parameters:
img- the JavaFXImageto be convertedbimg- an optionalBufferedImageobject that may be used to store the returned pixel data- Returns:
- a
BufferedImagecontaining a snapshot of the JavaFXImage, or null if theImageis not readable.
-