X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=6e46781a360b0ef0a90daa77946d5e983c71a689;hb=fe8a4b9cb2b7242c902259aab79ecc0637c6c370;hp=f5634d247dab6a1cd6f340169d00c14605bf5e28;hpb=4bb7ef2feb729af8a320e9c090e39aee12028375;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index f5634d2..6e46781 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -36,6 +36,7 @@ import jalview.math.AlignmentDimension; import jalview.schemes.ResidueProperties; import jalview.structure.StructureSelectionManager; import jalview.util.Comparison; +import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.ViewportListenerI; @@ -48,7 +49,6 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; -import java.awt.Insets; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.ComponentAdapter; @@ -336,9 +336,9 @@ public class AlignmentPanel extends GAlignmentPanel implements { boolean scrolled = scrollToPosition(results, 0, true, false); - boolean noFastPaint = scrolled && av.getWrapAlignment(); + boolean fastPaint = !(scrolled && av.getWrapAlignment()); - getSeqPanel().seqCanvas.highlightSearchResults(results, noFastPaint); + getSeqPanel().seqCanvas.highlightSearchResults(results, fastPaint); } /** @@ -556,13 +556,10 @@ public class AlignmentPanel extends GAlignmentPanel implements /* * Estimate available height in the AlignFrame for alignment + * annotations. Deduct an estimate for title bar, menu bar, scale panel, - * hscroll, status bar (as these are not laid out we can't inspect their - * actual heights). Insets gives frame borders. + * hscroll, status bar, insets. */ - int stuff = Platform.isAMac() ? 80 : 100; - Insets insets = alignFrame.getInsets(); - int availableHeight = alignFrame.getHeight() - stuff - insets.top - - insets.bottom; + int stuff = Platform.isAMac() ? 120 : 140; + int availableHeight = alignFrame.getHeight() - stuff; /* * If not enough vertical space, maximize annotation height while keeping @@ -1282,9 +1279,16 @@ public class AlignmentPanel extends GAlignmentPanel implements return idwidth.intValue() + 4; } - void makeAlignmentImage(jalview.util.ImageMaker.TYPE type, File file) + /** + * Builds an image of the alignment of the specified type (EPS/PNG/SVG) and + * writes it to the specified file + * + * @param type + * @param file + */ + void makeAlignmentImage(ImageMaker.TYPE type, File file) { - int boarderBottomOffset = 5; + int borderBottomOffset = 5; long pSessionId = System.currentTimeMillis(); headless = (System.getProperty("java.awt.headless") != null && System.getProperty("java.awt.headless").equals("true")); @@ -1300,65 +1304,39 @@ public class AlignmentPanel extends GAlignmentPanel implements try { AlignmentDimension aDimension = getAlignmentDimension(); - try + String imageAction = "Create " + type.getName() + + " image from alignment"; + String imageTitle = alignFrame.getTitle(); + + ImageMaker im = new ImageMaker(this, type, imageAction, + aDimension.getWidth(), + aDimension.getHeight() + borderBottomOffset, file, imageTitle, + alignFrame, pSessionId, headless); + Graphics graphics = im.getGraphics(); + if (graphics != null) { - jalview.util.ImageMaker im; - final String imageAction, imageTitle; - if (type == jalview.util.ImageMaker.TYPE.PNG) - { - imageAction = "Create PNG image from alignment"; - imageTitle = null; - } - else if (type == jalview.util.ImageMaker.TYPE.EPS) - { - imageAction = "Create EPS file from alignment"; - imageTitle = alignFrame.getTitle(); - } - else - { - imageAction = "Create SVG file from alignment"; - imageTitle = alignFrame.getTitle(); - } - - im = new jalview.util.ImageMaker(this, type, imageAction, - aDimension.getWidth(), - aDimension.getHeight() + boarderBottomOffset, file, - imageTitle, alignFrame, pSessionId, headless); - Graphics graphics = im.getGraphics(); if (av.getWrapAlignment()) { - if (graphics != null) - { - printWrappedAlignment(aDimension.getWidth(), - aDimension.getHeight() + boarderBottomOffset, 0, - graphics); - im.writeImage(); - } + printWrappedAlignment(aDimension.getWidth(), + aDimension.getHeight() + borderBottomOffset, 0, graphics); } else { - if (graphics != null) - { - printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, - graphics, graphics); - im.writeImage(); - } + printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, + graphics, graphics); } - - } catch (OutOfMemoryError err) - { - // Be noisy here. - System.out.println("########################\n" + "OUT OF MEMORY " - + file + "\n" + "########################"); - new OOMWarning("Creating Image for " + file, err); - // System.out.println("Create IMAGE: " + err); - } catch (Exception ex) - { - ex.printStackTrace(); + im.writeImage(); } - } finally + } catch (OutOfMemoryError err) { - + // Be noisy here. + System.out.println("########################\n" + "OUT OF MEMORY " + + file + "\n" + "########################"); + new OOMWarning("Creating Image for " + file, err); + // System.out.println("Create IMAGE: " + err); + } catch (Exception ex) + { + ex.printStackTrace(); } } @@ -1402,27 +1380,6 @@ public class AlignmentPanel extends GAlignmentPanel implements } - /** - * DOCUMENT ME! - */ - public void makeEPS(File epsFile) - { - makeAlignmentImage(jalview.util.ImageMaker.TYPE.EPS, epsFile); - } - - /** - * DOCUMENT ME! - */ - public void makePNG(File pngFile) - { - makeAlignmentImage(jalview.util.ImageMaker.TYPE.PNG, pngFile); - } - - public void makeSVG(File svgFile) - { - makeAlignmentImage(jalview.util.ImageMaker.TYPE.SVG, svgFile); - } - public void makePNGImageMap(File imgMapFile, String imageName) { // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS