JAL-1297 JAL-1295 JAL-1294 sensible toString for benefit of annotation IO test
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Wed, 22 May 2013 16:45:29 +0000 (17:45 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 24 May 2013 14:10:55 +0000 (15:10 +0100)
src/jalview/datamodel/Annotation.java

index 73611bd..b7a83a5 100755 (executable)
@@ -117,4 +117,57 @@ public class Annotation
   {
     this(null, null, ' ', val);
   }
+
+  @Override
+  public String toString()
+  {
+    StringBuffer sb = new StringBuffer();
+    if (displayCharacter != null)
+    {
+      sb.append("\'");
+      sb.append(displayCharacter);
+      sb.append("\'");
+    }
+    {
+      sb.append(",");
+    }
+    if (secondaryStructure != 0
+            && !("" + displayCharacter).equals("" + secondaryStructure))
+    {
+      sb.append("\'");
+      sb.append(secondaryStructure);
+      sb.append("\'");
+    }
+    {
+      sb.append(",");
+    }
+    if (description != null && description.length() > 0)
+    {
+      sb.append("\"");
+      sb.append(description);
+      sb.append("\"");
+    }
+    {
+      sb.append(",");
+    }
+    if (value != Float.NaN)
+    {
+      sb.append(value);
+    }
+    if (colour != null)
+    {
+      if (sb.length() > 0)
+      {
+        sb.append(",");
+      }
+      sb.append("[");
+      sb.append(colour.getRed());
+      sb.append(",");
+      sb.append(colour.getGreen());
+      sb.append(",");
+      sb.append(colour.getBlue());
+      sb.append("]");
+    }
+    return sb.toString();
+  }
 }