2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
30 * @version $Revision$ $Date$
32 public class Annotation implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
42 private boolean _graph;
45 * keeps track of state for field: _graph
47 private boolean _has_graph;
52 private int _graphType;
55 * keeps track of state for field: _graphType
57 private boolean _has_graphType;
62 private java.lang.String _sequenceRef;
67 private java.lang.String _groupRef;
72 private int _graphColour;
75 * keeps track of state for field: _graphColour
77 private boolean _has_graphColour;
82 private int _graphGroup;
85 * keeps track of state for field: _graphGroup
87 private boolean _has_graphGroup;
90 * height in pixels for the graph if this is a graph-type annotation.
92 private int _graphHeight;
95 * keeps track of state for field: _graphHeight
97 private boolean _has_graphHeight;
102 private java.lang.String _id;
107 private boolean _scoreOnly = false;
110 * keeps track of state for field: _scoreOnly
112 private boolean _has_scoreOnly;
117 private double _score;
120 * keeps track of state for field: _score
122 private boolean _has_score;
127 private boolean _visible;
130 * keeps track of state for field: _visible
132 private boolean _has_visible;
135 * Field _centreColLabels.
137 private boolean _centreColLabels;
140 * keeps track of state for field: _centreColLabels
142 private boolean _has_centreColLabels;
145 * Field _scaleColLabels.
147 private boolean _scaleColLabels;
150 * keeps track of state for field: _scaleColLabels
152 private boolean _has_scaleColLabels;
155 * Field _showAllColLabels.
157 private boolean _showAllColLabels;
160 * keeps track of state for field: _showAllColLabels
162 private boolean _has_showAllColLabels;
165 * is an autocalculated annotation row
167 private boolean _autoCalculated = false;
170 * keeps track of state for field: _autoCalculated
172 private boolean _has_autoCalculated;
175 * is to be shown below the alignment - introduced in Jalview 2.8 for
176 * visualizing T-COFFEE alignment scores
178 private boolean _belowAlignment = true;
181 * keeps track of state for field: _belowAlignment
183 private boolean _has_belowAlignment;
186 * Optional string identifier used to group sets of annotation produced by a
187 * particular calculation. Values are opaque strings but have semantic meaning
188 * to Jalview's renderer, data importer and calculation system.
190 private java.lang.String _calcId;
193 * Field _annotationElementList.
195 private java.util.Vector _annotationElementList;
200 private java.lang.String _label;
203 * Field _description.
205 private java.lang.String _description;
208 * Field _thresholdLine.
210 private jalview.schemabinding.version2.ThresholdLine _thresholdLine;
219 this._annotationElementList = new java.util.Vector();
229 * @param vAnnotationElement
230 * @throws java.lang.IndexOutOfBoundsException
231 * if the index given is outside the bounds of the collection
233 public void addAnnotationElement(
234 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
235 throws java.lang.IndexOutOfBoundsException
237 this._annotationElementList.addElement(vAnnotationElement);
244 * @param vAnnotationElement
245 * @throws java.lang.IndexOutOfBoundsException
246 * if the index given is outside the bounds of the collection
248 public void addAnnotationElement(
250 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
251 throws java.lang.IndexOutOfBoundsException
253 this._annotationElementList.add(index, vAnnotationElement);
258 public void deleteAutoCalculated()
260 this._has_autoCalculated = false;
265 public void deleteBelowAlignment()
267 this._has_belowAlignment = false;
272 public void deleteCentreColLabels()
274 this._has_centreColLabels = false;
279 public void deleteGraph()
281 this._has_graph = false;
286 public void deleteGraphColour()
288 this._has_graphColour = false;
293 public void deleteGraphGroup()
295 this._has_graphGroup = false;
300 public void deleteGraphHeight()
302 this._has_graphHeight = false;
307 public void deleteGraphType()
309 this._has_graphType = false;
314 public void deleteScaleColLabels()
316 this._has_scaleColLabels = false;
321 public void deleteScore()
323 this._has_score = false;
328 public void deleteScoreOnly()
330 this._has_scoreOnly = false;
335 public void deleteShowAllColLabels()
337 this._has_showAllColLabels = false;
342 public void deleteVisible()
344 this._has_visible = false;
348 * Method enumerateAnnotationElement.
350 * @return an Enumeration over all
351 * jalview.schemabinding.version2.AnnotationElement elements
353 public java.util.Enumeration enumerateAnnotationElement()
355 return this._annotationElementList.elements();
359 * Method getAnnotationElement.
362 * @throws java.lang.IndexOutOfBoundsException
363 * if the index given is outside the bounds of the collection
364 * @return the value of the jalview.schemabinding.version2.AnnotationElement
367 public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(
368 final int index) throws java.lang.IndexOutOfBoundsException
370 // check bounds for index
371 if (index < 0 || index >= this._annotationElementList.size())
373 throw new IndexOutOfBoundsException(
374 "getAnnotationElement: Index value '" + index
375 + "' not in range [0.."
376 + (this._annotationElementList.size() - 1) + "]");
379 return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList
384 * Method getAnnotationElement.Returns the contents of the collection in an
387 * Note: Just in case the collection contents are changing in another thread,
388 * we pass a 0-length Array of the correct type into the API call. This way we
389 * <i>know</i> that the Array returned is of exactly the correct length.
391 * @return this collection as an Array
393 public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement()
395 jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];
396 return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList
401 * Method getAnnotationElementCount.
403 * @return the size of this collection
405 public int getAnnotationElementCount()
407 return this._annotationElementList.size();
411 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
412 * the following description: is an autocalculated annotation row
414 * @return the value of field 'AutoCalculated'.
416 public boolean getAutoCalculated()
418 return this._autoCalculated;
422 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
423 * the following description: is to be shown below the alignment - introduced
424 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
426 * @return the value of field 'BelowAlignment'.
428 public boolean getBelowAlignment()
430 return this._belowAlignment;
434 * Returns the value of field 'calcId'. The field 'calcId' has the following
435 * description: Optional string identifier used to group sets of annotation
436 * produced by a particular calculation. Values are opaque strings but have
437 * semantic meaning to Jalview's renderer, data importer and calculation
440 * @return the value of field 'CalcId'.
442 public java.lang.String getCalcId()
448 * Returns the value of field 'centreColLabels'.
450 * @return the value of field 'CentreColLabels'.
452 public boolean getCentreColLabels()
454 return this._centreColLabels;
458 * Returns the value of field 'description'.
460 * @return the value of field 'Description'.
462 public java.lang.String getDescription()
464 return this._description;
468 * Returns the value of field 'graph'.
470 * @return the value of field 'Graph'.
472 public boolean getGraph()
478 * Returns the value of field 'graphColour'.
480 * @return the value of field 'GraphColour'.
482 public int getGraphColour()
484 return this._graphColour;
488 * Returns the value of field 'graphGroup'.
490 * @return the value of field 'GraphGroup'.
492 public int getGraphGroup()
494 return this._graphGroup;
498 * Returns the value of field 'graphHeight'. The field 'graphHeight' has the
499 * following description: height in pixels for the graph if this is a
500 * graph-type annotation.
502 * @return the value of field 'GraphHeight'.
504 public int getGraphHeight()
506 return this._graphHeight;
510 * Returns the value of field 'graphType'.
512 * @return the value of field 'GraphType'.
514 public int getGraphType()
516 return this._graphType;
520 * Returns the value of field 'groupRef'.
522 * @return the value of field 'GroupRef'.
524 public java.lang.String getGroupRef()
526 return this._groupRef;
530 * Returns the value of field 'id'.
532 * @return the value of field 'Id'.
534 public java.lang.String getId()
540 * Returns the value of field 'label'.
542 * @return the value of field 'Label'.
544 public java.lang.String getLabel()
550 * Returns the value of field 'scaleColLabels'.
552 * @return the value of field 'ScaleColLabels'.
554 public boolean getScaleColLabels()
556 return this._scaleColLabels;
560 * Returns the value of field 'score'.
562 * @return the value of field 'Score'.
564 public double getScore()
570 * Returns the value of field 'scoreOnly'.
572 * @return the value of field 'ScoreOnly'.
574 public boolean getScoreOnly()
576 return this._scoreOnly;
580 * Returns the value of field 'sequenceRef'.
582 * @return the value of field 'SequenceRef'.
584 public java.lang.String getSequenceRef()
586 return this._sequenceRef;
590 * Returns the value of field 'showAllColLabels'.
592 * @return the value of field 'ShowAllColLabels'.
594 public boolean getShowAllColLabels()
596 return this._showAllColLabels;
600 * Returns the value of field 'thresholdLine'.
602 * @return the value of field 'ThresholdLine'.
604 public jalview.schemabinding.version2.ThresholdLine getThresholdLine()
606 return this._thresholdLine;
610 * Returns the value of field 'visible'.
612 * @return the value of field 'Visible'.
614 public boolean getVisible()
616 return this._visible;
620 * Method hasAutoCalculated.
622 * @return true if at least one AutoCalculated has been added
624 public boolean hasAutoCalculated()
626 return this._has_autoCalculated;
630 * Method hasBelowAlignment.
632 * @return true if at least one BelowAlignment has been added
634 public boolean hasBelowAlignment()
636 return this._has_belowAlignment;
640 * Method hasCentreColLabels.
642 * @return true if at least one CentreColLabels has been added
644 public boolean hasCentreColLabels()
646 return this._has_centreColLabels;
652 * @return true if at least one Graph has been added
654 public boolean hasGraph()
656 return this._has_graph;
660 * Method hasGraphColour.
662 * @return true if at least one GraphColour has been added
664 public boolean hasGraphColour()
666 return this._has_graphColour;
670 * Method hasGraphGroup.
672 * @return true if at least one GraphGroup has been added
674 public boolean hasGraphGroup()
676 return this._has_graphGroup;
680 * Method hasGraphHeight.
682 * @return true if at least one GraphHeight has been added
684 public boolean hasGraphHeight()
686 return this._has_graphHeight;
690 * Method hasGraphType.
692 * @return true if at least one GraphType has been added
694 public boolean hasGraphType()
696 return this._has_graphType;
700 * Method hasScaleColLabels.
702 * @return true if at least one ScaleColLabels has been added
704 public boolean hasScaleColLabels()
706 return this._has_scaleColLabels;
712 * @return true if at least one Score has been added
714 public boolean hasScore()
716 return this._has_score;
720 * Method hasScoreOnly.
722 * @return true if at least one ScoreOnly has been added
724 public boolean hasScoreOnly()
726 return this._has_scoreOnly;
730 * Method hasShowAllColLabels.
732 * @return true if at least one ShowAllColLabels has been added
734 public boolean hasShowAllColLabels()
736 return this._has_showAllColLabels;
742 * @return true if at least one Visible has been added
744 public boolean hasVisible()
746 return this._has_visible;
750 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
751 * the following description: is an autocalculated annotation row
753 * @return the value of field 'AutoCalculated'.
755 public boolean isAutoCalculated()
757 return this._autoCalculated;
761 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
762 * the following description: is to be shown below the alignment - introduced
763 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
765 * @return the value of field 'BelowAlignment'.
767 public boolean isBelowAlignment()
769 return this._belowAlignment;
773 * Returns the value of field 'centreColLabels'.
775 * @return the value of field 'CentreColLabels'.
777 public boolean isCentreColLabels()
779 return this._centreColLabels;
783 * Returns the value of field 'graph'.
785 * @return the value of field 'Graph'.
787 public boolean isGraph()
793 * Returns the value of field 'scaleColLabels'.
795 * @return the value of field 'ScaleColLabels'.
797 public boolean isScaleColLabels()
799 return this._scaleColLabels;
803 * Returns the value of field 'scoreOnly'.
805 * @return the value of field 'ScoreOnly'.
807 public boolean isScoreOnly()
809 return this._scoreOnly;
813 * Returns the value of field 'showAllColLabels'.
815 * @return the value of field 'ShowAllColLabels'.
817 public boolean isShowAllColLabels()
819 return this._showAllColLabels;
825 * @return true if this object is valid according to the schema
827 public boolean isValid()
832 } catch (org.exolab.castor.xml.ValidationException vex)
840 * Returns the value of field 'visible'.
842 * @return the value of field 'Visible'.
844 public boolean isVisible()
846 return this._visible;
853 * @throws org.exolab.castor.xml.MarshalException
854 * if object is null or if any SAXException is thrown during
856 * @throws org.exolab.castor.xml.ValidationException
857 * if this object is an invalid instance according to the schema
859 public void marshal(final java.io.Writer out)
860 throws org.exolab.castor.xml.MarshalException,
861 org.exolab.castor.xml.ValidationException
863 Marshaller.marshal(this, out);
870 * @throws java.io.IOException
871 * if an IOException occurs during marshaling
872 * @throws org.exolab.castor.xml.ValidationException
873 * if this object is an invalid instance according to the schema
874 * @throws org.exolab.castor.xml.MarshalException
875 * if object is null or if any SAXException is thrown during
878 public void marshal(final org.xml.sax.ContentHandler handler)
879 throws java.io.IOException,
880 org.exolab.castor.xml.MarshalException,
881 org.exolab.castor.xml.ValidationException
883 Marshaller.marshal(this, handler);
888 public void removeAllAnnotationElement()
890 this._annotationElementList.clear();
894 * Method removeAnnotationElement.
896 * @param vAnnotationElement
897 * @return true if the object was removed from the collection.
899 public boolean removeAnnotationElement(
900 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
902 boolean removed = _annotationElementList.remove(vAnnotationElement);
907 * Method removeAnnotationElementAt.
910 * @return the element removed from the collection
912 public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(
915 java.lang.Object obj = this._annotationElementList.remove(index);
916 return (jalview.schemabinding.version2.AnnotationElement) obj;
923 * @param vAnnotationElement
924 * @throws java.lang.IndexOutOfBoundsException
925 * if the index given is outside the bounds of the collection
927 public void setAnnotationElement(
929 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
930 throws java.lang.IndexOutOfBoundsException
932 // check bounds for index
933 if (index < 0 || index >= this._annotationElementList.size())
935 throw new IndexOutOfBoundsException(
936 "setAnnotationElement: Index value '" + index
937 + "' not in range [0.."
938 + (this._annotationElementList.size() - 1) + "]");
941 this._annotationElementList.set(index, vAnnotationElement);
947 * @param vAnnotationElementArray
949 public void setAnnotationElement(
950 final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray)
953 _annotationElementList.clear();
955 for (int i = 0; i < vAnnotationElementArray.length; i++)
957 this._annotationElementList.add(vAnnotationElementArray[i]);
962 * Sets the value of field 'autoCalculated'. The field 'autoCalculated' has
963 * the following description: is an autocalculated annotation row
965 * @param autoCalculated
966 * the value of field 'autoCalculated'.
968 public void setAutoCalculated(final boolean autoCalculated)
970 this._autoCalculated = autoCalculated;
971 this._has_autoCalculated = true;
975 * Sets the value of field 'belowAlignment'. The field 'belowAlignment' has
976 * the following description: is to be shown below the alignment - introduced
977 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
979 * @param belowAlignment
980 * the value of field 'belowAlignment'.
982 public void setBelowAlignment(final boolean belowAlignment)
984 this._belowAlignment = belowAlignment;
985 this._has_belowAlignment = true;
989 * Sets the value of field 'calcId'. The field 'calcId' has the following
990 * description: Optional string identifier used to group sets of annotation
991 * produced by a particular calculation. Values are opaque strings but have
992 * semantic meaning to Jalview's renderer, data importer and calculation
996 * the value of field 'calcId'.
998 public void setCalcId(final java.lang.String calcId)
1000 this._calcId = calcId;
1004 * Sets the value of field 'centreColLabels'.
1006 * @param centreColLabels
1007 * the value of field 'centreColLabels'.
1009 public void setCentreColLabels(final boolean centreColLabels)
1011 this._centreColLabels = centreColLabels;
1012 this._has_centreColLabels = true;
1016 * Sets the value of field 'description'.
1018 * @param description
1019 * the value of field 'description'.
1021 public void setDescription(final java.lang.String description)
1023 this._description = description;
1027 * Sets the value of field 'graph'.
1030 * the value of field 'graph'.
1032 public void setGraph(final boolean graph)
1034 this._graph = graph;
1035 this._has_graph = true;
1039 * Sets the value of field 'graphColour'.
1041 * @param graphColour
1042 * the value of field 'graphColour'.
1044 public void setGraphColour(final int graphColour)
1046 this._graphColour = graphColour;
1047 this._has_graphColour = true;
1051 * Sets the value of field 'graphGroup'.
1054 * the value of field 'graphGroup'.
1056 public void setGraphGroup(final int graphGroup)
1058 this._graphGroup = graphGroup;
1059 this._has_graphGroup = true;
1063 * Sets the value of field 'graphHeight'. The field 'graphHeight' has the
1064 * following description: height in pixels for the graph if this is a
1065 * graph-type annotation.
1067 * @param graphHeight
1068 * the value of field 'graphHeight'.
1070 public void setGraphHeight(final int graphHeight)
1072 this._graphHeight = graphHeight;
1073 this._has_graphHeight = true;
1077 * Sets the value of field 'graphType'.
1080 * the value of field 'graphType'.
1082 public void setGraphType(final int graphType)
1084 this._graphType = graphType;
1085 this._has_graphType = true;
1089 * Sets the value of field 'groupRef'.
1092 * the value of field 'groupRef'.
1094 public void setGroupRef(final java.lang.String groupRef)
1096 this._groupRef = groupRef;
1100 * Sets the value of field 'id'.
1103 * the value of field 'id'.
1105 public void setId(final java.lang.String id)
1111 * Sets the value of field 'label'.
1114 * the value of field 'label'.
1116 public void setLabel(final java.lang.String label)
1118 this._label = label;
1122 * Sets the value of field 'scaleColLabels'.
1124 * @param scaleColLabels
1125 * the value of field 'scaleColLabels'.
1127 public void setScaleColLabels(final boolean scaleColLabels)
1129 this._scaleColLabels = scaleColLabels;
1130 this._has_scaleColLabels = true;
1134 * Sets the value of field 'score'.
1137 * the value of field 'score'.
1139 public void setScore(final double score)
1141 this._score = score;
1142 this._has_score = true;
1146 * Sets the value of field 'scoreOnly'.
1149 * the value of field 'scoreOnly'.
1151 public void setScoreOnly(final boolean scoreOnly)
1153 this._scoreOnly = scoreOnly;
1154 this._has_scoreOnly = true;
1158 * Sets the value of field 'sequenceRef'.
1160 * @param sequenceRef
1161 * the value of field 'sequenceRef'.
1163 public void setSequenceRef(final java.lang.String sequenceRef)
1165 this._sequenceRef = sequenceRef;
1169 * Sets the value of field 'showAllColLabels'.
1171 * @param showAllColLabels
1172 * the value of field 'showAllColLabels'
1174 public void setShowAllColLabels(final boolean showAllColLabels)
1176 this._showAllColLabels = showAllColLabels;
1177 this._has_showAllColLabels = true;
1181 * Sets the value of field 'thresholdLine'.
1183 * @param thresholdLine
1184 * the value of field 'thresholdLine'.
1186 public void setThresholdLine(
1187 final jalview.schemabinding.version2.ThresholdLine thresholdLine)
1189 this._thresholdLine = thresholdLine;
1193 * Sets the value of field 'visible'.
1196 * the value of field 'visible'.
1198 public void setVisible(final boolean visible)
1200 this._visible = visible;
1201 this._has_visible = true;
1208 * @throws org.exolab.castor.xml.MarshalException
1209 * if object is null or if any SAXException is thrown during
1211 * @throws org.exolab.castor.xml.ValidationException
1212 * if this object is an invalid instance according to the schema
1213 * @return the unmarshaled jalview.schemabinding.version2.Annotation
1215 public static jalview.schemabinding.version2.Annotation unmarshal(
1216 final java.io.Reader reader)
1217 throws org.exolab.castor.xml.MarshalException,
1218 org.exolab.castor.xml.ValidationException
1220 return (jalview.schemabinding.version2.Annotation) Unmarshaller
1221 .unmarshal(jalview.schemabinding.version2.Annotation.class,
1228 * @throws org.exolab.castor.xml.ValidationException
1229 * if this object is an invalid instance according to the schema
1231 public void validate() throws org.exolab.castor.xml.ValidationException
1233 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1234 validator.validate(this);