JAL - 3690 AlignCalc rebuilt - FutureTask-based manager
[jalview.git] / src / jalview / workers / AnnotationWorker.java
index 8f37f15..98e26b3 100644 (file)
@@ -59,63 +59,41 @@ class AnnotationWorker extends AlignCalcWorker
   @Override
   public void run()
   {
-    try
+    if (alignViewport.isClosed())
     {
-      calcMan.notifyStart(this);
-
-      while (!calcMan.notifyWorking(this))
-      {
-        try
-        {
-          Thread.sleep(200);
-        } catch (InterruptedException ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-      if (alignViewport.isClosed())
-      {
-        abortAndDestroy();
-        return;
-      }
+      abortAndDestroy();
+      return;
+    }
 
-      // removeAnnotation();
+    // removeAnnotation();
       AlignmentI alignment = alignViewport.getAlignment();
-      if (alignment != null)
+    if (alignment != null)
+    {
+      try
       {
-        try
+        List<AlignmentAnnotation> anns = counter.calculateAnnotation(
+                alignment, new FeatureRenderer(alignViewport));
+        for (AlignmentAnnotation ann : anns)
         {
-          List<AlignmentAnnotation> anns = counter.calculateAnnotation(
-                  alignment, new FeatureRenderer(alignViewport));
-          for (AlignmentAnnotation ann : anns)
+          AlignmentAnnotation theAnn = alignment.findOrCreateAnnotation(
+                  ann.label, ann.description, false, null, null);
+          theAnn.showAllColLabels = true;
+          theAnn.graph = AlignmentAnnotation.BAR_GRAPH;
+          theAnn.scaleColLabel = true;
+          theAnn.annotations = ann.annotations;
+          setGraphMinMax(theAnn, theAnn.annotations);
+          theAnn.validateRangeAndDisplay();
+          if (!ourAnnots.contains(theAnn))
           {
-            AlignmentAnnotation theAnn = alignment.findOrCreateAnnotation(
-                    ann.label, ann.description, false, null, null);
-            theAnn.showAllColLabels = true;
-            theAnn.graph = AlignmentAnnotation.BAR_GRAPH;
-            theAnn.scaleColLabel = true;
-            theAnn.annotations = ann.annotations;
-            setGraphMinMax(theAnn, theAnn.annotations);
-            theAnn.validateRangeAndDisplay();
-            if (!ourAnnots.contains(theAnn))
-            {
-              ourAnnots.add(theAnn);
-            }
-            // alignment.addAnnotation(ann);
+            ourAnnots.add(theAnn);
           }
-        } catch (IndexOutOfBoundsException x)
-        {
-          // probable race condition. just finish and return without any fuss.
-          return;
+          // alignment.addAnnotation(ann);
         }
+      } catch (IndexOutOfBoundsException x)
+      {
+        // probable race condition. just finish and return without any fuss.
+        return;
       }
-    } catch (OutOfMemoryError error)
-    {
-      ap.raiseOOMWarning("calculating annotations", error);
-      calcMan.disableWorker(this);
-    } finally
-    {
-      calcMan.workerComplete(this);
     }
 
     if (ap != null)