From: Jim Procter Date: Tue, 1 Nov 2016 21:37:48 +0000 (+0000) Subject: JAL-966 JAL-345 JAL-1738 quick rewrite of scrollToPosition in applet - further refact... X-Git-Tag: Release_2_10_1~10^2~6^2~1^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ea8826bea12e5d811e47463d22413c33dae3738a;p=jalview.git JAL-966 JAL-345 JAL-1738 quick rewrite of scrollToPosition in applet - further refactoring needed to merge applet/desktop scroll logic --- diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 4198960..f77d6a1 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -323,7 +323,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, public boolean scrollToPosition(SearchResultsI results, boolean redrawOverview) { - return scrollToPosition(results, redrawOverview, false); + return scrollToPosition(results, 0, redrawOverview, false); } /** @@ -336,6 +336,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * @return false if results were not found */ public boolean scrollToPosition(SearchResultsI results, + int verticalOffset, boolean redrawOverview, boolean centre) { // do we need to scroll the panel? @@ -347,6 +348,10 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { return false; } + /* + * allow for offset of target sequence (actually scroll to one above it) + */ + SequenceI seq = alignment.getSequenceAt(seqIndex); int[] r = results.getResults(seq, 0, alignment.getWidth()); if (r == null) @@ -391,6 +396,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { return false; } + + /* + * allow for offset of target sequence (actually scroll to one above it) + */ + seqIndex = Math.max(0, seqIndex - verticalOffset); return scrollTo(start, end, seqIndex, false, redrawOverview); } return true; @@ -419,6 +429,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { start = ostart; } + if (!av.getWrapAlignment()) { /* @@ -931,16 +942,14 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { return; // failsafe, shouldn't happen } - sequenceIndex = Math.max(0, sequenceIndex - seqOffset); - sr.getResults().get(0) - .setSequence(av.getAlignment().getSequenceAt(sequenceIndex)); /* * Scroll to position but centring the target residue. Also set a state flag * to prevent adjustmentValueChanged performing this recursively. */ setFollowingComplementScroll(true); - scrollToPosition(sr, true, true); + // this should be scrollToPosition(sr,verticalOffset, + scrollToPosition(sr, seqOffset, true, true); } private void sendViewPosition()