Class ImageExporter


  • public class ImageExporter
    extends java.lang.Object
    An image exporter assists in exporting a collection of images to an ExportContainer such as a ZIP archive. It is most commonly used by the Export command to export images of a game component.
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageExporter()
      Creates a new export manager.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean beginExport​(java.lang.String baseSheetName, java.lang.String comments, double defaultDPI, boolean largeFormat, boolean allowJoining, boolean multipleFaces, boolean hasMarker)
      Begin an export operation.
      boolean beginExport​(java.lang.String baseSheetName, java.lang.String comments, double defaultDPI, PrintDimensions sizeInPoints, boolean allowJoining, boolean multipleFaces, boolean hasMarker)
      Begin an export operation.
      void endExport()
      Completes the export operation, writing a readme file into the export container, closing it, and optionally opening the container depending on application settings.
      void exportImage​(java.lang.String sheetSuffix, java.awt.image.BufferedImage bi)
      Exports an image.
      void exportSheet​(java.lang.String sheetSuffix, Sheet<?> face)
      Exports the next sheet.
      static ImageExporter getSharedInstance()
      Returns a shared export manager.
      double getTargetResolution()
      Returns the target resolution that sheets will be rendered at when exporting.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageExporter

        public ImageExporter()
        Creates a new export manager. An export manager is usually obtained by calling getSharedInstance(). The only time you would need to create an export manager via the constructor is if you need to use more than one simultaneously.
    • Method Detail

      • getSharedInstance

        public static ImageExporter getSharedInstance()
        Returns a shared export manager. Note that if you do not retain a reference to the returned instance, it may be garbage collected at any time. (Assign the returned value to a variable and leave it unmodified for the duration of the export session.)
        Returns:
        returns a shared export manager
      • beginExport

        public boolean beginExport​(java.lang.String baseSheetName,
                                   java.lang.String comments,
                                   double defaultDPI,
                                   boolean largeFormat,
                                   boolean allowJoining,
                                   boolean multipleFaces,
                                   boolean hasMarker)
                            throws java.io.IOException
        Begin an export operation. The user will be presented with an opportunity to set options and choose a destination ExportContainer. The basename will be used to form a suggested file name and as a base name for constructing the names of the exported files. If this method returns false, the user has cancelled the operation or an error occurred.
        Parameters:
        baseSheetName - a base name for the exported files
        comments - notes that may optionally be included in the export
        defaultDPI - suggested default resolution
        largeFormat - a hint that the images are large and a lower resolution may be appropriate
        allowJoining - a hint that an option to join the images should be enabled
        multipleFaces - a hint that the export will consist of a card with multiple faces
        hasMarker - a hint that the final sheet is a marker
        Returns:
        false if the export was cancelled
        Throws:
        java.io.IOException - if an I/O error occurs
      • beginExport

        public boolean beginExport​(java.lang.String baseSheetName,
                                   java.lang.String comments,
                                   double defaultDPI,
                                   PrintDimensions sizeInPoints,
                                   boolean allowJoining,
                                   boolean multipleFaces,
                                   boolean hasMarker)
                            throws java.io.IOException
        Begin an export operation. The user will be presented with an opportunity to set options and choose a destination ExportContainer. The basename will be used to form a suggested file name and as a base name for constructing the names of the exported files. If this method returns false, the user has cancelled the operation or an error occurred.
        Parameters:
        baseSheetName - a base name for the exported files
        comments - notes that may optionally be included in the export
        defaultDPI - suggested default resolution
        sizeInPoints - the dimensions of the content to be exported, in points
        allowJoining - a hint that an option to join the images should be enabled
        multipleFaces - a hint that the export will consist of a card with multiple faces
        hasMarker - a hint that the final sheet is a marker
        Returns:
        false if the export was cancelled
        Throws:
        java.io.IOException - if an I/O error occurs
      • exportSheet

        public void exportSheet​(java.lang.String sheetSuffix,
                                Sheet<?> face)
                         throws java.io.IOException
        Exports the next sheet.
        Parameters:
        sheetSuffix - the suffix to append to the base sheet name for this sheet
        face - the sheet to export
        Throws:
        java.io.IOException - if an I/O error occurs
      • exportImage

        public void exportImage​(java.lang.String sheetSuffix,
                                java.awt.image.BufferedImage bi)
                         throws java.io.IOException
        Exports an image. The resolution is assumed to be getTargetResolution().
        Parameters:
        sheetSuffix - the suffix to append to the base sheet name for this sheet
        bi - the image to export
        Throws:
        java.io.IOException - if an I/O error occurs
      • getTargetResolution

        public double getTargetResolution()
        Returns the target resolution that sheets will be rendered at when exporting.
        Returns:
        the target resolution in pixels per inch
      • endExport

        public void endExport()
                       throws java.io.IOException
        Completes the export operation, writing a readme file into the export container, closing it, and optionally opening the container depending on application settings.
        Throws:
        java.io.IOException - if an I/O error occurs while closing the container