JAL-2388 Factored out applet overview canvas, threading adjustments
[jalview.git] / src / jalview / gui / OverviewCanvas.java
index df831e1..8c02423 100644 (file)
@@ -42,6 +42,8 @@ public class OverviewCanvas extends JComponent
   // the overview is being calculated
   private volatile boolean restart = false;
 
+  private volatile boolean updaterunning = false;
+
   private BufferedImage miniMe;
 
   private BufferedImage lastMiniMe = null;
@@ -79,9 +81,20 @@ public class OverviewCanvas extends JComponent
    * Signals to drawing code that the associated alignment viewport
    * has changed and a redraw will be required
    */
-  public void restartDraw()
+  public boolean restartDraw()
   {
-    restart = true;
+    synchronized (this)
+    {
+      if (updaterunning)
+      {
+        restart = true;
+      }
+      else
+      {
+        updaterunning = true;
+      }
+      return restart;
+    }
   }
 
   public void draw(boolean showSequenceFeatures, boolean showAnnotation)
@@ -143,6 +156,7 @@ public class OverviewCanvas extends JComponent
     }
     else
     {
+      updaterunning = false;
       lastMiniMe = miniMe;
     }
   }