From a377b62f440f6afda24b06e26317677904fa2953 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 15 Jun 2005 15:01:37 +0000 Subject: [PATCH] Column selection changed --- src/jalview/gui/ScalePanel.java | 49 +++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 551f262..73a9e6e 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -33,6 +33,9 @@ public class ScalePanel AlignmentPanel ap; boolean stretchingGroup = false; + int min, max; //used by mouseDragged to see if user + // wants to delete columns + public ScalePanel(AlignViewport av, AlignmentPanel ap) { this.av = av; @@ -65,14 +68,17 @@ public class ScalePanel int res = (x / av.getCharWidth()) + av.getStartRes(); SequenceGroup sg = null; + min=res; + max=res; + if (av.getColumnSelection().contains(res)) { av.getColumnSelection().removeElement(res); + ap.annotationPanel.removeEditableColumn(res); } else { av.getColumnSelection().addElement(res); - sg = new SequenceGroup(); for (int i = 0; i < av.alignment.getSequences().size(); i++) @@ -83,7 +89,6 @@ public class ScalePanel sg.setStartRes(res); sg.setEndRes(res); - ap.annotationPanel.addEditableColumn(res); } av.setSelectionGroup(sg); @@ -92,17 +97,22 @@ public class ScalePanel public void doMouseReleased(MouseEvent evt) { - if (!stretchingGroup) - { - return; - } - int x = evt.getX(); int res = (x / av.getCharWidth()) + av.getStartRes(); - if (!av.getColumnSelection().contains(res)) + if(av.getColumnSelection()!=null) { - av.getColumnSelection().addElement(res); + for(int i=0; imax) + max = res; + SequenceGroup sg = av.getSelectionGroup(); if (sg != null) { stretchingGroup = true; + if (!av.getColumnSelection().contains(res)) + { + av.getColumnSelection().addElement(res); + } + if (res > sg.getStartRes()) { @@ -140,7 +160,16 @@ public class ScalePanel sg.setStartRes(res); } - ap.annotationPanel.addEditableColumn(res); + for(int i=min; i<=max; i++) + { + if (i < sg.getStartRes() || i > sg.getEndRes()) + { + av.getColumnSelection().removeElement(i); + ap.annotationPanel.removeEditableColumn(res); + } + else + av.getColumnSelection().addElement(i); + } ap.repaint(); } } -- 1.7.10.2