allow middle-button drag to change height of annotation rows in applet
authorjprocter <Jim Procter>
Thu, 3 Sep 2009 15:34:52 +0000 (15:34 +0000)
committerjprocter <Jim Procter>
Thu, 3 Sep 2009 15:34:52 +0000 (15:34 +0000)
src/jalview/appletgui/AnnotationPanel.java

index aef6511..825773f 100755 (executable)
@@ -59,7 +59,13 @@ public class AnnotationPanel extends Panel implements AdjustmentListener,
   int imgWidth = 0;
 
   boolean fastPaint = false;
+  //Used For mouse Dragging and resizing graphs
+  int graphStretch = -1;
 
+  int graphStretchY = -1;
+  
+  boolean mouseDragging=false;
+  
   public static int GRAPH_HEIGHT = 40;
 
   boolean MAC = false;
@@ -262,6 +268,13 @@ public class AnnotationPanel extends Panel implements AdjustmentListener,
         {
           activeRow = i;
         }
+                else if (aa[i].graph > 0)
+        {
+          // Stretch Graph
+          graphStretch = i;
+          graphStretchY = evt.getY();
+        }
+        
 
         break;
       }
@@ -307,6 +320,9 @@ public class AnnotationPanel extends Panel implements AdjustmentListener,
 
   public void mouseReleased(MouseEvent evt)
   {
+    graphStretch = -1;
+    graphStretchY = -1;
+    mouseDragging = false;
     ap.scalePanel.mouseReleased(evt);
   }
 
@@ -316,7 +332,22 @@ public class AnnotationPanel extends Panel implements AdjustmentListener,
 
   public void mouseDragged(MouseEvent evt)
   {
-    ap.scalePanel.mouseDragged(evt);
+    if (graphStretch > -1)
+    {
+      av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+              - evt.getY();
+      if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+      {
+        av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+      }
+      graphStretchY = evt.getY();
+      adjustPanelHeight();
+      ap.paintAlignment(true);
+    }
+    else
+    {
+      ap.scalePanel.mouseDragged(evt);
+    }
   }
 
   public void mouseMoved(MouseEvent evt)