AlignmentAnnotation: added annotation score attribute and allowed for annotation...
[jalview.git] / src / jalview / gui / Jalview2XML.java
index eda5eac..f0551e8 100755 (executable)
@@ -530,32 +530,40 @@ public class Jalview2XML
         }
 
         an.setLabel(aa[i].label);
-
+        if (aa[i].hasScore())
+        {
+          an.setScore(aa[i].getScore());
+        }
         AnnotationElement ae;
-
-        for (int a = 0; a < aa[i].annotations.length; a++)
+        if (aa[i].annotations!=null)
         {
-          if ( (aa[i] == null) || (aa[i].annotations[a] == null))
+          an.setScoreOnly(false);
+          for (int a = 0; a < aa[i].annotations.length; a++)
           {
-            continue;
-          }
+            if ((aa[i] == null) || (aa[i].annotations[a] == null))
+            {
+              continue;
+            }
 
-          ae = new AnnotationElement();
-          ae.setDescription(aa[i].annotations[a].description);
-          ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);
-          ae.setValue(aa[i].annotations[a].value);
-          ae.setPosition(a);
-          ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure +
-                                   "");
+            ae = new AnnotationElement();
+            ae.setDescription(aa[i].annotations[a].description);
+            ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);
+            ae.setValue(aa[i].annotations[a].value);
+            ae.setPosition(a);
+            ae
+                    .setSecondaryStructure(aa[i].annotations[a].secondaryStructure
+                            + "");
 
-          if (aa[i].annotations[a].colour != java.awt.Color.black)
-          {
-            ae.setColour(aa[i].annotations[a].colour.getRGB());
-          }
+            if (aa[i].annotations[a].colour != java.awt.Color.black)
+            {
+              ae.setColour(aa[i].annotations[a].colour.getRGB());
+            }
 
-          an.addAnnotationElement(ae);
+            an.addAnnotationElement(ae);
+          }
+        } else {
+          an.setScoreOnly(true);
         }
-
         vamsasSet.addAnnotation(an);
       }
     }
@@ -1310,21 +1318,24 @@ public class Jalview2XML
         }
 
         AnnotationElement[] ae = an[i].getAnnotationElement();
-        jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[
-            al.getWidth()];
+        jalview.datamodel.Annotation[] anot = null;
+        if (!an[i].getScoreOnly())
+        { 
+          anot = new jalview.datamodel.Annotation[
+                    al.getWidth()];
 
-        for (int aa = 0; aa < ae.length && aa < anot.length; aa++)
-        {
-          anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa].
-              getDisplayCharacter(),
-              ae[aa].getDescription(),
-              ae[aa].getSecondaryStructure().length() == 0 ? ' ' :
-              ae[aa].getSecondaryStructure().charAt(0),
-                   ae[aa].getValue());
-          anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa].
-              getColour());
+          for (int aa = 0; aa < ae.length && aa < anot.length; aa++)
+          {
+            anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa].
+                    getDisplayCharacter(),
+                    ae[aa].getDescription(),
+                    ae[aa].getSecondaryStructure().length() == 0 ? ' ' :
+                      ae[aa].getSecondaryStructure().charAt(0),
+                      ae[aa].getValue());
+            anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa].
+                    getColour());
+          }
         }
-
         jalview.datamodel.AlignmentAnnotation jaa = null;
 
         if (an[i].getGraph())
@@ -1365,7 +1376,10 @@ public class Jalview2XML
               );
           al.findName(an[i].getSequenceRef()).addAlignmentAnnotation(jaa);
         }
-
+        if (an[i].hasScore())
+        {
+          jaa.setScore(an[i].getScore());
+        }
         al.addAnnotation(jaa);
       }
     }