protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
{
- HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
- if (hidden == null)
- {
- hidden = new HiddenColumns();
- }
+ HiddenColumns hidden = new HiddenColumns();
+ BitSet inserts = new BitSet();
+ inserts.set(0, ap.av.getAlignment().getWidth());
+
+ boolean markedPopup = false;
+ // mark inserts in current selection
if (ap.av.getSelectionGroup() != null)
{
- BitSet inserts = new BitSet();
- inserts.set(0, ap.av.getAlignment().getWidth());
- ;
for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
{
- inserts.and(sq.getInsertionsAsBits());
- }
- int firstSet = 0, lastSet = 0;
- do
- {
- if (inserts.get(firstSet))
- {
- lastSet = inserts.nextClearBit(firstSet) - 1;
- hidden.hideColumns(firstSet, lastSet);
- firstSet = lastSet + 1;
- }
- else
+ if (sq == sequence)
{
- firstSet = inserts.nextSetBit(firstSet);
+ markedPopup = true;
}
- } while (firstSet > -1);
-
+ inserts.and(sq.getInsertionsAsBits());
+ }
}
- else
- if (sequence != null)
+
+ // now mark for sequence under popup if we haven't already done it
+ if (!markedPopup && sequence != null)
{
- hidden.hideInsertionsFor(sequence);
- ap.av.getAlignment().setHiddenColumns(hidden);
+ inserts.and(sequence.getInsertionsAsBits());
}
+
+ // finally, hide and set hidden columns
+ hidden.hideMarkedBits(inserts);
+ ap.av.getAlignment().setHiddenColumns(hidden);
refresh();
}