X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=b427739ca3fc776c60e42ea6bfcf4549261092a1;hb=HEAD;hp=3c2d1664bba6c5adbcfd622cfe09d74d9d91d46f;hpb=4b7d3640209c4434d569c746672cf9eed4250ace;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 3c2d166..b427739 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -278,6 +278,27 @@ public class ColumnSelection } /** + * add a series of start,end (inclusive) ranges to the column selection + * + * @param rng + * [start_0, end_0, start_1, end_1, ... ] + * @param baseOne + * - when true, ranges are base 1 and will be mapped to base 0 + */ + public void addRangeOfElements(int[] rng, boolean baseOne) + { + int base = baseOne ? -1 : 0; + for (int c = 0; c < rng.length; c += 2) + { + for (int p = rng[c]; p <= rng[c + 1]; p++) + { + selection.add(base + p); + } + } + + } + + /** * clears column selection */ public void clear() @@ -319,10 +340,12 @@ public class ColumnSelection /** * Returns a read-only view of the (possibly empty) list of selected columns + * (base 1) *

- * The list contains no duplicates but is not necessarily ordered. It also may - * include columns hidden from the current view. To modify (for example sort) - * the list, you should first make a copy. + * The list contains no duplicates but is not necessarily ordered. Columns are + * reported in alignment coordinates (base 1), so may also include columns + * hidden from the current view. To modify (for example sort) the list, you + * should first make a copy. *

* The list is not thread-safe: iterating over it could result in * ConcurrentModificationException if it is modified by another thread.