JAL-1738 JAL-345 fix broken calculation of newly marked bits
authorJim Procter <jprocter@issues.jalview.org>
Tue, 1 Nov 2016 17:17:53 +0000 (17:17 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 1 Nov 2016 17:17:53 +0000 (17:17 +0000)
src/jalview/datamodel/SearchResults.java

index a5bf8aa..3cb34de 100755 (executable)
@@ -275,9 +275,9 @@ public class SearchResults implements SearchResultsI
   public int markColumns(SequenceCollectionI sqcol, BitSet bs)
   {
     int count = 0;
+    BitSet mask = new BitSet();
     for (SequenceI s : sqcol.getSequences())
     {
-      BitSet mask = new BitSet();
       int[] cols = getResults(s, sqcol.getStartRes(), sqcol.getEndRes());
       if (cols != null)
       {
@@ -286,13 +286,13 @@ public class SearchResults implements SearchResultsI
           mask.set(cols[pair], cols[pair + 1] + 1);
         }
       }
-      // find columns that were already selected
-      BitSet compl = (BitSet) mask.clone();
-      compl.and(bs);
-      count += compl.cardinality();
-      // and mark ranges not already marked
-      bs.or(mask);
     }
+    // compute columns that were newly selected
+    BitSet original = (BitSet) bs.clone();
+    original.and(mask);
+    count = mask.cardinality() - original.cardinality();
+    // and mark ranges not already marked
+    bs.or(mask);
     return count;
   }