JAL-3878 Add getCalcName to AlignCalcWorkerI.
[jalview.git] / src / jalview / workers / InformationThread.java
index d719189..dae4ef2 100644 (file)
@@ -37,6 +37,12 @@ public class InformationThread extends AlignCalcWorker
     super(alignViewport, alignPanel);
   }
 
+  @Override
+  public String getCalcName()
+  {
+    return "Information";
+  }
+
   /**
    * Recomputes Information annotations for any HMM consensus sequences (for
    * alignment and/or groups)
@@ -48,73 +54,34 @@ public class InformationThread extends AlignCalcWorker
     {
       return;
     }
-    if (calcMan.isPending(this))
+    if (alignViewport.isClosed())
     {
+      abortAndDestroy();
       return;
     }
-    calcMan.notifyStart(this);
-    // long started = System.currentTimeMillis();
 
-    try
+    AlignmentI alignment = alignViewport.getAlignment();
+    int aWidth = alignment == null ? -1 : alignment.getWidth();
+    if (aWidth < 0)
     {
-      if (calcMan.isPending(this))
-      {
-        // another instance of this is waiting to run
-        calcMan.workerComplete(this);
-        return;
-      }
-      while (!calcMan.notifyWorking(this))
-      {
-        // another thread in progress, wait my turn
-        try
-        {
-          if (ap != null)
-          {
-            ap.paintAlignment(false, false);
-          }
-          Thread.sleep(200);
-        } catch (Exception ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-      if (alignViewport.isClosed())
-      {
-        abortAndDestroy();
-        return;
-      }
-
-      AlignmentI alignment = alignViewport.getAlignment();
-      int aWidth = alignment == null ? -1 : alignment.getWidth();
-      if (aWidth < 0)
-      {
-        calcMan.workerComplete(this);
-        return;
-      }
+      return;
+    }
 
-      /*
-       * compute information profiles for any HMM consensus sequences
-       * for the alignment or sub-groups
-       */
-      computeProfiles(alignment);
+    /*
+     * compute information profiles for any HMM consensus sequences
+     * for the alignment or sub-groups
+     */
+    computeProfiles(alignment);
 
-      /*
-       * construct the corresponding annotations
-       */
-      updateAnnotation();
+    /*
+     * construct the corresponding annotations
+     */
+    updateAnnotation();
 
-      if (ap != null)
-      {
-        ap.adjustAnnotationHeight();
-        ap.paintAlignment(true, true);
-      }
-    } catch (OutOfMemoryError error)
+    if (ap != null)
     {
-      calcMan.disableWorker(this);
-      ap.raiseOOMWarning("calculating information", error);
-    } finally
-    {
-      calcMan.workerComplete(this);
+      ap.adjustAnnotationHeight();
+      ap.paintAlignment(true, true);
     }
   }
 
@@ -178,7 +145,7 @@ public class InformationThread extends AlignCalcWorker
    */
   protected AlignmentAnnotation getGapAnnotation()
   {
-    return alignViewport.getOccupancyAnnotation();
+               return alignViewport.getAlignmentGapAnnotation();
   }
 
   /**
@@ -212,10 +179,13 @@ public class InformationThread extends AlignCalcWorker
     for (SequenceGroup group : alignment.getGroups())
     {
       hmmSeqs = group.getHmmSequences();
-      ProfilesI profiles = group.getHmmProfiles();
-      float m = updateInformationAnnotation(hmmSeqs.get(0), profiles, group,
-              infos);
-      maxInformation = Math.max(maxInformation, m);
+      if (!hmmSeqs.isEmpty())
+      {
+        ProfilesI profiles = group.getHmmProfiles();
+        float m = updateInformationAnnotation(hmmSeqs.get(0), profiles,
+                group, infos);
+        maxInformation = Math.max(maxInformation, m);
+      }
     }
 
     /*