X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=98a7fe28b15d9d497984541fe31c96912cfacdcf;hb=51728d3951398f9c12d7017c776953f17322cc68;hp=d651c0bfb7e67dfecbbac0d1161b25998b7b51d6;hpb=853624fb32058cccc544ae7d13af6ad4b0800b6c;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index d651c0b..98a7fe2 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -866,6 +866,24 @@ public class ColumnSelection */ region[0] = Math.min(region[0], start); region[1] = Math.max(region[1], end); + + /* + * also update or remove any subsequent ranges + * that are overlapped + */ + while (i < hiddenColumns.size() - 1) + { + int[] nextRegion = hiddenColumns.get(i + 1); + if (nextRegion[0] > end + 1) + { + /* + * gap to next hidden range - no more to update + */ + break; + } + region[1] = Math.max(nextRegion[1], end); + hiddenColumns.remove(i + 1); + } return; } } @@ -1813,4 +1831,55 @@ public class ColumnSelection return changed; } + /** + * Adjusts column selections, and the given selection group, to match the + * range of a stretch (e.g. mouse drag) operation + *

+ * Method refactored from ScalePanel.mouseDragged + * + * @param res + * current column position, adjusted for hidden columns + * @param sg + * current selection group + * @param min + * start position of the stretch group + * @param max + * end position of the stretch group + */ + public void stretchGroup(int res, SequenceGroup sg, int min, int max) + { + if (!contains(res)) + { + addElement(res); + } + + if (res > sg.getStartRes()) + { + // expand selection group to the right + sg.setEndRes(res); + } + if (res < sg.getStartRes()) + { + // expand selection group to the left + sg.setStartRes(res); + } + + /* + * expand or shrink column selection to match the + * range of the drag operation + */ + for (int col = min; col <= max; col++) + { + if (col < sg.getStartRes() || col > sg.getEndRes()) + { + // shrinking drag - remove from selection + removeElement(col); + } + else + { + // expanding drag - add to selection + addElement(col); + } + } + } }