+
+ /**
+ * Copy constructor New annotation takes on the same (or duplicated)
+ * attributes as the given template
+ *
+ * @param that
+ * template annotation
+ */
+ public Annotation(Annotation that)
+ {
+ if (that == null || this == that)
+ {
+ return;
+ }
+ if (that.displayCharacter != null)
+ {
+ displayCharacter = new String(that.displayCharacter);
+ }
+ if (that.description != null)
+ {
+ description = new String(that.description);
+ }
+ secondaryStructure = that.secondaryStructure;
+ value = that.value;
+ colour = that.colour;
+
+ }
+
+ /**
+ * Value only annotation.
+ *
+ * @param val
+ * value at this annotation position
+ */
+ public Annotation(float val)
+ {
+ this(null, null, ' ', val, null);
+ }
+
+ /**
+ * human readable representation of an annotation row element.
+ *
+ * Format is 'display Char','secondary Structure
+ * Char',"description",score,[colourstring]
+ *
+ * fields may be missing if they are null, whitespace, or equivalent to
+ * Float.NaN
+ */
+ @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 (!Float.isNaN(value))
+ {
+ 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();
+ }