AlignmentPanel ap;\r
boolean stretchingGroup = false;\r
\r
+ int min, max; //used by mouseDragged to see if user\r
+ // wants to delete columns\r
+\r
public ScalePanel(AlignViewport av, AlignmentPanel ap)\r
{\r
this.av = av;\r
int res = (x / av.getCharWidth()) + av.getStartRes();\r
SequenceGroup sg = null;\r
\r
+ min=res;\r
+ max=res;\r
+\r
if (av.getColumnSelection().contains(res))\r
{\r
av.getColumnSelection().removeElement(res);\r
+ ap.annotationPanel.removeEditableColumn(res);\r
}\r
else\r
{\r
av.getColumnSelection().addElement(res);\r
-\r
sg = new SequenceGroup();\r
\r
for (int i = 0; i < av.alignment.getSequences().size(); i++)\r
sg.setStartRes(res);\r
sg.setEndRes(res);\r
\r
- ap.annotationPanel.addEditableColumn(res);\r
}\r
\r
av.setSelectionGroup(sg);\r
\r
public void doMouseReleased(MouseEvent evt)\r
{\r
- if (!stretchingGroup)\r
- {\r
- return;\r
- }\r
-\r
int x = evt.getX();\r
int res = (x / av.getCharWidth()) + av.getStartRes();\r
\r
- if (!av.getColumnSelection().contains(res))\r
+ if(av.getColumnSelection()!=null)\r
{\r
- av.getColumnSelection().addElement(res);\r
+ for(int i=0; i<av.getColumnSelection().size(); i++)\r
+ {\r
+ ap.annotationPanel.addEditableColumn(\r
+ av.getColumnSelection().columnAt(i));\r
+ }\r
+ }\r
+\r
+ if (!stretchingGroup)\r
+ {\r
+ ap.repaint();\r
+ return;\r
}\r
\r
SequenceGroup sg = av.getSelectionGroup();\r
int x = evt.getX();\r
int res = (x / av.getCharWidth()) + av.getStartRes();\r
\r
+ if(res < min)\r
+ min = res;\r
+ if(res>max)\r
+ max = res;\r
+\r
SequenceGroup sg = av.getSelectionGroup();\r
\r
if (sg != null)\r
{\r
stretchingGroup = true;\r
+ if (!av.getColumnSelection().contains(res))\r
+ {\r
+ av.getColumnSelection().addElement(res);\r
+ }\r
+\r
\r
if (res > sg.getStartRes())\r
{\r
sg.setStartRes(res);\r
}\r
\r
- ap.annotationPanel.addEditableColumn(res);\r
+ for(int i=min; i<=max; i++)\r
+ {\r
+ if (i < sg.getStartRes() || i > sg.getEndRes())\r
+ {\r
+ av.getColumnSelection().removeElement(i);\r
+ ap.annotationPanel.removeEditableColumn(res);\r
+ }\r
+ else\r
+ av.getColumnSelection().addElement(i);\r
+ }\r
ap.repaint();\r
}\r
}\r