2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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.schemabinding.version2;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
31 * @version $Revision$ $Date$
33 public class Annotation implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private boolean _graph;
46 * keeps track of state for field: _graph
48 private boolean _has_graph;
53 private int _graphType;
56 * keeps track of state for field: _graphType
58 private boolean _has_graphType;
63 private java.lang.String _sequenceRef;
68 private java.lang.String _groupRef;
73 private int _graphColour;
76 * keeps track of state for field: _graphColour
78 private boolean _has_graphColour;
83 private int _graphGroup;
86 * keeps track of state for field: _graphGroup
88 private boolean _has_graphGroup;
91 * height in pixels for the graph if this is a graph-type annotation.
93 private int _graphHeight;
96 * keeps track of state for field: _graphHeight
98 private boolean _has_graphHeight;
103 private java.lang.String _id;
108 private boolean _scoreOnly = false;
111 * keeps track of state for field: _scoreOnly
113 private boolean _has_scoreOnly;
118 private double _score;
121 * keeps track of state for field: _score
123 private boolean _has_score;
128 private boolean _visible;
131 * keeps track of state for field: _visible
133 private boolean _has_visible;
136 * Field _centreColLabels.
138 private boolean _centreColLabels;
141 * keeps track of state for field: _centreColLabels
143 private boolean _has_centreColLabels;
146 * Field _scaleColLabels.
148 private boolean _scaleColLabels;
151 * keeps track of state for field: _scaleColLabels
153 private boolean _has_scaleColLabels;
156 * Field _showAllColLabels.
158 private boolean _showAllColLabels;
161 * keeps track of state for field: _showAllColLabels
163 private boolean _has_showAllColLabels;
166 * is an autocalculated annotation row
168 private boolean _autoCalculated = false;
171 * keeps track of state for field: _autoCalculated
173 private boolean _has_autoCalculated;
176 * is to be shown below the alignment - introduced in Jalview 2.8 for
177 * visualizing T-COFFEE alignment scores
179 private boolean _belowAlignment = true;
182 * keeps track of state for field: _belowAlignment
184 private boolean _has_belowAlignment;
187 * Optional string identifier used to group sets of annotation produced by a
188 * particular calculation. Values are opaque strings but have semantic meaning
189 * to Jalview's renderer, data importer and calculation system.
191 private java.lang.String _calcId;
194 * Field _annotationElementList.
196 private java.util.Vector _annotationElementList;
201 private java.lang.String _label;
204 * Field _description.
206 private java.lang.String _description;
209 * Field _thresholdLine.
211 private jalview.schemabinding.version2.ThresholdLine _thresholdLine;
220 this._annotationElementList = new java.util.Vector();
230 * @param vAnnotationElement
231 * @throws java.lang.IndexOutOfBoundsException
232 * if the index given is outside the bounds of the collection
234 public void addAnnotationElement(
235 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
236 throws java.lang.IndexOutOfBoundsException
238 this._annotationElementList.addElement(vAnnotationElement);
245 * @param vAnnotationElement
246 * @throws java.lang.IndexOutOfBoundsException
247 * if the index given is outside the bounds of the collection
249 public void addAnnotationElement(
251 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
252 throws java.lang.IndexOutOfBoundsException
254 this._annotationElementList.add(index, vAnnotationElement);
259 public void deleteAutoCalculated()
261 this._has_autoCalculated = false;
266 public void deleteBelowAlignment()
268 this._has_belowAlignment = false;
273 public void deleteCentreColLabels()
275 this._has_centreColLabels = false;
280 public void deleteGraph()
282 this._has_graph = false;
287 public void deleteGraphColour()
289 this._has_graphColour = false;
294 public void deleteGraphGroup()
296 this._has_graphGroup = false;
301 public void deleteGraphHeight()
303 this._has_graphHeight = false;
308 public void deleteGraphType()
310 this._has_graphType = false;
315 public void deleteScaleColLabels()
317 this._has_scaleColLabels = false;
322 public void deleteScore()
324 this._has_score = false;
329 public void deleteScoreOnly()
331 this._has_scoreOnly = false;
336 public void deleteShowAllColLabels()
338 this._has_showAllColLabels = false;
343 public void deleteVisible()
345 this._has_visible = false;
349 * Method enumerateAnnotationElement.
351 * @return an Enumeration over all
352 * jalview.schemabinding.version2.AnnotationElement elements
354 public java.util.Enumeration enumerateAnnotationElement()
356 return this._annotationElementList.elements();
360 * Method getAnnotationElement.
363 * @throws java.lang.IndexOutOfBoundsException
364 * if the index given is outside the bounds of the collection
365 * @return the value of the jalview.schemabinding.version2.AnnotationElement
368 public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(
369 final int index) throws java.lang.IndexOutOfBoundsException
371 // check bounds for index
372 if (index < 0 || index >= this._annotationElementList.size())
374 throw new IndexOutOfBoundsException(
375 "getAnnotationElement: Index value '" + index
376 + "' not in range [0.."
377 + (this._annotationElementList.size() - 1) + "]");
380 return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList
385 * Method getAnnotationElement.Returns the contents of the collection in an
388 * Note: Just in case the collection contents are changing in another thread,
389 * we pass a 0-length Array of the correct type into the API call. This way we
390 * <i>know</i> that the Array returned is of exactly the correct length.
392 * @return this collection as an Array
394 public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement()
396 jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];
397 return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList
402 * Method getAnnotationElementCount.
404 * @return the size of this collection
406 public int getAnnotationElementCount()
408 return this._annotationElementList.size();
412 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
413 * the following description: is an autocalculated annotation row
415 * @return the value of field 'AutoCalculated'.
417 public boolean getAutoCalculated()
419 return this._autoCalculated;
423 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
424 * the following description: is to be shown below the alignment - introduced
425 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
427 * @return the value of field 'BelowAlignment'.
429 public boolean getBelowAlignment()
431 return this._belowAlignment;
435 * Returns the value of field 'calcId'. The field 'calcId' has the following
436 * description: Optional string identifier used to group sets of annotation
437 * produced by a particular calculation. Values are opaque strings but have
438 * semantic meaning to Jalview's renderer, data importer and calculation
441 * @return the value of field 'CalcId'.
443 public java.lang.String getCalcId()
449 * Returns the value of field 'centreColLabels'.
451 * @return the value of field 'CentreColLabels'.
453 public boolean getCentreColLabels()
455 return this._centreColLabels;
459 * Returns the value of field 'description'.
461 * @return the value of field 'Description'.
463 public java.lang.String getDescription()
465 return this._description;
469 * Returns the value of field 'graph'.
471 * @return the value of field 'Graph'.
473 public boolean getGraph()
479 * Returns the value of field 'graphColour'.
481 * @return the value of field 'GraphColour'.
483 public int getGraphColour()
485 return this._graphColour;
489 * Returns the value of field 'graphGroup'.
491 * @return the value of field 'GraphGroup'.
493 public int getGraphGroup()
495 return this._graphGroup;
499 * Returns the value of field 'graphHeight'. The field 'graphHeight' has the
500 * following description: height in pixels for the graph if this is a
501 * graph-type annotation.
503 * @return the value of field 'GraphHeight'.
505 public int getGraphHeight()
507 return this._graphHeight;
511 * Returns the value of field 'graphType'.
513 * @return the value of field 'GraphType'.
515 public int getGraphType()
517 return this._graphType;
521 * Returns the value of field 'groupRef'.
523 * @return the value of field 'GroupRef'.
525 public java.lang.String getGroupRef()
527 return this._groupRef;
531 * Returns the value of field 'id'.
533 * @return the value of field 'Id'.
535 public java.lang.String getId()
541 * Returns the value of field 'label'.
543 * @return the value of field 'Label'.
545 public java.lang.String getLabel()
551 * Returns the value of field 'scaleColLabels'.
553 * @return the value of field 'ScaleColLabels'.
555 public boolean getScaleColLabels()
557 return this._scaleColLabels;
561 * Returns the value of field 'score'.
563 * @return the value of field 'Score'.
565 public double getScore()
571 * Returns the value of field 'scoreOnly'.
573 * @return the value of field 'ScoreOnly'.
575 public boolean getScoreOnly()
577 return this._scoreOnly;
581 * Returns the value of field 'sequenceRef'.
583 * @return the value of field 'SequenceRef'.
585 public java.lang.String getSequenceRef()
587 return this._sequenceRef;
591 * Returns the value of field 'showAllColLabels'.
593 * @return the value of field 'ShowAllColLabels'.
595 public boolean getShowAllColLabels()
597 return this._showAllColLabels;
601 * Returns the value of field 'thresholdLine'.
603 * @return the value of field 'ThresholdLine'.
605 public jalview.schemabinding.version2.ThresholdLine getThresholdLine()
607 return this._thresholdLine;
611 * Returns the value of field 'visible'.
613 * @return the value of field 'Visible'.
615 public boolean getVisible()
617 return this._visible;
621 * Method hasAutoCalculated.
623 * @return true if at least one AutoCalculated has been added
625 public boolean hasAutoCalculated()
627 return this._has_autoCalculated;
631 * Method hasBelowAlignment.
633 * @return true if at least one BelowAlignment has been added
635 public boolean hasBelowAlignment()
637 return this._has_belowAlignment;
641 * Method hasCentreColLabels.
643 * @return true if at least one CentreColLabels has been added
645 public boolean hasCentreColLabels()
647 return this._has_centreColLabels;
653 * @return true if at least one Graph has been added
655 public boolean hasGraph()
657 return this._has_graph;
661 * Method hasGraphColour.
663 * @return true if at least one GraphColour has been added
665 public boolean hasGraphColour()
667 return this._has_graphColour;
671 * Method hasGraphGroup.
673 * @return true if at least one GraphGroup has been added
675 public boolean hasGraphGroup()
677 return this._has_graphGroup;
681 * Method hasGraphHeight.
683 * @return true if at least one GraphHeight has been added
685 public boolean hasGraphHeight()
687 return this._has_graphHeight;
691 * Method hasGraphType.
693 * @return true if at least one GraphType has been added
695 public boolean hasGraphType()
697 return this._has_graphType;
701 * Method hasScaleColLabels.
703 * @return true if at least one ScaleColLabels has been added
705 public boolean hasScaleColLabels()
707 return this._has_scaleColLabels;
713 * @return true if at least one Score has been added
715 public boolean hasScore()
717 return this._has_score;
721 * Method hasScoreOnly.
723 * @return true if at least one ScoreOnly has been added
725 public boolean hasScoreOnly()
727 return this._has_scoreOnly;
731 * Method hasShowAllColLabels.
733 * @return true if at least one ShowAllColLabels has been added
735 public boolean hasShowAllColLabels()
737 return this._has_showAllColLabels;
743 * @return true if at least one Visible has been added
745 public boolean hasVisible()
747 return this._has_visible;
751 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
752 * the following description: is an autocalculated annotation row
754 * @return the value of field 'AutoCalculated'.
756 public boolean isAutoCalculated()
758 return this._autoCalculated;
762 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
763 * the following description: is to be shown below the alignment - introduced
764 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
766 * @return the value of field 'BelowAlignment'.
768 public boolean isBelowAlignment()
770 return this._belowAlignment;
774 * Returns the value of field 'centreColLabels'.
776 * @return the value of field 'CentreColLabels'.
778 public boolean isCentreColLabels()
780 return this._centreColLabels;
784 * Returns the value of field 'graph'.
786 * @return the value of field 'Graph'.
788 public boolean isGraph()
794 * Returns the value of field 'scaleColLabels'.
796 * @return the value of field 'ScaleColLabels'.
798 public boolean isScaleColLabels()
800 return this._scaleColLabels;
804 * Returns the value of field 'scoreOnly'.
806 * @return the value of field 'ScoreOnly'.
808 public boolean isScoreOnly()
810 return this._scoreOnly;
814 * Returns the value of field 'showAllColLabels'.
816 * @return the value of field 'ShowAllColLabels'.
818 public boolean isShowAllColLabels()
820 return this._showAllColLabels;
826 * @return true if this object is valid according to the schema
828 public boolean isValid()
833 } catch (org.exolab.castor.xml.ValidationException vex)
841 * Returns the value of field 'visible'.
843 * @return the value of field 'Visible'.
845 public boolean isVisible()
847 return this._visible;
854 * @throws org.exolab.castor.xml.MarshalException
855 * if object is null or if any SAXException is thrown during
857 * @throws org.exolab.castor.xml.ValidationException
858 * if this object is an invalid instance according to the schema
860 public void marshal(final java.io.Writer out)
861 throws org.exolab.castor.xml.MarshalException,
862 org.exolab.castor.xml.ValidationException
864 Marshaller.marshal(this, out);
871 * @throws java.io.IOException
872 * if an IOException occurs during marshaling
873 * @throws org.exolab.castor.xml.ValidationException
874 * if this object is an invalid instance according to the schema
875 * @throws org.exolab.castor.xml.MarshalException
876 * if object is null or if any SAXException is thrown during
879 public void marshal(final org.xml.sax.ContentHandler handler)
880 throws java.io.IOException,
881 org.exolab.castor.xml.MarshalException,
882 org.exolab.castor.xml.ValidationException
884 Marshaller.marshal(this, handler);
889 public void removeAllAnnotationElement()
891 this._annotationElementList.clear();
895 * Method removeAnnotationElement.
897 * @param vAnnotationElement
898 * @return true if the object was removed from the collection.
900 public boolean removeAnnotationElement(
901 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
903 boolean removed = _annotationElementList.remove(vAnnotationElement);
908 * Method removeAnnotationElementAt.
911 * @return the element removed from the collection
913 public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(
916 java.lang.Object obj = this._annotationElementList.remove(index);
917 return (jalview.schemabinding.version2.AnnotationElement) obj;
924 * @param vAnnotationElement
925 * @throws java.lang.IndexOutOfBoundsException
926 * if the index given is outside the bounds of the collection
928 public void setAnnotationElement(
930 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
931 throws java.lang.IndexOutOfBoundsException
933 // check bounds for index
934 if (index < 0 || index >= this._annotationElementList.size())
936 throw new IndexOutOfBoundsException(
937 "setAnnotationElement: Index value '" + index
938 + "' not in range [0.."
939 + (this._annotationElementList.size() - 1) + "]");
942 this._annotationElementList.set(index, vAnnotationElement);
948 * @param vAnnotationElementArray
950 public void setAnnotationElement(
951 final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray)
954 _annotationElementList.clear();
956 for (int i = 0; i < vAnnotationElementArray.length; i++)
958 this._annotationElementList.add(vAnnotationElementArray[i]);
963 * Sets the value of field 'autoCalculated'. The field 'autoCalculated' has
964 * the following description: is an autocalculated annotation row
966 * @param autoCalculated
967 * the value of field 'autoCalculated'.
969 public void setAutoCalculated(final boolean autoCalculated)
971 this._autoCalculated = autoCalculated;
972 this._has_autoCalculated = true;
976 * Sets the value of field 'belowAlignment'. The field 'belowAlignment' has
977 * the following description: is to be shown below the alignment - introduced
978 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
980 * @param belowAlignment
981 * the value of field 'belowAlignment'.
983 public void setBelowAlignment(final boolean belowAlignment)
985 this._belowAlignment = belowAlignment;
986 this._has_belowAlignment = true;
990 * Sets the value of field 'calcId'. The field 'calcId' has the following
991 * description: Optional string identifier used to group sets of annotation
992 * produced by a particular calculation. Values are opaque strings but have
993 * semantic meaning to Jalview's renderer, data importer and calculation
997 * the value of field 'calcId'.
999 public void setCalcId(final java.lang.String calcId)
1001 this._calcId = calcId;
1005 * Sets the value of field 'centreColLabels'.
1007 * @param centreColLabels
1008 * the value of field 'centreColLabels'.
1010 public void setCentreColLabels(final boolean centreColLabels)
1012 this._centreColLabels = centreColLabels;
1013 this._has_centreColLabels = true;
1017 * Sets the value of field 'description'.
1019 * @param description
1020 * the value of field 'description'.
1022 public void setDescription(final java.lang.String description)
1024 this._description = description;
1028 * Sets the value of field 'graph'.
1031 * the value of field 'graph'.
1033 public void setGraph(final boolean graph)
1035 this._graph = graph;
1036 this._has_graph = true;
1040 * Sets the value of field 'graphColour'.
1042 * @param graphColour
1043 * the value of field 'graphColour'.
1045 public void setGraphColour(final int graphColour)
1047 this._graphColour = graphColour;
1048 this._has_graphColour = true;
1052 * Sets the value of field 'graphGroup'.
1055 * the value of field 'graphGroup'.
1057 public void setGraphGroup(final int graphGroup)
1059 this._graphGroup = graphGroup;
1060 this._has_graphGroup = true;
1064 * Sets the value of field 'graphHeight'. The field 'graphHeight' has the
1065 * following description: height in pixels for the graph if this is a
1066 * graph-type annotation.
1068 * @param graphHeight
1069 * the value of field 'graphHeight'.
1071 public void setGraphHeight(final int graphHeight)
1073 this._graphHeight = graphHeight;
1074 this._has_graphHeight = true;
1078 * Sets the value of field 'graphType'.
1081 * the value of field 'graphType'.
1083 public void setGraphType(final int graphType)
1085 this._graphType = graphType;
1086 this._has_graphType = true;
1090 * Sets the value of field 'groupRef'.
1093 * the value of field 'groupRef'.
1095 public void setGroupRef(final java.lang.String groupRef)
1097 this._groupRef = groupRef;
1101 * Sets the value of field 'id'.
1104 * the value of field 'id'.
1106 public void setId(final java.lang.String id)
1112 * Sets the value of field 'label'.
1115 * the value of field 'label'.
1117 public void setLabel(final java.lang.String label)
1119 this._label = label;
1123 * Sets the value of field 'scaleColLabels'.
1125 * @param scaleColLabels
1126 * the value of field 'scaleColLabels'.
1128 public void setScaleColLabels(final boolean scaleColLabels)
1130 this._scaleColLabels = scaleColLabels;
1131 this._has_scaleColLabels = true;
1135 * Sets the value of field 'score'.
1138 * the value of field 'score'.
1140 public void setScore(final double score)
1142 this._score = score;
1143 this._has_score = true;
1147 * Sets the value of field 'scoreOnly'.
1150 * the value of field 'scoreOnly'.
1152 public void setScoreOnly(final boolean scoreOnly)
1154 this._scoreOnly = scoreOnly;
1155 this._has_scoreOnly = true;
1159 * Sets the value of field 'sequenceRef'.
1161 * @param sequenceRef
1162 * the value of field 'sequenceRef'.
1164 public void setSequenceRef(final java.lang.String sequenceRef)
1166 this._sequenceRef = sequenceRef;
1170 * Sets the value of field 'showAllColLabels'.
1172 * @param showAllColLabels
1173 * the value of field 'showAllColLabels'
1175 public void setShowAllColLabels(final boolean showAllColLabels)
1177 this._showAllColLabels = showAllColLabels;
1178 this._has_showAllColLabels = true;
1182 * Sets the value of field 'thresholdLine'.
1184 * @param thresholdLine
1185 * the value of field 'thresholdLine'.
1187 public void setThresholdLine(
1188 final jalview.schemabinding.version2.ThresholdLine thresholdLine)
1190 this._thresholdLine = thresholdLine;
1194 * Sets the value of field 'visible'.
1197 * the value of field 'visible'.
1199 public void setVisible(final boolean visible)
1201 this._visible = visible;
1202 this._has_visible = true;
1209 * @throws org.exolab.castor.xml.MarshalException
1210 * if object is null or if any SAXException is thrown during
1212 * @throws org.exolab.castor.xml.ValidationException
1213 * if this object is an invalid instance according to the schema
1214 * @return the unmarshaled jalview.schemabinding.version2.Annotation
1216 public static jalview.schemabinding.version2.Annotation unmarshal(
1217 final java.io.Reader reader)
1218 throws org.exolab.castor.xml.MarshalException,
1219 org.exolab.castor.xml.ValidationException
1221 return (jalview.schemabinding.version2.Annotation) Unmarshaller
1222 .unmarshal(jalview.schemabinding.version2.Annotation.class,
1229 * @throws org.exolab.castor.xml.ValidationException
1230 * if this object is an invalid instance according to the schema
1232 public void validate() throws org.exolab.castor.xml.ValidationException
1234 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1235 validator.validate(this);