updatingConsensus, updatingConservation is static - only one thread can run the calcu...
authoramwaterhouse <Andrew Waterhouse>
Fri, 27 Oct 2006 16:43:54 +0000 (16:43 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 27 Oct 2006 16:43:54 +0000 (16:43 +0000)
src/jalview/gui/AlignViewport.java

index efce038..36f69a5 100755 (executable)
@@ -264,6 +264,21 @@ public class AlignViewport
       {
         try
         {
+          while (updatingConservation)
+          {
+            try
+            {
+              Thread.sleep(200);
+            }
+            catch (Exception ex)
+            {
+              ex.printStackTrace();
+            }
+          }
+
+          updatingConservation = true;
+
+
           int alWidth = alignment.getWidth();
           if(alWidth<0)
             return;
@@ -381,15 +396,15 @@ public class AlignViewport
     }
 
 
-    static ConservationThread conservationThread;
+    ConservationThread conservationThread;
 
-    static ConsensusThread consensusThread;
+    ConsensusThread consensusThread;
 
     boolean consUpdateNeeded = false;
 
-    boolean updatingConsensus = false;
+    static boolean updatingConsensus = false;
 
-    boolean updatingConservation = false;
+    static boolean updatingConservation = false;
 
     /**
      * DOCUMENT ME!
@@ -399,21 +414,8 @@ public class AlignViewport
       if (alignment.isNucleotide() || conservation==null)
         return;
 
-      updatingConservation = true;
-    // javax.swing.SwingUtilities.invokeLater(new Runnable()      {        public void run()  {
-          while (conservationThread != null && conservationThread.isAlive())
-          {
-            try
-            {
-           //   Thread.sleep(100);
-              ap.repaint();
-            }
-            catch (Exception ex)
-            {}
-          }
-          conservationThread = new ConservationThread(ap);
-          conservationThread.start();
-      //  }      });
+      conservationThread = new ConservationThread(ap);
+      conservationThread.start();
     }
 
     /**
@@ -421,22 +423,8 @@ public class AlignViewport
      */
     public void updateConsensus(final AlignmentPanel ap)
     {
-      updatingConsensus = true;
-
-     // javax.swing.SwingUtilities.invokeLater(new Runnable()      {        public void run()   {
-          while (consensusThread != null && consensusThread.isAlive())
-          {
-            try
-            {
-          //    Thread.sleep(100);
-              ap.repaint();
-            }
-            catch (Exception ex)
-            {}
-          }
-          consensusThread = new ConsensusThread(ap);
-          consensusThread.start();
-      //  }      });
+      consensusThread = new ConsensusThread(ap);
+      consensusThread.start();
     }
 
 
@@ -449,6 +437,20 @@ public class AlignViewport
       }
       public void run()
       {
+        while (updatingConsensus)
+        {
+          try
+          {
+            Thread.sleep(200);
+          }
+          catch (Exception ex)
+          {
+            ex.printStackTrace();
+          }
+        }
+
+        updatingConsensus = true;
+
         try
         {
           int aWidth = alignment.getWidth();
@@ -1510,6 +1512,7 @@ public class AlignViewport
         resetAllColourSchemes();
 
         alignment.adjustSequenceAnnotations();
+
     }