X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=ed07b637c53ea3a3bdb90afa9ccd354850d9d1e0;hb=7f4da0a2b0c10f158a03dbfce8878e67e90c4a68;hp=5a156faf2f8d6e9484b545c5363e37eac678686a;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 5a156fa..ed07b63 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -264,72 +264,30 @@ public class ScalePanel extends Panel implements MouseMotionListener, av.sendSelection(); } + /** + * Action on dragging the mouse in the scale panel is to expand or shrink the + * selection group range (including any hidden columns that it spans) + * + * @param evt + */ @Override public void mouseDragged(MouseEvent evt) { mouseDragging = true; + ColumnSelection cs = av.getColumnSelection(); int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - if (res < 0) - { - res = 0; - } - - if (av.hasHiddenColumns()) - { - res = av.getColumnSelection().adjustForHiddenColumns(res); - } - - if (res > av.getAlignment().getWidth()) - { - res = av.getAlignment().getWidth() - 1; - } - - if (res < min) - { - min = res; - } - - if (res > max) - { - max = res; - } + res = Math.max(0, res); + res = cs.adjustForHiddenColumns(res); + res = Math.min(res, av.getAlignment().getWidth() - 1); + min = Math.min(res, min); + max = Math.max(res, max); SequenceGroup sg = av.getSelectionGroup(); - if (sg != null) { stretchingGroup = true; - - if (!av.getColumnSelection().contains(res)) - { - av.getColumnSelection().addElement(res); - } - - if (res > sg.getStartRes()) - { - sg.setEndRes(res); - } - if (res < sg.getStartRes()) - { - sg.setStartRes(res); - } - - int col; - for (int i = min; i <= max; i++) - { - col = av.getColumnSelection().adjustForHiddenColumns(i); - - if ((col < sg.getStartRes()) || (col > sg.getEndRes())) - { - av.getColumnSelection().removeElement(col); - } - else - { - av.getColumnSelection().addElement(col); - } - } - + cs.stretchGroup(res, sg, min, max); ap.paintAlignment(false); } }