From 9770f7a914079cf2b1f05c90fb6c4d373e22b444 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Sun, 21 Jul 2019 18:28:26 +0100 Subject: [PATCH] JAL-3364 tidy and i18n makeAlignmentImage --- resources/lang/Messages.properties | 3 +++ src/jalview/gui/AlignmentPanel.java | 43 +++++++++++++++++++---------------- src/jalview/gui/AppJmol.java | 29 +++++++---------------- src/jalview/gui/PCAPanel.java | 26 ++++++--------------- 4 files changed, 41 insertions(+), 60 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 8abb156..ca3cd0e 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1234,6 +1234,9 @@ label.sifts_mapping = SIFTs Mapping label.mapping_method = Sequence \u27f7 Structure mapping method status.waiting_for_user_to_select_output_file = Waiting for user to select {0} file status.cancelled_image_export_operation = Cancelled {0} export operation +label.make_alignment_image = Create {0} image from alignment +label.make_pca_image = Make {0} image from PCA +label.make_pdb_image = Make {0} image from view info.error_creating_file = Error creating {0} file exception.outofmemory_loading_mmcif_file = Out of memory loading mmCIF File label.run_groovy = Run Groovy console script diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 4ec71c5..d387540 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -20,6 +20,10 @@ */ package jalview.gui; +import static jalview.util.ImageMaker.TYPE.EPS; +import static jalview.util.ImageMaker.TYPE.PNG; +import static jalview.util.ImageMaker.TYPE.SVG; + import jalview.analysis.AnnotationSorter; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; @@ -1030,6 +1034,11 @@ public class AlignmentPanel extends GAlignmentPanel implements alignmentDrawnHeight); getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av, alignmentGraphics, -1, startRes, endRes + 1); + + /* + * reset to left margin + */ + alignmentGraphics.translate(-alignmentGraphicsOffset, 0); } return Printable.PAGE_EXISTS; @@ -1195,24 +1204,11 @@ public class AlignmentPanel extends GAlignmentPanel implements + borderBottomOffset; final int graphicsWidth = Math.max(dim1.width, dim2.width); - final String imageAction, imageTitle; - if (type == ImageMaker.TYPE.PNG) - { - imageAction = "Create PNG image from alignment"; - imageTitle = null; - } - else if (type == ImageMaker.TYPE.EPS) - { - imageAction = "Create EPS file from alignment"; - imageTitle = alignFrame.getTitle(); - } - else - { - imageAction = "Create SVG file from alignment"; - imageTitle = alignFrame.getTitle(); - } + final String dialogTitle = MessageManager + .formatMessage("label.make_alignment_image", type.getName()); + String imageTitle = type == PNG ? null : alignFrame.getTitle(); - ImageMaker im = new ImageMaker(this, type, imageAction, + ImageMaker im = new ImageMaker(this, type, dialogTitle, graphicsWidth, graphicsHeight, file, imageTitle, alignFrame, pSessionId, headless); Graphics graphics = im.getGraphics(); @@ -1238,6 +1234,13 @@ public class AlignmentPanel extends GAlignmentPanel implements * append coding complement image */ graphics.translate(0, dim1.height); + boolean test = true; + if (test) + { + graphics.setColor(Color.red); + graphics.drawString("Hello world", 0, 0); + graphics.setColor(Color.black); + } if (av.getCodingComplement().getWrapAlignment()) { comp.printWrappedAlignment(dim2.width, @@ -1322,7 +1325,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void makeEPS(File epsFile, boolean forSplitFrame) { - makeAlignmentImage(ImageMaker.TYPE.EPS, epsFile, forSplitFrame); + makeAlignmentImage(EPS, epsFile, forSplitFrame); } /** @@ -1334,7 +1337,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void makePNG(File pngFile, boolean forSplitFrame) { - makeAlignmentImage(ImageMaker.TYPE.PNG, pngFile, forSplitFrame); + makeAlignmentImage(PNG, pngFile, forSplitFrame); } /** @@ -1346,7 +1349,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void makeSVG(File svgFile, boolean forSplitFrame) { - makeAlignmentImage(ImageMaker.TYPE.SVG, svgFile, forSplitFrame); + makeAlignmentImage(SVG, svgFile, forSplitFrame); } public void makePNGImageMap(File imgMapFile, String imageName) diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index ea7fb6b..d8564c5 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -20,6 +20,8 @@ */ package jalview.gui; +import static jalview.util.ImageMaker.TYPE.PNG; + import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.PDBEntry; @@ -27,6 +29,7 @@ import jalview.datamodel.SequenceI; import jalview.gui.StructureViewer.ViewerType; import jalview.structures.models.AAStructureBindingModel; import jalview.util.BrowserLauncher; +import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.ws.dbsources.Pdb; @@ -566,27 +569,11 @@ public class AppJmol extends StructureViewerBase int width = getWidth(); int height = getHeight(); - jalview.util.ImageMaker im; - - if (type == jalview.util.ImageMaker.TYPE.PNG) - { - im = new jalview.util.ImageMaker(this, - jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view", - width, height, null, null, null, 0, false); - } - else if (type == jalview.util.ImageMaker.TYPE.EPS) - { - im = new jalview.util.ImageMaker(this, - jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view", - width, height, null, this.getTitle(), null, 0, false); - } - else - { - - im = new jalview.util.ImageMaker(this, - jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA", - width, height, null, this.getTitle(), null, 0, false); - } + String dialogTitle = MessageManager + .formatMessage("label.make_pdb_image", type.getName()); + String imageTitle = type == PNG ? null : this.getTitle(); + ImageMaker im = new ImageMaker(this, type, dialogTitle, width, height, + null, imageTitle, null, 0, false); if (im.getGraphics() != null) { diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 4f660a2..a833f98 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -20,6 +20,8 @@ */ package jalview.gui; +import static jalview.util.ImageMaker.TYPE.PNG; + import jalview.analysis.scoremodels.ScoreModels; import jalview.api.AlignViewportI; import jalview.api.analysis.ScoreModelI; @@ -431,25 +433,11 @@ public class PCAPanel extends GPCAPanel int width = getRotatableCanvas().getWidth(); int height = getRotatableCanvas().getHeight(); - ImageMaker im; - - switch (type) - { - case PNG: - im = new ImageMaker(this, ImageMaker.TYPE.PNG, - "Make PNG image from PCA", width, height, null, null, null, 0, - false); - break; - case EPS: - im = new ImageMaker(this, ImageMaker.TYPE.EPS, - "Make EPS file from PCA", width, height, null, - this.getTitle(), null, 0, false); - break; - default: - im = new ImageMaker(this, ImageMaker.TYPE.SVG, - "Make SVG file from PCA", width, height, null, - this.getTitle(), null, 0, false); - } + String dialogTitle = MessageManager + .formatMessage("label.make_pca_image", type.getName()); + String imageTitle = type == PNG ? null : this.getTitle(); + ImageMaker im = new ImageMaker(this, type, dialogTitle, width, height, + null, imageTitle, null, 0, false); if (im.getGraphics() != null) { -- 1.7.10.2