JAL-147 corrected update of ViewportRanges for show/hide sequences
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 4 Jul 2017 10:23:32 +0000 (11:23 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 4 Jul 2017 10:23:32 +0000 (11:23 +0100)
src/jalview/viewmodel/AlignmentViewport.java

index 7b64ab3..5e88c87 100644 (file)
@@ -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<SequenceI> 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());
     }
   }