From 0a1844850e4663d353cc52b5a97b1fbdb0e825da Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 4 Jul 2017 11:23:32 +0100 Subject: [PATCH] JAL-147 corrected update of ViewportRanges for show/hide sequences --- src/jalview/viewmodel/AlignmentViewport.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 7b64ab3..5e88c87 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1391,6 +1391,8 @@ public abstract class AlignmentViewport implements AlignViewportI, // common hide/show seq stuff public void showAllHiddenSeqs() { + int startSeq = ranges.getStartSeq(); + if (alignment.getHiddenSequences().getSize() > 0) { if (selectionGroup == null) @@ -1408,7 +1410,8 @@ public abstract class AlignmentViewport implements AlignViewportI, hiddenRepSequences = null; - ranges.setViewportStartAndHeight(0, alignment.getHeight()); + ranges.setStartSeq(startSeq); + firePropertyChange("alignment", null, alignment.getSequences()); // used to set hasHiddenRows/hiddenRepSequences here, after the property // changed event @@ -1418,6 +1421,8 @@ public abstract class AlignmentViewport implements AlignViewportI, public void showSequence(int index) { + int startSeq = ranges.getStartSeq(); + List tmp = alignment.getHiddenSequences().showSequence( index, hiddenRepSequences); if (tmp.size() > 0) @@ -1433,7 +1438,7 @@ public abstract class AlignmentViewport implements AlignViewportI, selectionGroup.addSequence(seq, false); setSequenceAnnotationsVisible(seq, true); } - ranges.setViewportStartAndHeight(0, alignment.getHeight()); + ranges.setStartSeq(startSeq); firePropertyChange("alignment", null, alignment.getSequences()); sendSelection(); } @@ -1455,6 +1460,11 @@ public abstract class AlignmentViewport implements AlignViewportI, public void hideSequence(SequenceI[] seq) { + /* + * cache offset to first visible sequence + */ + int startSeq = ranges.getStartSeq(); + if (seq != null) { for (int i = 0; i < seq.length; i++) @@ -1462,7 +1472,7 @@ public abstract class AlignmentViewport implements AlignViewportI, alignment.getHiddenSequences().hideSequence(seq[i]); setSequenceAnnotationsVisible(seq[i], false); } - ranges.setViewportStartAndHeight(0, alignment.getHeight()); + ranges.setStartSeq(startSeq); firePropertyChange("alignment", null, alignment.getSequences()); } } -- 1.7.10.2