Use same mouse events as scalePanel
authoramwaterhouse <Andrew Waterhouse>
Wed, 11 Apr 2007 13:01:18 +0000 (13:01 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 11 Apr 2007 13:01:18 +0000 (13:01 +0000)
src/jalview/gui/AnnotationPanel.java

index ecc1d29..86fef5f 100755 (executable)
@@ -200,6 +200,9 @@ public class AnnotationPanel
       {\r
         int index = av.getColumnSelection().columnAt(i);\r
 \r
+        if(!av.colSel.isVisible(index))\r
+          continue;\r
+\r
         if (anot[index] == null)\r
         {\r
           anot[index] = new Annotation(label, "", ' ', 0);\r
@@ -218,6 +221,9 @@ public class AnnotationPanel
       {\r
         int index = av.getColumnSelection().columnAt(i);\r
 \r
+        if(!av.colSel.isVisible(index))\r
+          continue;\r
+\r
         if (anot[index] == null)\r
         {\r
           anot[index] = new Annotation("", "", ' ', 0);\r
@@ -264,6 +270,9 @@ public class AnnotationPanel
       {\r
         int index = av.getColumnSelection().columnAt(i);\r
 \r
+        if(!av.colSel.isVisible(index))\r
+          continue;\r
+\r
         if (anot[index] == null)\r
         {\r
           anot[index] = new Annotation(label, "", type, 0);\r
@@ -354,36 +363,7 @@ public class AnnotationPanel
       return;\r
     }\r
 \r
-    int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();\r
-\r
-    if (av.hasHiddenColumns)\r
-    {\r
-      res = av.getColumnSelection().adjustForHiddenColumns(res);\r
-    }\r
-\r
-    min = res;\r
-    max = res;\r
-\r
-    if (av.getColumnSelection().contains(res))\r
-    {\r
-      av.getColumnSelection().removeElement(res);\r
-    }\r
-    else\r
-    {\r
-      av.getColumnSelection().addElement(res);\r
-      SequenceGroup sg = new SequenceGroup();\r
-\r
-      for (int i = 0; i < av.alignment.getSequences().size(); i++)\r
-      {\r
-        sg.addSequence(av.alignment.getSequenceAt(i), false);\r
-      }\r
-\r
-      sg.setStartRes(res);\r
-      sg.setEndRes(res);\r
-      av.setSelectionGroup(sg);\r
-    }\r
-\r
-    ap.paintAlignment(true);\r
+    ap.scalePanel.mousePressed(evt);\r
 \r
   }\r
 \r
@@ -397,6 +377,7 @@ public class AnnotationPanel
     graphStretch = -1;\r
     graphStretchY = -1;\r
     mouseDragging = false;\r
+    ap.scalePanel.mouseReleased(evt);\r
   }\r
 \r
   /**\r
@@ -406,10 +387,7 @@ public class AnnotationPanel
    */\r
   public void mouseEntered(MouseEvent evt)\r
   {\r
-    if (mouseDragging)\r
-    {\r
-      ap.seqPanel.scrollCanvas(null);\r
-    }\r
+     ap.scalePanel.mouseEntered(evt);\r
   }\r
 \r
   /**\r
@@ -419,10 +397,7 @@ public class AnnotationPanel
    */\r
   public void mouseExited(MouseEvent evt)\r
   {\r
-    if (mouseDragging)\r
-    {\r
-      ap.seqPanel.scrollCanvas(evt);\r
-    }\r
+    ap.scalePanel.mouseExited(evt);\r
   }\r
 \r
   /**\r
@@ -446,58 +421,7 @@ public class AnnotationPanel
     }\r
     else\r
     {\r
-      mouseDragging = true;\r
-\r
-      int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();\r
-\r
-      if (av.hasHiddenColumns)\r
-      {\r
-        res = av.getColumnSelection().adjustForHiddenColumns(res);\r
-      }\r
-\r
-      SequenceGroup sg = av.getSelectionGroup();\r
-\r
-      if (res < min)\r
-      {\r
-        min = res;\r
-      }\r
-\r
-      if (res > max)\r
-      {\r
-        max = res;\r
-      }\r
-\r
-      if (sg != null)\r
-      {\r
-        if (!av.getColumnSelection().contains(res))\r
-        {\r
-          av.getColumnSelection().addElement(res);\r
-        }\r
-\r
-        if (res > sg.getStartRes())\r
-        {\r
-          sg.setEndRes(res);\r
-        }\r
-        else if (res < sg.getStartRes())\r
-        {\r
-          sg.setStartRes(res);\r
-        }\r
-\r
-        for (int i = min; i <= max; i++)\r
-        {\r
-          if ( (i < sg.getStartRes()) || (i > sg.getEndRes()))\r
-          {\r
-            av.getColumnSelection().removeElement(i);\r
-          }\r
-          else\r
-          {\r
-            av.getColumnSelection().addElement(i);\r
-          }\r
-        }\r
-\r
-        ap.paintAlignment(true);\r
-      }\r
-\r
+      ap.scalePanel.mouseDragged(evt);\r
     }\r
   }\r
 \r