/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.api;
+import java.util.concurrent.Callable;
+
import jalview.datamodel.AlignmentAnnotation;
-public interface AlignCalcWorkerI extends Runnable
+/**
+ * Interface describing a worker that calculates alignment annotation(s). The
+ * main (re-)calculation should be performed by the inherited run() method.
+ */
+public interface AlignCalcWorkerI extends Callable<Void>
{
+ /**
+ * Answers true if this worker updates the given annotation (regardless of its
+ * current state)
+ *
+ * @param annot
+ * @return
+ */
+ boolean involves(AlignmentAnnotation annot);
- public boolean involves(AlignmentAnnotation annot);
-
- public void updateAnnotation();
+ /**
+ * Updates the display of calculated annotation values (does not recalculate
+ * the values). This allows a quick redraw of annotations when display
+ * settings are changed.
+ */
+ void updateAnnotation();
- void removeOurAnnotation();
+ /**
+ * Removes any annotation(s) managed by this worker from the alignment
+ */
+ void removeAnnotation();
+
+
+ /**
+ * Default implementation of call which calls run and propagates the
+ * exception.
+ */
+ @Override
+ public default Void call() throws Exception
+ {
+ run();
+ return null;
+ }
+
+ /**
+ * The main calculation happens here
+ */
+ public void run() throws Exception;
+
+ /**
+ * Answers true if the worker should be deleted entirely when its annotation
+ * is deleted from the display, or false if it should continue to run. Some
+ * workers are required to run for their side-effects.
+ *
+ * @return
+ */
+ boolean isDeletable();
}