2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import java.awt.Color;
26 * Holds all annotation values for a position in an AlignmentAnnotation row
31 public class Annotation
33 /** Character label - also shown below histogram */
34 public String displayCharacter = "";
37 * Text label for position: shown in mouse over and displayed on secondary
40 public String description = "";
43 * Secondary structure symbol: Protein symbols are H, E and S(?), RNA are
44 * WUSS/Vienna plus extended pseudoknot symbols
46 public char secondaryStructure = ' ';
48 /** Score for the position - used in histograms, line graphs and for shading */
51 /** Colour for position */
55 * Creates a new Annotation object.
66 public Annotation(String displayChar, String desc, char ss, float val)
68 displayCharacter = displayChar;
70 secondaryStructure = ss;
76 * Creates a new Annotation object.
89 public Annotation(String displayChar, String desc, char ss, float val,
92 this(displayChar, desc, ss, val);
97 * Copy constructor New annotation takes on the same (or duplicated)
98 * attributes as the given template
101 * template annotation
103 public Annotation(Annotation that)
105 if (that == null || this == that)
109 if (that.displayCharacter != null)
110 displayCharacter = new String(that.displayCharacter);
111 if (that.description != null)
112 description = new String(that.description);
113 secondaryStructure = that.secondaryStructure;
115 colour = that.colour;
120 * Value only annotation.
123 * value at this annotation position
125 public Annotation(float val)
127 this(null, null, ' ', val, null);
131 * human readable representation of an annotation row element.
133 * Format is 'display Char','secondary Structure
134 * Char',"description",score,[colourstring]
136 * fields may be missing if they are null, whitespace, or equivalent to
140 public String toString()
142 StringBuffer sb = new StringBuffer();
143 if (displayCharacter != null)
146 sb.append(displayCharacter);
152 if (secondaryStructure != 0
153 && !("" + displayCharacter).equals("" + secondaryStructure))
156 sb.append(secondaryStructure);
162 if (description != null && description.length() > 0)
165 sb.append(description);
171 if (value != Float.NaN)
182 sb.append(colour.getRed());
184 sb.append(colour.getGreen());
186 sb.append(colour.getBlue());
189 return sb.toString();