Package ca.cgjennings.apps.arkham
Class ImageExporter
- java.lang.Object
-
- ca.cgjennings.apps.arkham.ImageExporter
-
public class ImageExporter extends java.lang.Object
An image exporter assists in exporting a collection of images to anExportContainer
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.
-
-
-
Constructor Detail
-
ImageExporter
public ImageExporter()
Creates a new export manager. An export manager is usually obtained by callinggetSharedInstance()
. 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 destinationExportContainer
. Thebasename
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 returnsfalse
, the user has cancelled the operation or an error occurred.- Parameters:
baseSheetName
- a base name for the exported filescomments
- notes that may optionally be included in the exportdefaultDPI
- suggested default resolutionlargeFormat
- a hint that the images are large and a lower resolution may be appropriateallowJoining
- a hint that an option to join the images should be enabledmultipleFaces
- a hint that the export will consist of a card with multiple faceshasMarker
- 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 destinationExportContainer
. Thebasename
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 returnsfalse
, the user has cancelled the operation or an error occurred.- Parameters:
baseSheetName
- a base name for the exported filescomments
- notes that may optionally be included in the exportdefaultDPI
- suggested default resolutionsizeInPoints
- the dimensions of the content to be exported, in pointsallowJoining
- a hint that an option to join the images should be enabledmultipleFaces
- a hint that the export will consist of a card with multiple faceshasMarker
- 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 sheetface
- 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 begetTargetResolution()
.- Parameters:
sheetSuffix
- the suffix to append to the base sheet name for this sheetbi
- 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
-
-