JAL-3345 JAL3253 Smoother ScalePanel-based scrolling
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Tue, 2 Jul 2019 18:27:13 +0000 (20:27 +0200)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Tue, 2 Jul 2019 18:27:13 +0000 (20:27 +0200)
src/jalview/gui/ScalePanel.java
src/jalview/gui/SeqPanel.java

index a6b4b49..bfa903a 100755 (executable)
@@ -585,4 +585,10 @@ public class ScalePanel extends JPanel
     }
   }
 
+  public boolean isMouseDragging()
+  {
+    // TODO Auto-generated method stub
+    return mouseDragging;
+  }
+
 }
index 2df55ad..26ec081 100644 (file)
@@ -134,7 +134,6 @@ public class SeqPanel extends JPanel
       MousePos o = (MousePos) obj;
       boolean b = (column == o.column && seqIndex == o.seqIndex
               && annotationIndex == o.annotationIndex);
-      // System.out.println(obj + (b ? "= " : "!= ") + this);
       return b;
     }
 
@@ -1504,7 +1503,6 @@ public class SeqPanel extends JPanel
         return;
       }
 
-      // System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~");
       // Selection spans a hidden region
       if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1))
       {
@@ -1942,13 +1940,17 @@ public class SeqPanel extends JPanel
   @Override
   public void mouseExited(MouseEvent e)
   {
+    if (ap.getScalePanel().isMouseDragging())
+    {
+      ap.getScalePanel().mouseExited(e);
+      return;
+    }
     lastMousePosition = null;
     ap.alignFrame.setStatus(" ");
     if (av.getWrapAlignment())
     {
       return;
     }
-
     if (mouseDragging && scrollThread == null)
     {
       startScrolling(e.getPoint());
@@ -2424,29 +2426,22 @@ public class SeqPanel extends JPanel
               // if (!scrollOnce() {t.stop();}) gives compiler error :-(
               scrollThread.scrollOnce();
             }
-          }
-        });
-        t.addActionListener(new ActionListener()
-        {
-          @Override
-          public void actionPerformed(ActionEvent e)
-          {
             if (scrollThread == null)
             {
               // SeqPanel.stopScrolling called
-              t.stop();
+              ((Timer) e.getSource()).stop();
             }
           }
         });
         t.start();
       }
-    }
-    else
-    {
-      /*
-       * Java - run in a new thread
-       */
-      scrollThread.start();
+      else
+      {
+        /*
+         * Java - run in a new thread
+         */
+        scrollThread.start();
+      }
     }
   }