X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=beafa8cb36ed9b916ef9fc2e185f519ef475be46;hb=1ae9824ef37ce4ed36d1da986003474b47d1ab11;hp=be8e592c5aaa7d26cc6da3da71a139da2403e603;hpb=b13f521553582ef2fbfd7815ae25e23284babdea;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index be8e592..beafa8c 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -21,6 +21,7 @@ package jalview.gui; import jalview.analysis.AnnotationSorter; +import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; import jalview.datamodel.AlignmentI; @@ -94,9 +95,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * Creates a new AlignmentPanel object. * * @param af - * DOCUMENT ME! * @param av - * DOCUMENT ME! */ public AlignmentPanel(AlignFrame af, final AlignViewport av) { @@ -122,8 +121,6 @@ public class AlignmentPanel extends GAlignmentPanel implements setScrollValues(0, 0); - setAnnotationVisible(av.isShowAnnotation()); - hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); @@ -141,9 +138,14 @@ public class AlignmentPanel extends GAlignmentPanel implements }); fontChanged(); adjustAnnotationHeight(); - + updateLayout(); } + @Override + public AlignViewportI getAlignViewport() + { + return av; + } public void alignmentChanged() { av.alignmentChanged(this); @@ -163,9 +165,10 @@ public class AlignmentPanel extends GAlignmentPanel implements // to prevent drawing old image FontMetrics fm = getFontMetrics(av.getFont()); - scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight + scalePanelHolder.setPreferredSize(new Dimension(10, av.getCharHeight() + fm.getDescent())); - idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight + idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av + .getCharHeight() + fm.getDescent())); getIdPanel().getIdCanvas().gg = null; @@ -173,6 +176,7 @@ public class AlignmentPanel extends GAlignmentPanel implements getAnnotationPanel().adjustPanelHeight(); Dimension d = calculateIdWidth(); + d.setSize(d.width + 4, d.height); getIdPanel().getIdCanvas().setPreferredSize(d); hscrollFillerPanel.setPreferredSize(d); @@ -181,6 +185,10 @@ public class AlignmentPanel extends GAlignmentPanel implements { overviewPanel.setBoxPosition(); } + if (this.alignFrame.getSplitViewContainer() != null) + { + ((SplitFrame) this.alignFrame.getSplitViewContainer()).adjustLayout(); + } repaint(); } @@ -195,11 +203,21 @@ public class AlignmentPanel extends GAlignmentPanel implements public Dimension calculateIdWidth() { // calculate sensible default width when no preference is available - - int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300); - int maxwidth = Math.max(20, - Math.min(afwidth - 200, 2 * afwidth / 3)); - return calculateIdWidth(maxwidth); + Dimension r = null; + if (av.getIdWidth() < 0) + { + int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300); + int maxwidth = Math.max(20, Math.min(afwidth - 200, 2 * afwidth / 3)); + r = calculateIdWidth(maxwidth); + av.setIdWidth(r.width); + } + else + { + r = new Dimension(); + r.width = av.getIdWidth(); + r.height = 0; + } + return r; } /** @@ -339,7 +357,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } } } - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { if ((startv = av.getStartRes()) >= start) { @@ -412,7 +430,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void setAnnotationVisible(boolean b) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { annotationSpaceFillerHolder.setVisible(b); annotationScroller.setVisible(b); @@ -488,13 +506,16 @@ public class AlignmentPanel extends GAlignmentPanel implements } /** - * DOCUMENT ME! + * update alignment layout for viewport settings * * @param wrap * DOCUMENT ME! */ - public void setWrapAlignment(boolean wrap) + public void updateLayout() { + fontChanged(); + setAnnotationVisible(av.isShowAnnotation()); + boolean wrap = av.getWrapAlignment(); av.startSeq = 0; scalePanelHolder.setVisible(!wrap); hscroll.setVisible(!wrap); @@ -605,10 +626,11 @@ public class AlignmentPanel extends GAlignmentPanel implements width = av.getColumnSelection().findColumnPosition(width); } - av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av.charWidth)) - 1); + av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av + .getCharWidth())) - 1); - hextent = getSeqPanel().seqCanvas.getWidth() / av.charWidth; - vextent = getSeqPanel().seqCanvas.getHeight() / av.charHeight; + hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth(); + vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight(); if (hextent > width) { @@ -652,7 +674,6 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void adjustmentValueChanged(AdjustmentEvent evt) { - int oldX = av.getStartRes(); int oldY = av.getStartSeq(); @@ -859,7 +880,7 @@ public class AlignmentPanel extends GAlignmentPanel implements { int idWidth = getVisibleIdWidth(false); FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + int scaleHeight = av.getCharHeight() + fm.getDescent(); pg.setColor(Color.white); pg.fillRect(0, 0, pwidth, pheight); @@ -949,7 +970,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } pg.setColor(currentColor); - pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, + pg.fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth, av.getCharHeight()); pg.setColor(currentTextColor); @@ -966,7 +987,7 @@ public class AlignmentPanel extends GAlignmentPanel implements pg.drawString( seq.getDisplayId(av.getShowJVSuffix()), xPos, - (((i - startSeq) * av.charHeight) + av.getCharHeight()) + (((i - startSeq) * av.getCharHeight()) + av.getCharHeight()) - (av.getCharHeight() / 5)); } @@ -981,7 +1002,8 @@ public class AlignmentPanel extends GAlignmentPanel implements // draw annotation - need to offset for current scroll position int offset = -getAlabels().getScrollOffset(); pg.translate(0, offset); - pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3); + pg.translate(-idWidth - 3, (endSeq - startSeq) * av.getCharHeight() + + 3); getAlabels().drawComponent(pg, idWidth); pg.translate(idWidth + 3, 0); getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av, @@ -1012,7 +1034,6 @@ public class AlignmentPanel extends GAlignmentPanel implements public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException { - int annotationHeight = 0; AnnotationLabels labels = null; if (av.isShowAnnotation()) @@ -1021,13 +1042,13 @@ public class AlignmentPanel extends GAlignmentPanel implements labels = new AnnotationLabels(av); } - int hgap = av.charHeight; - if (av.scaleAboveWrapped) + int hgap = av.getCharHeight(); + if (av.getScaleAboveWrapped()) { - hgap += av.charHeight; + hgap += av.getCharHeight(); } - int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap + annotationHeight; int idWidth = getVisibleIdWidth(false); @@ -1071,18 +1092,19 @@ public class AlignmentPanel extends GAlignmentPanel implements xPos = idWidth - fm.stringWidth(string) - 4; } pg.drawString(string, xPos, - ((i * av.charHeight) + ypos + av.charHeight) - - (av.charHeight / 5)); + ((i * av.getCharHeight()) + ypos + av.getCharHeight()) + - (av.getCharHeight() / 5)); } if (labels != null) { pg.translate(-3, ypos - + (av.getAlignment().getHeight() * av.charHeight)); + + (av.getAlignment().getHeight() * av.getCharHeight())); pg.setFont(av.getFont()); labels.drawComponent(pg, idWidth); pg.translate(+3, -ypos - - (av.getAlignment().getHeight() * av.charHeight)); + - (av.getAlignment().getHeight() * av + .getCharHeight())); } ypos += cHeight; @@ -1149,8 +1171,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (alignFrame != null && !headless) { alignFrame.setProgressBar(MessageManager.formatMessage( - "status.saving_file", - new String[] + "status.saving_file", new Object[] { type.getLabel() }), progress); } try @@ -1225,9 +1246,9 @@ public class AlignmentPanel extends GAlignmentPanel implements maxwidth = av.getColumnSelection().findColumnPosition(maxwidth); } - int height = ((av.getAlignment().getHeight() + 1) * av.charHeight) + int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight()) + getScalePanel().getHeight(); - int width = getVisibleIdWidth(false) + (maxwidth * av.charWidth); + int width = getVisibleIdWidth(false) + (maxwidth * av.getCharWidth()); if (av.getWrapAlignment()) { @@ -1283,7 +1304,7 @@ public class AlignmentPanel extends GAlignmentPanel implements // //////////////////////////////////////////// int idWidth = getVisibleIdWidth(false); FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + int scaleHeight = av.getCharHeight() + fm.getDescent(); // Gen image map // //////////////////////////////// @@ -1302,7 +1323,7 @@ public class AlignmentPanel extends GAlignmentPanel implements for (s = 0; s < sSize; s++) { - sy = s * av.charHeight + scaleHeight; + sy = s * av.getCharHeight() + scaleHeight; SequenceI seq = av.getAlignment().getSequenceAt(s); SequenceFeature[] features = seq.getSequenceFeatures(); @@ -1310,24 +1331,24 @@ public class AlignmentPanel extends GAlignmentPanel implements for (res = 0; res < alwidth; res++) { text = new StringBuffer(); - Object obj = null; + String triplet = null; if (av.getAlignment().isNucleotide()) { - obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res) + triplet = ResidueProperties.nucleotideName.get(seq + .getCharAt(res) + ""); } else { - obj = ResidueProperties.aa2Triplet.get(seq.getCharAt(res) + triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(res) + ""); } - if (obj == null) + if (triplet == null) { continue; } - String triplet = obj.toString(); int alIndex = seq.findPosition(res); gSize = groups.length; for (g = 0; g < gSize; g++) @@ -1335,9 +1356,10 @@ public class AlignmentPanel extends GAlignmentPanel implements if (text.length() < 1) { text.append("