/** * */ package jalview.workers; import java.util.List; import jalview.api.AlignCalcManagerI; 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 * @author jimp * */ public abstract class AlignCalcWorker implements AlignCalcWorkerI { /** * manager and data source for calculations */ protected AlignViewportI alignViewport; protected AlignCalcManagerI calcMan; protected AlignmentViewPanel ap; protected List ourAnnots=null; public AlignCalcWorker(AlignViewportI alignViewport, AlignmentViewPanel alignPanel) { this.alignViewport = alignViewport; calcMan=alignViewport.getCalcManager(); ap = alignPanel; } protected void abortAndDestroy() { if (calcMan!=null) { calcMan.workerComplete(this); } alignViewport=null; calcMan=null; ap=null; } public boolean involves(AlignmentAnnotation i) { 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 }