X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FImageMaker.java;h=95322309859c7e4b326e3529dd1f73748df788f4;hb=37de9310bec3501cbc6381e0c3dcb282fcaad812;hp=72fa605acb6170e9349e8950e5dc032b73c9281f;hpb=ee409dd34f8aff73c4b2b7d425e1154add8e2142;p=jalview.git diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java index 72fa605..9532230 100755 --- a/src/jalview/util/ImageMaker.java +++ b/src/jalview/util/ImageMaker.java @@ -54,11 +54,17 @@ public class ImageMaker TYPE type; + private IProgressIndicator pIndicator; + + private long pSessionId; + + private boolean headless; + public enum TYPE { - EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()), PNG( - "PNG", MessageManager.getString("label.png_image"), - getPNGChooser()), SVG("SVG", "SVG", getSVGChooser()); + EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()), + PNG("PNG", MessageManager.getString("label.png_image"), getPNGChooser()), + SVG("SVG", "SVG", getSVGChooser()); private JalviewFileChooser chooser; @@ -94,17 +100,14 @@ public class ImageMaker int height, File file, String fileTitle, IProgressIndicator pIndicator, long pSessionId, boolean headless) { + this.pIndicator = pIndicator; this.type = type; - + this.pSessionId = pSessionId; + this.headless = headless; if (file == null) { - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar( - MessageManager.formatMessage( - "status.waiting_for_user_to_select_output_file", - type.name), pSessionId); - } + setProgressMessage(MessageManager.formatMessage( + "status.waiting_for_user_to_select_output_file", type.name)); JalviewFileChooser chooser; chooser = type.getChooser(); chooser.setFileView(new jalview.io.JalviewFileView()); @@ -120,12 +123,8 @@ public class ImageMaker } else { - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar(MessageManager.formatMessage( - "status.cancelled_image_export_operation", type.name), - pSessionId); - } + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", type.name)); } } @@ -134,6 +133,9 @@ public class ImageMaker try { out = new FileOutputStream(file); + setProgressMessage(null); + setProgressMessage(MessageManager.formatMessage( + "status.exporting_alignment_as_x_file", type.getName())); if (type == TYPE.SVG) { setupSVG(width, height, fileTitle); @@ -146,19 +148,13 @@ public class ImageMaker { setupPNG(width, height); } - if (pIndicator != null && !headless) - { - pIndicator.setProgressBar( -MessageManager.formatMessage( - "status.export_complete", type.getName()), - pSessionId); - } + } catch (Exception ex) { System.out.println("Error creating " + type.getName() + " file."); - pIndicator.setProgressBar(MessageManager.formatMessage( - "info.error_creating_file", type.getName()), pSessionId); + setProgressMessage(MessageManager.formatMessage( + "info.error_creating_file", type.getName())); } } } @@ -214,6 +210,8 @@ MessageManager.formatMessage( if (renderStyle == null || eps.cancelled) { + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", "EPS")); return; } } @@ -233,6 +231,8 @@ MessageManager.formatMessage( pg.setAccurateTextMode(accurateText); graphics = pg; + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); } catch (Exception ex) { } @@ -245,6 +245,8 @@ MessageManager.formatMessage( Graphics2D ig2 = (Graphics2D) graphics; ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); } @@ -268,6 +270,8 @@ MessageManager.formatMessage( if (renderStyle == null || svgOption.cancelled) { + setProgressMessage(MessageManager.formatMessage( + "status.cancelled_image_export_operation", "SVG")); return; } } @@ -278,6 +282,8 @@ MessageManager.formatMessage( SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR); } + setProgressMessage(MessageManager.formatMessage( + "status.export_complete", type.getName())); graphics = g2; } @@ -307,6 +313,14 @@ MessageManager.formatMessage( "Encapsulated Postscript"); } + private void setProgressMessage(String message) + { + if (pIndicator != null && !headless) + { + pIndicator.setProgressBar(message, pSessionId); + } + } + static JalviewFileChooser getSVGChooser() { if (Jalview.isHeadlessMode())