import jalview.util.MessageManager;
import java.awt.Color;
+import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
}
+ /**
+ *
+ * Add highlighted sequences to selected rows. Exclude highlighted sequences
+ * from selected rows. toggle inclusion or exclusion of highlighted sequences.
+ * or add/exclude/toggle for sequences not highlighted.
+ *
+ * @param invert
+ * - when true, sequences that are not highlighted are used to modify
+ * selection
+ * @param extendCurrent
+ * - normally true , the current selected group is modified.
+ * @param toggle
+ * - if a select
+ * @return
+ */
+ public boolean selectHighlightedSequences(boolean invert,
+ boolean extendCurrent, boolean toggle)
+ {
+ List<SequenceI> results = alignPanel.getAlignViewport()
+ .getHighlightedSeqs();
+
+ SequenceGroup sq = (extendCurrent
+ && viewport.getSelectionGroup() != null)
+ ? viewport.getSelectionGroup()
+ : new SequenceGroup();
+
+ if (invert)
+ {
+ List<SequenceI> nothighlighted = new ArrayList();
+ for (SequenceI seq : alignPanel.getAlignViewport().getAlignment()
+ .getSequences())
+ {
+ if (!results.contains(seq))
+ {
+ nothighlighted.add(seq);
+ }
+ }
+ results = nothighlighted;
+ }
+
+ if (results == null || results.size() == 0)
+ {
+ // do nothing if no selection exists
+ // unless toggle ??
+ return false;
+ }
+
+ boolean changed = false;
+
+ for (SequenceI seq : results)
+ {
+ int size = sq.getSize();
+ if (toggle)
+ {
+ sq.addOrRemove(seq, false);
+ }
+ else
+ {
+ sq.addSequence(seq, false);
+ }
+ changed |= size != sq.getSize();
+ }
+
+ if (sq.getSize() == 0)
+ {
+ viewport.setSelectionGroup(null);
+ }
+ else
+ {
+ if (sq != viewport.getSelectionGroup())
+ {
+ sq.setStartRes(0);
+ sq.setEndRes(viewport.getRanges().getAbsoluteAlignmentWidth());
+ }
+ viewport.setSelectionGroup(sq);
+ }
+
+ alignPanel.paintAlignment(false, false);
+
+ return changed;
+ }
+
@Override
public boolean markHighlightedColumns(boolean invert,
boolean extendCurrent, boolean toggle)