From: Jim Procter Date: Sun, 4 Jun 2017 11:17:31 +0000 (+0100) Subject: JAL-2291 use HiddenColumns.hideMarkedBits and take union of selection and sequence... X-Git-Tag: Release_2_10_2~3^2~33 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=948b782d6ecd8cfd15aedc2dba66e6c994108629;p=jalview.git JAL-2291 use HiddenColumns.hideMarkedBits and take union of selection and sequence under popup --- diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 8f01162..c7e3fd9 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -1445,42 +1445,33 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener 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(); }