1 package jalview.ws2.gui;
3 import jalview.api.FeatureColourI;
4 import jalview.datamodel.features.FeatureMatcherSetI;
5 import jalview.gui.AlignFrame;
6 import jalview.gui.AlignmentPanel;
7 import jalview.gui.IProgressIndicator;
8 import jalview.gui.IProgressIndicatorHandler;
9 import jalview.schemes.FeatureSettingsAdapter;
10 import jalview.util.MathUtils;
11 import jalview.ws2.actions.annotation.AlignCalcWorkerAdapter;
12 import jalview.ws2.actions.annotation.AnnotationAction;
13 import jalview.ws2.actions.annotation.AnnotationResult;
15 public class AnnotationServiceGuiHandler
16 implements AlignCalcWorkerAdapter.WorkerListener
18 private final long progressId = MathUtils.getUID();
20 private final AlignFrame alignFrame;
22 private final AlignmentPanel alignPanel;
24 private final IProgressIndicator progressIndicator;
26 private final AnnotationAction action;
28 public AnnotationServiceGuiHandler(AnnotationAction action, AlignFrame frame)
30 this.alignFrame = frame;
31 this.alignPanel = frame.alignPanel;
32 this.progressIndicator = frame;
37 public void workerStarted(AlignCalcWorkerAdapter source)
39 progressIndicator.addProgressBar(progressId, action.getFullName());
40 progressIndicator.registerHandler(progressId,
41 new IProgressIndicatorHandler()
44 public boolean cancelActivity(long id)
51 public boolean canCancel()
59 public void workerStopped(AlignCalcWorkerAdapter source)
61 progressIndicator.removeProgressBar(progressId);
65 public void workerHasResult(AlignCalcWorkerAdapter source, final AnnotationResult result)
69 if (result.getTransferFeatures())
71 alignFrame.getViewport().applyFeaturesStyle(new FeatureSettingsAdapter()
74 public FeatureColourI getFeatureColour(String type)
76 return result.getFeatureColours().get(type);
80 public FeatureMatcherSetI getFeatureFilters(String type)
82 return result.getFeatureFilters().get(type);
86 public boolean isFeatureDisplayed(String type)
88 return result.getFeatureColours().containsKey(type);
91 if (alignFrame.alignPanel == alignPanel)
93 alignFrame.getViewport().setShowSequenceFeatures(true);
94 alignFrame.setMenusForViewport();
97 alignPanel.adjustAnnotationHeight();