attempt to make fastPaint method thread safe
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index 149f432..07841d2 100755 (executable)
@@ -71,10 +71,7 @@ public class AnnotationPanel
   public AnnotationPanel(AlignmentPanel ap)
   {
 
-    if (System.getProperty("os.name").startsWith("Mac"))
-    {
-      MAC = true;
-    }
+    MAC = new jalview.util.Platform().isAMac();
 
     ToolTipManager.sharedInstance().registerComponent(this);
     ToolTipManager.sharedInstance().setInitialDelay(0);
@@ -611,25 +608,30 @@ public class AnnotationPanel
     drawComponent(gg, av.startRes, av.endRes + 1);
     g.drawImage(image, 0, 0, this);
   }
-
+  boolean fpainting=false;
   /**
-   * DOCUMENT ME!
+   * Thread safe repaint
    *
-   * @param horizontal DOCUMENT ME!
+   * @param horizontal repaint with horizontal shift in alignment
    */
   public void fastPaint(int horizontal)
   {
+    
+    if (fpainting)
+      return;
+    fpainting=true;
+
     if ( (horizontal == 0)
         || gg == null
         || av.alignment.getAlignmentAnnotation() == null
         || av.alignment.getAlignmentAnnotation().length < 1
         || av.updatingConsensus
-        || av.updatingConservation)
+        || av.updatingConservation
+        ) // || fpainting)
     {
       repaint();
       return;
     }
-
     gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0);
 
     int sr = av.startRes;
@@ -653,9 +655,8 @@ public class AnnotationPanel
     gg.translate( -transX, 0);
 
     fastPaint = true;
-
     repaint();
-
+    fpainting=false;
   }
 
   /**