From 948b782d6ecd8cfd15aedc2dba66e6c994108629 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 4 Jun 2017 12:17:31 +0100 Subject: [PATCH] JAL-2291 use HiddenColumns.hideMarkedBits and take union of selection and sequence under popup --- src/jalview/gui/PopupMenu.java | 45 ++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 27 deletions(-) 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(); } -- 1.7.10.2