JAL-961 JAL-975 extend api to support removal of workers no-longer required by the...
[jalview.git] / src / jalview / workers / AlignCalcWorker.java
index 19a92fb..f1b3019 100644 (file)
@@ -10,6 +10,7 @@ import jalview.api.AlignCalcWorkerI;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
 
 /**
  * Base class for alignment calculation workers 
@@ -47,7 +48,24 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI
   {
     return ourAnnots!=null && ourAnnots.contains(i);
   }
-  
+
+  /**
+   * permanently remove from the alignment all annotation rows managed by this worker
+   */
+  @Override
+  public void removeOurAnnotation()
+  {
+    if (ourAnnots!=null && alignViewport!=null)
+    {
+      AlignmentI alignment=alignViewport.getAlignment();
+      synchronized (ourAnnots) {
+        for (AlignmentAnnotation aa:ourAnnots)
+        {
+          alignment.deleteAnnotation(aa, true);
+        }
+      }
+    }
+  }
   // TODO: allow GUI to query workers associated with annotation to add items to annotation label panel popup menu
 
 }