X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=3dfb5105fcaf77d7c3312e8b0468d3bc5af44d09;hb=a6f0678764ea06034460236c7a811bbfcad682aa;hp=e84aae0758c77af11c5c011c42b814b71fbe18ee;hpb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index e84aae0..3dfb510 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -20,30 +20,6 @@ */ package jalview.gui; -import jalview.analysis.AnnotationSorter; -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.bin.Cache; -import jalview.bin.Console; -import jalview.bin.Jalview; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.HiddenColumns; -import jalview.datamodel.SearchResultsI; -import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.gui.ImageExporter.ImageWriterI; -import jalview.io.HTMLOutput; -import jalview.jbgui.GAlignmentPanel; -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.viewmodel.ViewportListenerI; -import jalview.viewmodel.ViewportRanges; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; @@ -68,6 +44,32 @@ import java.util.List; import javax.swing.SwingUtilities; +import jalview.analysis.AnnotationSorter; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; +import jalview.bin.Console; +import jalview.bin.Jalview; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.HiddenColumns; +import jalview.datamodel.SearchResultsI; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.gui.ImageExporter.ImageWriterI; +import jalview.io.HTMLOutput; +import jalview.io.exceptions.ImageOutputException; +import jalview.jbgui.GAlignmentPanel; +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.imagemaker.BitmapImageSizing; +import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; + /** * DOCUMENT ME! * @@ -230,6 +232,10 @@ public class AlignmentPanel extends GAlignmentPanel implements // to prevent drawing old image FontMetrics fm = getFontMetrics(av.getFont()); + // update the flag controlling whether the grid is too small to render the + // font + av.validCharWidth = fm.charWidth('M') <= av.getCharWidth(); + scalePanelHolder.setPreferredSize( new Dimension(10, av.getCharHeight() + fm.getDescent())); idSpaceFillerPanel1.setPreferredSize( @@ -1042,6 +1048,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight); + updateLayout(); getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av, alignmentGraphics, -1, startRes, endRes + 1); } @@ -1168,14 +1175,23 @@ public class AlignmentPanel extends GAlignmentPanel implements return (w > 0 ? w : calculateIdWidth().width); } + void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer) throws ImageOutputException + { + makeAlignmentImage(type, file, renderer, + BitmapImageSizing.nullBitmapImageSizing()); + } + /** * Builds an image of the alignment of the specified type (EPS/PNG/SVG) and * writes it to the specified file * * @param type * @param file + * @param textrenderer + * @param bitmapscale */ - void makeAlignmentImage(ImageMaker.TYPE type, File file) + void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer, + BitmapImageSizing userBis) throws ImageOutputException { final int borderBottomOffset = 5; @@ -1205,7 +1221,8 @@ public class AlignmentPanel extends GAlignmentPanel implements int imageWidth = aDimension.getWidth(); int imageHeight = aDimension.getHeight() + borderBottomOffset; String of = MessageManager.getString("label.alignment"); - exporter.doExport(file, this, imageWidth, imageHeight, of); + exporter.doExport(file, this, imageWidth, imageHeight, of, renderer, + userBis); } /** @@ -1249,7 +1266,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } - public void makePNGImageMap(File imgMapFile, String imageName) + public void makePNGImageMap(File imgMapFile, String imageName) throws ImageOutputException { // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS // //////////////////////////////////////////// @@ -1374,7 +1391,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } catch (Exception ex) { - ex.printStackTrace(); + throw new ImageOutputException("couldn't write ImageMap due to unexpected error",ex); } } // /////////END OF IMAGE MAP @@ -1742,4 +1759,42 @@ public class AlignmentPanel extends GAlignmentPanel implements return calculationDialog; } + /** + * Constructs and sets the title for the Overview window (if there is one), + * including the align frame's title, and view name (if applicable). Returns + * the title, or null if this panel has no Overview window open. + * + * @param alignFrame + * @return + */ + public String setOverviewTitle(AlignFrame alignFrame) + { + if (this.overviewPanel == null) + { + return null; + } + String overviewTitle = MessageManager + .formatMessage("label.overview_params", new Object[] + { alignFrame.getTitle() }); + String viewName = getViewName(); + if (viewName != null) + { + overviewTitle += (" " + viewName); + } + overviewPanel.setTitle(overviewTitle); + return overviewTitle; + } + + /** + * If this alignment panel has an Overview panel open, closes it + */ + public void closeOverviewPanel() + { + if (overviewPanel != null) + { + overviewPanel.close(); + overviewPanel = null; + } + } + }