| 1 |
|
package jalview.ws2.gui; |
| 2 |
|
|
| 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; |
| 14 |
|
|
| |
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 12 |
Complexity Density: 0.57 |
|
| 15 |
|
public class AnnotationServiceGuiHandler |
| 16 |
|
implements AlignCalcWorkerAdapter.WorkerListener |
| 17 |
|
{ |
| 18 |
|
private final long progressId = MathUtils.getUID(); |
| 19 |
|
|
| 20 |
|
private final AlignFrame alignFrame; |
| 21 |
|
|
| 22 |
|
private final AlignmentPanel alignPanel; |
| 23 |
|
|
| 24 |
|
private final IProgressIndicator progressIndicator; |
| 25 |
|
|
| 26 |
|
private final AnnotationAction action; |
| 27 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 28 |
0 |
public AnnotationServiceGuiHandler(AnnotationAction action, AlignFrame frame)... |
| 29 |
|
{ |
| 30 |
0 |
this.alignFrame = frame; |
| 31 |
0 |
this.alignPanel = frame.alignPanel; |
| 32 |
0 |
this.progressIndicator = frame; |
| 33 |
0 |
this.action = action; |
| 34 |
|
} |
| 35 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 36 |
0 |
@Override... |
| 37 |
|
public void workerStarted(AlignCalcWorkerAdapter source) |
| 38 |
|
{ |
| 39 |
0 |
progressIndicator.addProgressBar(progressId, action.getFullName()); |
| 40 |
0 |
progressIndicator.registerHandler(progressId, |
| 41 |
|
new IProgressIndicatorHandler() |
| 42 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 43 |
0 |
@Override... |
| 44 |
|
public boolean cancelActivity(long id) |
| 45 |
|
{ |
| 46 |
0 |
source.cancel(); |
| 47 |
0 |
return true; |
| 48 |
|
} |
| 49 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
0 |
@Override... |
| 51 |
|
public boolean canCancel() |
| 52 |
|
{ |
| 53 |
0 |
return true; |
| 54 |
|
} |
| 55 |
|
}); |
| 56 |
|
} |
| 57 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
0 |
@Override... |
| 59 |
|
public void workerStopped(AlignCalcWorkerAdapter source) |
| 60 |
|
{ |
| 61 |
0 |
progressIndicator.removeProgressBar(progressId); |
| 62 |
|
} |
| 63 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 64 |
0 |
@Override... |
| 65 |
|
public void workerHasResult(AlignCalcWorkerAdapter source, final AnnotationResult result) |
| 66 |
|
{ |
| 67 |
0 |
if (result == null) |
| 68 |
0 |
return; |
| 69 |
0 |
if (result.getHasFeatures()) |
| 70 |
|
{ |
| 71 |
0 |
alignFrame.getViewport().applyFeaturesStyle(new FeatureSettingsAdapter() |
| 72 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 73 |
0 |
@Override... |
| 74 |
|
public FeatureColourI getFeatureColour(String type) |
| 75 |
|
{ |
| 76 |
0 |
return result.getFeatureColours().get(type); |
| 77 |
|
} |
| 78 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 79 |
0 |
@Override... |
| 80 |
|
public FeatureMatcherSetI getFeatureFilters(String type) |
| 81 |
|
{ |
| 82 |
0 |
return result.getFeatureFilters().get(type); |
| 83 |
|
} |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 85 |
0 |
@Override... |
| 86 |
|
public boolean isFeatureDisplayed(String type) |
| 87 |
|
{ |
| 88 |
0 |
return result.getFeatureColours().containsKey(type); |
| 89 |
|
} |
| 90 |
|
}); |
| 91 |
0 |
if (alignFrame.alignPanel == alignPanel) |
| 92 |
|
{ |
| 93 |
0 |
alignFrame.getViewport().setShowSequenceFeatures(true); |
| 94 |
0 |
alignFrame.setMenusForViewport(); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
0 |
alignPanel.adjustAnnotationHeight(); |
| 98 |
|
} |
| 99 |
|
} |