2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.workers;
20 import java.util.List;
22 import jalview.api.AlignCalcManagerI;
23 import jalview.api.AlignCalcWorkerI;
24 import jalview.api.AlignViewportI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.AlignmentI;
30 * Base class for alignment calculation workers
35 public abstract class AlignCalcWorker implements AlignCalcWorkerI
38 * manager and data source for calculations
40 protected AlignViewportI alignViewport;
42 protected AlignCalcManagerI calcMan;
44 protected AlignmentViewPanel ap;
46 protected List<AlignmentAnnotation> ourAnnots = null;
48 public AlignCalcWorker(AlignViewportI alignViewport,
49 AlignmentViewPanel alignPanel)
51 this.alignViewport = alignViewport;
52 calcMan = alignViewport.getCalcManager();
56 protected void abortAndDestroy()
60 calcMan.workerComplete(this);
68 public boolean involves(AlignmentAnnotation i)
70 return ourAnnots != null && ourAnnots.contains(i);
74 * permanently remove from the alignment all annotation rows managed by this
78 public void removeOurAnnotation()
80 if (ourAnnots != null && alignViewport != null)
82 AlignmentI alignment = alignViewport.getAlignment();
83 synchronized (ourAnnots)
85 for (AlignmentAnnotation aa : ourAnnots)
87 alignment.deleteAnnotation(aa, true);
92 // TODO: allow GUI to query workers associated with annotation to add items to
93 // annotation label panel popup menu