From 788b7b7980d3de31579a9081bd0b3043b08d7a26 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 22 May 2013 17:45:29 +0100 Subject: [PATCH] JAL-1297 JAL-1295 JAL-1294 sensible toString for benefit of annotation IO test --- src/jalview/datamodel/Annotation.java | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/jalview/datamodel/Annotation.java b/src/jalview/datamodel/Annotation.java index 73611bd..b7a83a5 100755 --- a/src/jalview/datamodel/Annotation.java +++ b/src/jalview/datamodel/Annotation.java @@ -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(); + } } -- 1.7.10.2