2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
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.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class Annotation implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private boolean _graph;
48 * keeps track of state for field: _graph
50 private boolean _has_graph;
55 private int _graphType;
58 * keeps track of state for field: _graphType
60 private boolean _has_graphType;
65 private java.lang.String _sequenceRef;
70 private java.lang.String _groupRef;
75 private int _graphColour;
78 * keeps track of state for field: _graphColour
80 private boolean _has_graphColour;
85 private int _graphGroup;
88 * keeps track of state for field: _graphGroup
90 private boolean _has_graphGroup;
93 * height in pixels for the graph if this is a graph-type annotation.
95 private int _graphHeight;
98 * keeps track of state for field: _graphHeight
100 private boolean _has_graphHeight;
105 private java.lang.String _id;
110 private boolean _scoreOnly = false;
113 * keeps track of state for field: _scoreOnly
115 private boolean _has_scoreOnly;
120 private double _score;
123 * keeps track of state for field: _score
125 private boolean _has_score;
130 private boolean _visible;
133 * keeps track of state for field: _visible
135 private boolean _has_visible;
138 * Field _centreColLabels.
140 private boolean _centreColLabels;
143 * keeps track of state for field: _centreColLabels
145 private boolean _has_centreColLabels;
148 * Field _scaleColLabels.
150 private boolean _scaleColLabels;
153 * keeps track of state for field: _scaleColLabels
155 private boolean _has_scaleColLabels;
158 * Field _showAllColLabels.
160 private boolean _showAllColLabels;
163 * keeps track of state for field: _showAllColLabels
165 private boolean _has_showAllColLabels;
168 * is an autocalculated annotation row
170 private boolean _autoCalculated = false;
173 * keeps track of state for field: _autoCalculated
175 private boolean _has_autoCalculated;
178 * is to be shown below the alignment - introduced in Jalview 2.8 for
179 * visualizing T-COFFEE alignment scores
181 private boolean _belowAlignment = true;
184 * keeps track of state for field: _belowAlignment
186 private boolean _has_belowAlignment;
189 * Optional string identifier used to group sets of annotation produced by a
190 * particular calculation. Values are opaque strings but have semantic meaning
191 * to Jalview's renderer, data importer and calculation system.
193 private java.lang.String _calcId;
196 * Field _annotationElementList.
198 private java.util.Vector _annotationElementList;
203 private java.lang.String _label;
206 * Field _description.
208 private java.lang.String _description;
211 * Field _thresholdLine.
213 private jalview.schemabinding.version2.ThresholdLine _thresholdLine;
222 this._annotationElementList = new java.util.Vector();
232 * @param vAnnotationElement
233 * @throws java.lang.IndexOutOfBoundsException
234 * if the index given is outside the bounds of the collection
236 public void addAnnotationElement(
237 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
238 throws java.lang.IndexOutOfBoundsException
240 this._annotationElementList.addElement(vAnnotationElement);
247 * @param vAnnotationElement
248 * @throws java.lang.IndexOutOfBoundsException
249 * if the index given is outside the bounds of the collection
251 public void addAnnotationElement(
253 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
254 throws java.lang.IndexOutOfBoundsException
256 this._annotationElementList.add(index, vAnnotationElement);
261 public void deleteAutoCalculated()
263 this._has_autoCalculated = false;
268 public void deleteBelowAlignment()
270 this._has_belowAlignment = false;
275 public void deleteCentreColLabels()
277 this._has_centreColLabels = false;
282 public void deleteGraph()
284 this._has_graph = false;
289 public void deleteGraphColour()
291 this._has_graphColour = false;
296 public void deleteGraphGroup()
298 this._has_graphGroup = false;
303 public void deleteGraphHeight()
305 this._has_graphHeight = false;
310 public void deleteGraphType()
312 this._has_graphType = false;
317 public void deleteScaleColLabels()
319 this._has_scaleColLabels = false;
324 public void deleteScore()
326 this._has_score = false;
331 public void deleteScoreOnly()
333 this._has_scoreOnly = false;
338 public void deleteShowAllColLabels()
340 this._has_showAllColLabels = false;
345 public void deleteVisible()
347 this._has_visible = false;
351 * Method enumerateAnnotationElement.
353 * @return an Enumeration over all
354 * jalview.schemabinding.version2.AnnotationElement elements
356 public java.util.Enumeration enumerateAnnotationElement()
358 return this._annotationElementList.elements();
362 * Method getAnnotationElement.
365 * @throws java.lang.IndexOutOfBoundsException
366 * if the index given is outside the bounds of the collection
367 * @return the value of the jalview.schemabinding.version2.AnnotationElement
370 public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(
371 final int index) throws java.lang.IndexOutOfBoundsException
373 // check bounds for index
374 if (index < 0 || index >= this._annotationElementList.size())
376 throw new IndexOutOfBoundsException(
377 "getAnnotationElement: Index value '" + index
378 + "' not in range [0.."
379 + (this._annotationElementList.size() - 1) + "]");
382 return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList
387 * Method getAnnotationElement.Returns the contents of the collection in an
390 * Note: Just in case the collection contents are changing in another thread,
391 * we pass a 0-length Array of the correct type into the API call. This way we
392 * <i>know</i> that the Array returned is of exactly the correct length.
394 * @return this collection as an Array
396 public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement()
398 jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];
399 return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList
404 * Method getAnnotationElementCount.
406 * @return the size of this collection
408 public int getAnnotationElementCount()
410 return this._annotationElementList.size();
414 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
415 * the following description: is an autocalculated annotation row
417 * @return the value of field 'AutoCalculated'.
419 public boolean getAutoCalculated()
421 return this._autoCalculated;
425 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
426 * the following description: is to be shown below the alignment - introduced
427 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
429 * @return the value of field 'BelowAlignment'.
431 public boolean getBelowAlignment()
433 return this._belowAlignment;
437 * Returns the value of field 'calcId'. The field 'calcId' has the following
438 * description: Optional string identifier used to group sets of annotation
439 * produced by a particular calculation. Values are opaque strings but have
440 * semantic meaning to Jalview's renderer, data importer and calculation
443 * @return the value of field 'CalcId'.
445 public java.lang.String getCalcId()
451 * Returns the value of field 'centreColLabels'.
453 * @return the value of field 'CentreColLabels'.
455 public boolean getCentreColLabels()
457 return this._centreColLabels;
461 * Returns the value of field 'description'.
463 * @return the value of field 'Description'.
465 public java.lang.String getDescription()
467 return this._description;
471 * Returns the value of field 'graph'.
473 * @return the value of field 'Graph'.
475 public boolean getGraph()
481 * Returns the value of field 'graphColour'.
483 * @return the value of field 'GraphColour'.
485 public int getGraphColour()
487 return this._graphColour;
491 * Returns the value of field 'graphGroup'.
493 * @return the value of field 'GraphGroup'.
495 public int getGraphGroup()
497 return this._graphGroup;
501 * Returns the value of field 'graphHeight'. The field 'graphHeight' has the
502 * following description: height in pixels for the graph if this is a
503 * graph-type annotation.
505 * @return the value of field 'GraphHeight'.
507 public int getGraphHeight()
509 return this._graphHeight;
513 * Returns the value of field 'graphType'.
515 * @return the value of field 'GraphType'.
517 public int getGraphType()
519 return this._graphType;
523 * Returns the value of field 'groupRef'.
525 * @return the value of field 'GroupRef'.
527 public java.lang.String getGroupRef()
529 return this._groupRef;
533 * Returns the value of field 'id'.
535 * @return the value of field 'Id'.
537 public java.lang.String getId()
543 * Returns the value of field 'label'.
545 * @return the value of field 'Label'.
547 public java.lang.String getLabel()
553 * Returns the value of field 'scaleColLabels'.
555 * @return the value of field 'ScaleColLabels'.
557 public boolean getScaleColLabels()
559 return this._scaleColLabels;
563 * Returns the value of field 'score'.
565 * @return the value of field 'Score'.
567 public double getScore()
573 * Returns the value of field 'scoreOnly'.
575 * @return the value of field 'ScoreOnly'.
577 public boolean getScoreOnly()
579 return this._scoreOnly;
583 * Returns the value of field 'sequenceRef'.
585 * @return the value of field 'SequenceRef'.
587 public java.lang.String getSequenceRef()
589 return this._sequenceRef;
593 * Returns the value of field 'showAllColLabels'.
595 * @return the value of field 'ShowAllColLabels'.
597 public boolean getShowAllColLabels()
599 return this._showAllColLabels;
603 * Returns the value of field 'thresholdLine'.
605 * @return the value of field 'ThresholdLine'.
607 public jalview.schemabinding.version2.ThresholdLine getThresholdLine()
609 return this._thresholdLine;
613 * Returns the value of field 'visible'.
615 * @return the value of field 'Visible'.
617 public boolean getVisible()
619 return this._visible;
623 * Method hasAutoCalculated.
625 * @return true if at least one AutoCalculated has been added
627 public boolean hasAutoCalculated()
629 return this._has_autoCalculated;
633 * Method hasBelowAlignment.
635 * @return true if at least one BelowAlignment has been added
637 public boolean hasBelowAlignment()
639 return this._has_belowAlignment;
643 * Method hasCentreColLabels.
645 * @return true if at least one CentreColLabels has been added
647 public boolean hasCentreColLabels()
649 return this._has_centreColLabels;
655 * @return true if at least one Graph has been added
657 public boolean hasGraph()
659 return this._has_graph;
663 * Method hasGraphColour.
665 * @return true if at least one GraphColour has been added
667 public boolean hasGraphColour()
669 return this._has_graphColour;
673 * Method hasGraphGroup.
675 * @return true if at least one GraphGroup has been added
677 public boolean hasGraphGroup()
679 return this._has_graphGroup;
683 * Method hasGraphHeight.
685 * @return true if at least one GraphHeight has been added
687 public boolean hasGraphHeight()
689 return this._has_graphHeight;
693 * Method hasGraphType.
695 * @return true if at least one GraphType has been added
697 public boolean hasGraphType()
699 return this._has_graphType;
703 * Method hasScaleColLabels.
705 * @return true if at least one ScaleColLabels has been added
707 public boolean hasScaleColLabels()
709 return this._has_scaleColLabels;
715 * @return true if at least one Score has been added
717 public boolean hasScore()
719 return this._has_score;
723 * Method hasScoreOnly.
725 * @return true if at least one ScoreOnly has been added
727 public boolean hasScoreOnly()
729 return this._has_scoreOnly;
733 * Method hasShowAllColLabels.
735 * @return true if at least one ShowAllColLabels has been added
737 public boolean hasShowAllColLabels()
739 return this._has_showAllColLabels;
745 * @return true if at least one Visible has been added
747 public boolean hasVisible()
749 return this._has_visible;
753 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
754 * the following description: is an autocalculated annotation row
756 * @return the value of field 'AutoCalculated'.
758 public boolean isAutoCalculated()
760 return this._autoCalculated;
764 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
765 * the following description: is to be shown below the alignment - introduced
766 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
768 * @return the value of field 'BelowAlignment'.
770 public boolean isBelowAlignment()
772 return this._belowAlignment;
776 * Returns the value of field 'centreColLabels'.
778 * @return the value of field 'CentreColLabels'.
780 public boolean isCentreColLabels()
782 return this._centreColLabels;
786 * Returns the value of field 'graph'.
788 * @return the value of field 'Graph'.
790 public boolean isGraph()
796 * Returns the value of field 'scaleColLabels'.
798 * @return the value of field 'ScaleColLabels'.
800 public boolean isScaleColLabels()
802 return this._scaleColLabels;
806 * Returns the value of field 'scoreOnly'.
808 * @return the value of field 'ScoreOnly'.
810 public boolean isScoreOnly()
812 return this._scoreOnly;
816 * Returns the value of field 'showAllColLabels'.
818 * @return the value of field 'ShowAllColLabels'.
820 public boolean isShowAllColLabels()
822 return this._showAllColLabels;
828 * @return true if this object is valid according to the schema
830 public boolean isValid()
835 } catch (org.exolab.castor.xml.ValidationException vex)
843 * Returns the value of field 'visible'.
845 * @return the value of field 'Visible'.
847 public boolean isVisible()
849 return this._visible;
856 * @throws org.exolab.castor.xml.MarshalException
857 * if object is null or if any SAXException is thrown during
859 * @throws org.exolab.castor.xml.ValidationException
860 * if this object is an invalid instance according to the schema
862 public void marshal(final java.io.Writer out)
863 throws org.exolab.castor.xml.MarshalException,
864 org.exolab.castor.xml.ValidationException
866 Marshaller.marshal(this, out);
873 * @throws java.io.IOException
874 * if an IOException occurs during marshaling
875 * @throws org.exolab.castor.xml.ValidationException
876 * if this object is an invalid instance according to the schema
877 * @throws org.exolab.castor.xml.MarshalException
878 * if object is null or if any SAXException is thrown during
881 public void marshal(final org.xml.sax.ContentHandler handler)
882 throws java.io.IOException,
883 org.exolab.castor.xml.MarshalException,
884 org.exolab.castor.xml.ValidationException
886 Marshaller.marshal(this, handler);
891 public void removeAllAnnotationElement()
893 this._annotationElementList.clear();
897 * Method removeAnnotationElement.
899 * @param vAnnotationElement
900 * @return true if the object was removed from the collection.
902 public boolean removeAnnotationElement(
903 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
905 boolean removed = _annotationElementList.remove(vAnnotationElement);
910 * Method removeAnnotationElementAt.
913 * @return the element removed from the collection
915 public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(
918 java.lang.Object obj = this._annotationElementList.remove(index);
919 return (jalview.schemabinding.version2.AnnotationElement) obj;
926 * @param vAnnotationElement
927 * @throws java.lang.IndexOutOfBoundsException
928 * if the index given is outside the bounds of the collection
930 public void setAnnotationElement(
932 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
933 throws java.lang.IndexOutOfBoundsException
935 // check bounds for index
936 if (index < 0 || index >= this._annotationElementList.size())
938 throw new IndexOutOfBoundsException(
939 "setAnnotationElement: Index value '" + index
940 + "' not in range [0.."
941 + (this._annotationElementList.size() - 1) + "]");
944 this._annotationElementList.set(index, vAnnotationElement);
950 * @param vAnnotationElementArray
952 public void setAnnotationElement(
953 final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray)
956 _annotationElementList.clear();
958 for (int i = 0; i < vAnnotationElementArray.length; i++)
960 this._annotationElementList.add(vAnnotationElementArray[i]);
965 * Sets the value of field 'autoCalculated'. The field 'autoCalculated' has
966 * the following description: is an autocalculated annotation row
968 * @param autoCalculated
969 * the value of field 'autoCalculated'.
971 public void setAutoCalculated(final boolean autoCalculated)
973 this._autoCalculated = autoCalculated;
974 this._has_autoCalculated = true;
978 * Sets the value of field 'belowAlignment'. The field 'belowAlignment' has
979 * the following description: is to be shown below the alignment - introduced
980 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
982 * @param belowAlignment
983 * the value of field 'belowAlignment'.
985 public void setBelowAlignment(final boolean belowAlignment)
987 this._belowAlignment = belowAlignment;
988 this._has_belowAlignment = true;
992 * Sets the value of field 'calcId'. The field 'calcId' has the following
993 * description: Optional string identifier used to group sets of annotation
994 * produced by a particular calculation. Values are opaque strings but have
995 * semantic meaning to Jalview's renderer, data importer and calculation
999 * the value of field 'calcId'.
1001 public void setCalcId(final java.lang.String calcId)
1003 this._calcId = calcId;
1007 * Sets the value of field 'centreColLabels'.
1009 * @param centreColLabels
1010 * the value of field 'centreColLabels'.
1012 public void setCentreColLabels(final boolean centreColLabels)
1014 this._centreColLabels = centreColLabels;
1015 this._has_centreColLabels = true;
1019 * Sets the value of field 'description'.
1021 * @param description
1022 * the value of field 'description'.
1024 public void setDescription(final java.lang.String description)
1026 this._description = description;
1030 * Sets the value of field 'graph'.
1033 * the value of field 'graph'.
1035 public void setGraph(final boolean graph)
1037 this._graph = graph;
1038 this._has_graph = true;
1042 * Sets the value of field 'graphColour'.
1044 * @param graphColour
1045 * the value of field 'graphColour'.
1047 public void setGraphColour(final int graphColour)
1049 this._graphColour = graphColour;
1050 this._has_graphColour = true;
1054 * Sets the value of field 'graphGroup'.
1057 * the value of field 'graphGroup'.
1059 public void setGraphGroup(final int graphGroup)
1061 this._graphGroup = graphGroup;
1062 this._has_graphGroup = true;
1066 * Sets the value of field 'graphHeight'. The field 'graphHeight' has the
1067 * following description: height in pixels for the graph if this is a
1068 * graph-type annotation.
1070 * @param graphHeight
1071 * the value of field 'graphHeight'.
1073 public void setGraphHeight(final int graphHeight)
1075 this._graphHeight = graphHeight;
1076 this._has_graphHeight = true;
1080 * Sets the value of field 'graphType'.
1083 * the value of field 'graphType'.
1085 public void setGraphType(final int graphType)
1087 this._graphType = graphType;
1088 this._has_graphType = true;
1092 * Sets the value of field 'groupRef'.
1095 * the value of field 'groupRef'.
1097 public void setGroupRef(final java.lang.String groupRef)
1099 this._groupRef = groupRef;
1103 * Sets the value of field 'id'.
1106 * the value of field 'id'.
1108 public void setId(final java.lang.String id)
1114 * Sets the value of field 'label'.
1117 * the value of field 'label'.
1119 public void setLabel(final java.lang.String label)
1121 this._label = label;
1125 * Sets the value of field 'scaleColLabels'.
1127 * @param scaleColLabels
1128 * the value of field 'scaleColLabels'.
1130 public void setScaleColLabels(final boolean scaleColLabels)
1132 this._scaleColLabels = scaleColLabels;
1133 this._has_scaleColLabels = true;
1137 * Sets the value of field 'score'.
1140 * the value of field 'score'.
1142 public void setScore(final double score)
1144 this._score = score;
1145 this._has_score = true;
1149 * Sets the value of field 'scoreOnly'.
1152 * the value of field 'scoreOnly'.
1154 public void setScoreOnly(final boolean scoreOnly)
1156 this._scoreOnly = scoreOnly;
1157 this._has_scoreOnly = true;
1161 * Sets the value of field 'sequenceRef'.
1163 * @param sequenceRef
1164 * the value of field 'sequenceRef'.
1166 public void setSequenceRef(final java.lang.String sequenceRef)
1168 this._sequenceRef = sequenceRef;
1172 * Sets the value of field 'showAllColLabels'.
1174 * @param showAllColLabels
1175 * the value of field 'showAllColLabels'
1177 public void setShowAllColLabels(final boolean showAllColLabels)
1179 this._showAllColLabels = showAllColLabels;
1180 this._has_showAllColLabels = true;
1184 * Sets the value of field 'thresholdLine'.
1186 * @param thresholdLine
1187 * the value of field 'thresholdLine'.
1189 public void setThresholdLine(
1190 final jalview.schemabinding.version2.ThresholdLine thresholdLine)
1192 this._thresholdLine = thresholdLine;
1196 * Sets the value of field 'visible'.
1199 * the value of field 'visible'.
1201 public void setVisible(final boolean visible)
1203 this._visible = visible;
1204 this._has_visible = true;
1211 * @throws org.exolab.castor.xml.MarshalException
1212 * if object is null or if any SAXException is thrown during
1214 * @throws org.exolab.castor.xml.ValidationException
1215 * if this object is an invalid instance according to the schema
1216 * @return the unmarshaled jalview.schemabinding.version2.Annotation
1218 public static jalview.schemabinding.version2.Annotation unmarshal(
1219 final java.io.Reader reader)
1220 throws org.exolab.castor.xml.MarshalException,
1221 org.exolab.castor.xml.ValidationException
1223 return (jalview.schemabinding.version2.Annotation) Unmarshaller
1224 .unmarshal(jalview.schemabinding.version2.Annotation.class,
1231 * @throws org.exolab.castor.xml.ValidationException
1232 * if this object is an invalid instance according to the schema
1234 public void validate() throws org.exolab.castor.xml.ValidationException
1236 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1237 validator.validate(this);