JAL-4199 Update gui handler for annotation tasks
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 4 Jul 2023 11:33:15 +0000 (13:33 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 12 Jul 2023 14:25:05 +0000 (16:25 +0200)
src/jalview/ws2/gui/AnnotationServiceGuiHandler.java

index 32bc4b1..a0f7a63 100644 (file)
@@ -2,10 +2,13 @@ package jalview.ws2.gui;
 
 import java.util.List;
 
+import jalview.api.FeatureColourI;
+import jalview.datamodel.features.FeatureMatcherSetI;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.IProgressIndicator;
 import jalview.gui.IProgressIndicatorHandler;
+import jalview.schemes.FeatureSettingsAdapter;
 import jalview.ws2.actions.annotation.AnnotationAction;
 import jalview.ws2.actions.annotation.AnnotationResult;
 import jalview.ws2.actions.api.JobI;
@@ -76,14 +79,37 @@ public class AnnotationServiceGuiHandler
   }
 
   @Override
-  public void taskCompleted(TaskI<AnnotationResult> source, AnnotationResult result)
+  public void taskCompleted(TaskI<AnnotationResult> source, final AnnotationResult result)
   {
     if (result == null)
       return;
-    if (result.getTransferFeatures() && alignFrame.alignPanel == alignPanel)
+    if (result.getTransferFeatures())
     {
-      alignFrame.getViewport().setShowSequenceFeatures(true);
-      alignFrame.setMenusForViewport();
+      alignFrame.getViewport().applyFeaturesStyle(new FeatureSettingsAdapter()
+      {
+        @Override
+        public FeatureColourI getFeatureColour(String type)
+        {
+          return result.getFeatureColours().get(type);
+        }
+
+        @Override
+        public FeatureMatcherSetI getFeatureFilters(String type)
+        {
+          return result.getFeatureFilters().get(type);
+        }
+
+        @Override
+        public boolean isFeatureDisplayed(String type)
+        {
+          return result.getFeatureColours().containsKey(type);
+        }
+      });
+      if (alignFrame.alignPanel == alignPanel)
+      {
+        alignFrame.getViewport().setShowSequenceFeatures(true);
+        alignFrame.setMenusForViewport();
+      }
     }
     alignPanel.adjustAnnotationHeight();
   }