From: kiramt Date: Wed, 3 May 2017 15:31:14 +0000 (+0100) Subject: JAL-2491 Tidies X-Git-Tag: Release_2_10_2~3^2~64^2~25 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=86fd4dbafd6175d651fe569c0861de10029cc7b8;p=jalview.git JAL-2491 Tidies --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index a2773e8..0a128c8 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -477,7 +477,6 @@ public class AlignmentPanel extends GAlignmentPanel implements || res >= (vpRanges.getStartRes() + cwidth)) { vscroll.setValue((res / cwidth)); - // vpRanges.setStartRes(vscroll.getValue() * cwidth); } } @@ -705,7 +704,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (av.getWrapAlignment()) { - setScrollingForWrappedPanel(x, y); + setScrollingForWrappedPanel(x); } else { @@ -752,14 +751,8 @@ public class AlignmentPanel extends GAlignmentPanel implements x = 0; } - /* - * each scroll adjustment triggers adjustmentValueChanged, which resets the - * 'do not scroll complement' flag; ensure it is the same for both - * operations - */ - // boolean flag = isDontScrollComplement(); + // update the scroll values hscroll.setValues(x, hextent, 0, width); - // setDontScrollComplement(flag); vscroll.setValues(y, vextent, 0, height); } } @@ -787,6 +780,10 @@ public class AlignmentPanel extends GAlignmentPanel implements int offy = vscroll.getValue(); int rowSize = getSeqPanel().seqCanvas .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth()); + + // if we're scrolling to the position we're already at, stop + // this prevents infinite recursion of events when the scroll/viewport + // ranges values are the same if (offy * rowSize == oldX) { return; @@ -819,6 +816,10 @@ public class AlignmentPanel extends GAlignmentPanel implements if (evt.getSource() == hscroll) { int x = hscroll.getValue(); + + // if we're scrolling to the position we're already at, stop + // this prevents infinite recursion of events when the scroll/viewport + // ranges values are the same if (x == oldX) { return; @@ -830,6 +831,10 @@ public class AlignmentPanel extends GAlignmentPanel implements else if (evt.getSource() == vscroll) { int offy = vscroll.getValue(); + + // if we're scrolling to the position we're already at, stop + // this prevents infinite recursion of events when the scroll/viewport + // ranges values are the same if (offy == oldY) { return; @@ -889,35 +894,37 @@ public class AlignmentPanel extends GAlignmentPanel implements validate(); /* - * set scroll bar positions; first suppress this being 'followed' in any - * complementary split pane + * set scroll bar positions */ - - // setDontScrollComplement(true); setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq()); } /* * Set vertical scroll bar parameters for wrapped panel + * @param res + * the residue to scroll to */ - private void setScrollingForWrappedPanel(int x, int y) + private void setScrollingForWrappedPanel(int res) { + // get the width of the alignment in residues int maxwidth = av.getAlignment().getWidth(); - if (av.hasHiddenColumns()) { maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; } + // get the width of the canvas in residues int canvasWidth = getSeqPanel().seqCanvas .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth()); if (canvasWidth > 0) { - int current = x / canvasWidth; + // position we want to scroll to is number of canvasWidth's to get there + int current = res / canvasWidth; + + // max scroll position: add one because extent is 1 and scrollbar value + // can only be set to at most max - extent int max = maxwidth / canvasWidth + 1; - vscroll.setMaximum(max); vscroll.setUnitIncrement(1); - vscroll.setVisibleAmount(1); vscroll.setValues(current, 1, 0, max); } } @@ -1891,11 +1898,19 @@ public class AlignmentPanel extends GAlignmentPanel implements } @Override + /** + * Property change event fired when a change is made to the viewport ranges + * object associated with this alignment panel's viewport + */ public void propertyChange(PropertyChangeEvent evt) { + // update this panel's scroll values based on the new viewport ranges values int x = vpRanges.getStartRes(); int y = vpRanges.getStartSeq(); setScrollValues(x, y); + + // now update any complementary alignment (its viewport ranges object + // is different so does not get automatically updated) av.scrollComplementaryAlignment(); } }