Class BitmapExportOutputFormat

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 Details

  • Constructor Details

    • BitmapExportOutputFormat

      public BitmapExportOutputFormat()
  • Method Details

    • getExtension

      protected @NonNull String getExtension()
      Specified by:
      getExtension in class AbstractExportOutputFormat
    • isResolutionIndependent

      protected boolean isResolutionIndependent()
      Specified by:
      isResolutionIndependent in class AbstractExportOutputFormat
    • write

      public void write(@NonNull Map<javafx.scene.input.DataFormat,Object> out, @NonNull Drawing drawing, @NonNull Collection<Figure> selection) throws IOException
      Description copied from interface: ClipboardOutputFormat
      Writes a selection of figures from a Drawing into a clipboard
      Specified by:
      write in interface ClipboardOutputFormat
      Parameters:
      out - The clipboard
      drawing - 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: OutputFormat
      Writes a Drawing into an output stream.
      Specified by:
      write in interface OutputFormat
      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 absolute
      drawing - 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: OutputFormat
      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
      workState - 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: AbstractExportOutputFormat
      Writes a page.
      Specified by:
      writePage in class AbstractExportOutputFormat
      Parameters:
      file - the output file or null
      page - the page figure
      node - the node of the drawing
      pageCount - the page count
      pageNumber - the page number
      internalPageNumber - 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: AbstractExportOutputFormat
      Writes the node to the specified file as a Slice. May destroy the state of the node in the process!
      Specified by:
      writeSlice in class AbstractExportOutputFormat
      Parameters:
      file - a file
      slice - the Slice
      node - a node
      dpi - 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 JavaFX Image object and stores a copy of its pixels into a BufferedImage object, creating a new object if needed. The method will only convert a JavaFX Image that is readable as per the conditions on the Image.getPixelReader() method. If the Image is not readable, as determined by its getPixelReader() method, then this method will return null. If the Image is a writable, or other dynamic image, then the BufferedImage will only be set to the current state of the pixels in the image as determined by its PixelReader. Further changes to the pixels of the Image will not be reflected in the returned BufferedImage.

      The optional BufferedImage parameter may be reused to store the copy of the pixels. A new BufferedImage will 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 JavaFX Image to be converted
      bimg - an optional BufferedImage object that may be used to store the returned pixel data
      Returns:
      a BufferedImage containing a snapshot of the JavaFX Image, or null if the Image is not readable.