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)
111 displayCharacter = new String(that.displayCharacter);
113 if (that.description != null)
115 description = new String(that.description);
117 secondaryStructure = that.secondaryStructure;
119 colour = that.colour;
124 * Value only annotation.
127 * value at this annotation position
129 public Annotation(float val)
131 this(null, null, ' ', val, null);
135 * human readable representation of an annotation row element.
137 * Format is 'display Char','secondary Structure
138 * Char',"description",score,[colourstring]
140 * fields may be missing if they are null, whitespace, or equivalent to
144 public String toString()
146 StringBuffer sb = new StringBuffer();
147 if (displayCharacter != null)
150 sb.append(displayCharacter);
156 if (secondaryStructure != 0
157 && !("" + displayCharacter).equals("" + secondaryStructure))
160 sb.append(secondaryStructure);
166 if (description != null && description.length() > 0)
169 sb.append(description);
175 if (!Float.isNaN(value))
186 sb.append(colour.getRed());
188 sb.append(colour.getGreen());
190 sb.append(colour.getBlue());
193 return sb.toString();