- * Updates the column selection depending on the parameters, and returns true
- * if any change was made to the selection.
- *
- * @param columnSelection
- * the current column selection
- * @param invert
- * if true, deselect marked columns and select unmarked
- * @param extendCurrent
- * if true, extend rather than replacing the current column selection
- * @param toggle
- * if true, toggle the selection state of marked columns
- * @param markedColumns
- * a set identify marked columns
- * @param startCol
- * the first column of the range to operate over
- * @param endCol
- * the last column of the range to operate over
- * @return
- */
- static boolean selectMarkedColumns(ColumnSelection columnSelection,
- boolean invert, boolean extendCurrent, boolean toggle,
- BitSet markedColumns, int startCol, int endCol)
- {
- boolean changed = false;
- if (!extendCurrent && !toggle)
- {
- changed = !columnSelection.isEmpty();
- columnSelection.clear();
- }
- if (invert)
- {
- // invert only in the currently selected sequence region
- int i = markedColumns.nextClearBit(startCol);
- int ibs = markedColumns.nextSetBit(startCol);
- while (i >= startCol && i <= endCol)
- {
- if (ibs < 0 || i < ibs)
- {
- changed = true;
- if (toggle && columnSelection.contains(i))
- {
- columnSelection.removeElement(i++);
- }
- else
- {
- columnSelection.addElement(i++);
- }
- }
- else
- {
- i = markedColumns.nextClearBit(ibs);
- ibs = markedColumns.nextSetBit(i);
- }
- }
- }
- else
- {
- int i = markedColumns.nextSetBit(startCol);
- while (i >= startCol && i <= endCol)
- {
- changed = true;
- if (toggle && columnSelection.contains(i))
- {
- columnSelection.removeElement(i);
- }
- else
- {
- columnSelection.addElement(i);
- }
- i = markedColumns.nextSetBit(i + 1);
- }
- }
- return changed;
- }
-
- /**
- * Sets a bit in the BitSet for each column in the sequence collection which
- * includes the specified feature type. Returns the number of sequences which
- * have the feature in the selected range.