JAL-1136 JAL-811 JAL-812 store/recover autocalc alignment annotation based on calcId...
[jalview.git] / src / jalview / gui / Jalview2XML.java
index 4c042b3..7fb7f0b 100644 (file)
@@ -3367,7 +3367,16 @@ public class Jalview2XML
                 );
       }
     }
-
+    if (view.getCalcIdParam()!=null)
+    {
+      for (CalcIdParam calcIdParam:view.getCalcIdParam())
+      {
+        if (recoverCalcIdParam(calcIdParam, af.viewport)) {
+        } else {
+          warn("Couldn't recover parameters for "+calcIdParam.getCalcId());
+        }
+      }
+    }
     af.setMenusFromViewport(af.viewport);
     // TODO: we don't need to do this if the viewport is aready visible.
     Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
@@ -3397,10 +3406,13 @@ public class Jalview2XML
       }
       for (JvAnnotRow auan : autoAlan)
       {
-        visan.put(auan.template.label, auan);
+        visan.put(auan.template.label+(auan.template.getCalcId()==null ? "" : "\t"+auan.template.getCalcId()), auan);
       }
       int hSize = al.getAlignmentAnnotation().length;
       ArrayList<JvAnnotRow> reorder = new ArrayList<JvAnnotRow>();
+      // work through any autoCalculated annotation already on the view
+      // removing it if it should be placed in a different location on the
+      // annotation panel.
       for (int h = 0; h < hSize; h++)
       {
         jalview.datamodel.AlignmentAnnotation jalan = al
@@ -3408,10 +3420,15 @@ public class Jalview2XML
         if (jalan.autoCalculated)
         {
           JvAnnotRow valan = visan.get(jalan.label);
+          if (jalan.getCalcId()!=null)
+          {
+            valan = visan.get(jalan.label+ "\t"+jalan.getCalcId());
+          }
+          
           if (valan != null)
           {
             // delete the auto calculated row from the alignment
-            al.deleteAnnotation(al.getAlignmentAnnotation()[h], false);
+            al.deleteAnnotation(jalan, false);
             hSize--;
             h--;
             if (valan != nullAnnot)