import jalview.util.ShiftList;
import java.util.ArrayList;
+import java.util.BitSet;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
return hashCode;
}
+ /**
+ * Hide columns corresponding to the marked bits
+ *
+ * @param inserts
+ * - columns map to bits starting from zero
+ */
+ public void hideMarkedBits(BitSet inserts)
+ {
+ for (int firstSet = inserts.nextSetBit(0), lastSet = 0; firstSet >= 0; firstSet = inserts
+ .nextSetBit(lastSet))
+ {
+ lastSet = inserts.nextClearBit(firstSet);
+ hideColumns(firstSet, lastSet - 1);
+ }
+ }
+
}
import jalview.gui.JvOptionPane;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.List;
import org.testng.annotations.BeforeClass;
assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
}
+ @Test(groups = { "Functional" })
+ public void testHideBitset()
+ {
+ HiddenColumns cs;
+
+ BitSet one = new BitSet();
+
+ // one hidden range
+ one.set(1);
+ cs = new HiddenColumns();
+ cs.hideMarkedBits(one);
+ assertEquals(1, cs.getHiddenRegions().size());
+
+ one.set(2);
+ cs = new HiddenColumns();
+ cs.hideMarkedBits(one);
+ assertEquals(1, cs.getHiddenRegions().size());
+
+ one.set(3);
+ cs = new HiddenColumns();
+ cs.hideMarkedBits(one);
+ assertEquals(1, cs.getHiddenRegions().size());
+
+ // split
+ one.clear(2);
+ cs = new HiddenColumns();
+ cs.hideMarkedBits(one);
+ assertEquals(2, cs.getHiddenRegions().size());
+
+ assertEquals(0, cs.adjustForHiddenColumns(0));
+ assertEquals(2, cs.adjustForHiddenColumns(1));
+ assertEquals(4, cs.adjustForHiddenColumns(2));
+
+ // one again
+ one.clear(1);
+ cs = new HiddenColumns();
+ cs.hideMarkedBits(one);
+
+ assertEquals(1, cs.getHiddenRegions().size());
+
+ assertEquals(0, cs.adjustForHiddenColumns(0));
+ assertEquals(1, cs.adjustForHiddenColumns(1));
+ assertEquals(2, cs.adjustForHiddenColumns(2));
+ assertEquals(4, cs.adjustForHiddenColumns(3));
+ }
}