JAL-976 clean out associated annotation
[jalview.git] / src / jalview / ws / jws2 / AAConsClient.java
index f6c3fcf..d1bf303 100644 (file)
@@ -4,6 +4,8 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
 import jalview.gui.AlignFrame;
+import jalview.gui.AlignmentPanel;
+import jalview.ws.jws2.dm.AAConsSettings;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
 
@@ -28,8 +30,18 @@ public class AAConsClient extends JabawsAlignCalcWorker
     nucleotidesAllowed = false;
     proteinAllowed = true;
     gapMap=new boolean[0];
+    initViewportParams();
   }
 
+  protected void initViewportParams()
+  {
+    ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(getCalcId(), new AAConsSettings(true, service, this.preset, (arguments!=null) ?  JabaParamStore.getJwsArgsfromJaba(arguments) : null), true);
+  }
+  @Override
+  public void updateParameters(WsParamSetI newpreset, java.util.List<Argument> newarguments) {
+    super.updateParameters(newpreset, newarguments);
+    initViewportParams();
+  };
   public String getServiceActionText()
   {
     return "calculating Amino acid consensus using AACons service";
@@ -42,11 +54,9 @@ public class AAConsClient extends JabawsAlignCalcWorker
 
   public void updateResultAnnotation(boolean immediate)
   {
-
     if (immediate || !calcMan.isWorking(this) && scoremanager != null)
     {
       AlignmentAnnotation annotation;
-      ;
       Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
       int alWidth = alignViewport.getAlignment().getWidth();
       AlignmentI alignment;
@@ -73,7 +83,10 @@ public class AAConsClient extends JabawsAlignCalcWorker
           else
           {
             // simple annotation row
-            annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
+            annotation = alignViewport.getAlignment()
+                    .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
+                            null, null);
+
             Annotation[] elm = new Annotation[alWidth];
             if (alWidth == gapMap.length) // scr.getScores().size())
             {
@@ -156,4 +169,20 @@ public class AAConsClient extends JabawsAlignCalcWorker
     }
   }
 
+  public String getCalcId()
+  {
+    return SequenceAnnotationWSClient.AAConsCalcId;
+  }
+
+  public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
+  {
+    for (AlignmentAnnotation aa: alignPanel.getAlignment().findAnnotation(SequenceAnnotationWSClient.AAConsCalcId))
+    {
+      alignPanel.getAlignment().deleteAnnotation(aa);
+    }
+    // List<AlignmentAnnotation>
+    // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.)
+    // TODO Auto-generated method stub
+
+  }
 }