2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.datamodel;
21 import java.awt.Color;
24 * Holds all annotation values for a position in an AlignmentAnnotation row
29 public class Annotation
31 /** Character label - also shown below histogram */
32 public String displayCharacter = "";
35 * Text label for position: shown in mouse over and displayed on secondary
38 public String description = "";
41 * Secondary structure symbol: Protein symbols are H, E and S(?), RNA are
42 * WUSS/Vienna plus extended pseudoknot symbols
44 public char secondaryStructure = ' ';
46 /** Score for the position - used in histograms, line graphs and for shading */
49 /** Colour for position */
53 * Creates a new Annotation object.
64 public Annotation(String displayChar, String desc, char ss, float val)
66 displayCharacter = displayChar;
68 secondaryStructure = ss;
73 * Creates a new Annotation object.
86 public Annotation(String displayChar, String desc, char ss, float val,
89 this(displayChar, desc, ss, val);
94 * Copy constructor New annotation takes on the same (or duplicated)
95 * attributes as the given template
100 public Annotation(Annotation that)
102 if (that == null || this == that)
106 if (that.displayCharacter != null)
107 displayCharacter = new String(that.displayCharacter);
108 if (that.description != null)
109 description = new String(that.description);
110 secondaryStructure = that.secondaryStructure;
112 colour = that.colour;
116 * Value only annotation.
119 * value at this annotation position
121 public Annotation(float val)
123 this(null, null, ' ', val);
127 * human readable representation of an annotation row element.
129 * Format is 'display Char','secondary Structure
130 * Char',"description",score,[colourstring]
132 * fields may be missing if they are null, whitespace, or equivalent to
136 public String toString()
138 StringBuffer sb = new StringBuffer();
139 if (displayCharacter != null)
142 sb.append(displayCharacter);
148 if (secondaryStructure != 0
149 && !("" + displayCharacter).equals("" + secondaryStructure))
152 sb.append(secondaryStructure);
158 if (description != null && description.length() > 0)
161 sb.append(description);
167 if (value != Float.NaN)
178 sb.append(colour.getRed());
180 sb.append(colour.getGreen());
182 sb.append(colour.getBlue());
185 return sb.toString();