JAL-3878 Add getCalcName to AlignCalcWorkerI.
[jalview.git] / src / jalview / workers / ColumnCounterSetWorker.java
index 2422748..6054ad5 100644 (file)
@@ -57,11 +57,17 @@ class ColumnCounterSetWorker extends AlignCalcWorker
           AlignmentViewPanel panel, FeatureSetCounterI counter)
   {
     super(viewport, panel);
-    ourAnnots = new ArrayList<AlignmentAnnotation>();
+    ourAnnots = new ArrayList<>();
     this.counter = counter;
     calcMan.registerWorker(this);
   }
 
+  @Override
+  public String getCalcName()
+  {
+    return "Column Counter Set";
+  }
+
   /**
    * method called under control of AlignCalcManager to recompute the annotation
    * when the alignment changes
@@ -70,44 +76,22 @@ class ColumnCounterSetWorker extends AlignCalcWorker
   public void run()
   {
     boolean annotationAdded = false;
-    try
+    if (alignViewport.isClosed())
     {
-      calcMan.notifyStart(this);
+      abortAndDestroy();
+      return;
+    }
 
-      while (!calcMan.notifyWorking(this))
+    if (alignViewport.getAlignment() != null)
+    {
+      try
       {
-        try
-        {
-          Thread.sleep(200);
-        } catch (InterruptedException ex)
-        {
-          ex.printStackTrace();
-        }
-      }
-      if (alignViewport.isClosed())
+        annotationAdded = computeAnnotations();
+      } catch (IndexOutOfBoundsException x)
       {
-        abortAndDestroy();
+        // probable race condition. just finish and return without any fuss.
         return;
       }
-
-      if (alignViewport.getAlignment() != null)
-      {
-        try
-        {
-          annotationAdded = computeAnnotations();
-        } catch (IndexOutOfBoundsException x)
-        {
-          // probable race condition. just finish and return without any fuss.
-          return;
-        }
-      }
-    } catch (OutOfMemoryError error)
-    {
-      ap.raiseOOMWarning("calculating feature counts", error);
-      calcMan.disableWorker(this);
-    } finally
-    {
-      calcMan.workerComplete(this);
     }
 
     if (ap != null)
@@ -116,7 +100,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker
       {
         ap.adjustAnnotationHeight();
       }
-      ap.paintAlignment(true);
+      ap.paintAlignment(true, true);
     }
 
   }
@@ -229,6 +213,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker
    * 
    * @param alignment
    * @param col
+   *          (0..)
    * @param row
    * @param fr
    */
@@ -249,14 +234,12 @@ class ColumnCounterSetWorker extends AlignCalcWorker
     {
       return null;
     }
-    int pos = seq.findPosition(col);
 
     /*
      * compute a count for any displayed features at residue
      */
-    // NB have to adjust pos if using AlignmentView.getVisibleAlignment
     // see JAL-2075
-    List<SequenceFeature> features = fr.findFeaturesAtRes(seq, pos);
+    List<SequenceFeature> features = fr.findFeaturesAtColumn(seq, col + 1);
     int[] count = this.counter.count(String.valueOf(res), features);
     return count;
   }