JAL-1136 Ensure asynchronously calculated autoannotation is also added to the alignme...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 3 Aug 2012 16:53:41 +0000 (17:53 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 3 Aug 2012 16:53:41 +0000 (17:53 +0100)
src/jalview/gui/Jalview2XML.java

index 7fb7f0b..ea5d5a7 100644 (file)
@@ -3413,22 +3413,25 @@ public class Jalview2XML
       // work through any autoCalculated annotation already on the view
       // removing it if it should be placed in a different location on the
       // annotation panel.
+      List<String> remains=new ArrayList(visan.keySet());
       for (int h = 0; h < hSize; h++)
       {
         jalview.datamodel.AlignmentAnnotation jalan = al
                 .getAlignmentAnnotation()[h];
         if (jalan.autoCalculated)
         {
-          JvAnnotRow valan = visan.get(jalan.label);
+          String k;
+          JvAnnotRow valan = visan.get(k=jalan.label);
           if (jalan.getCalcId()!=null)
           {
-            valan = visan.get(jalan.label+ "\t"+jalan.getCalcId());
+            valan = visan.get(k=jalan.label+ "\t"+jalan.getCalcId());
           }
           
           if (valan != null)
           {
             // delete the auto calculated row from the alignment
             al.deleteAnnotation(jalan, false);
+            remains.remove(k);
             hSize--;
             h--;
             if (valan != nullAnnot)
@@ -3450,6 +3453,16 @@ public class Jalview2XML
           }
         }
       }
+      // Add any (possibly stale) autocalculated rows that were not appended to the view during construction
+      for (String other:remains)
+      {
+        JvAnnotRow othera=visan.get(other);
+        if (othera!=nullAnnot && othera.template.getCalcId()!=null && othera.template.getCalcId().length()>0)
+        {
+          reorder.add(othera);
+        }
+      }
+      // now put the automatic annotation in its correct place
       int s = 0, srt[] = new int[reorder.size()];
       JvAnnotRow[] rws = new JvAnnotRow[reorder.size()];
       for (JvAnnotRow jvar : reorder)