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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class Annotation implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private boolean _graph;
50 * keeps track of state for field: _graph
52 private boolean _has_graph;
57 private int _graphType;
60 * keeps track of state for field: _graphType
62 private boolean _has_graphType;
67 private java.lang.String _sequenceRef;
72 private java.lang.String _groupRef;
77 private int _graphColour;
80 * keeps track of state for field: _graphColour
82 private boolean _has_graphColour;
87 private int _graphGroup;
90 * keeps track of state for field: _graphGroup
92 private boolean _has_graphGroup;
95 * height in pixels for the graph if this is a graph-type annotation.
97 private int _graphHeight;
100 * keeps track of state for field: _graphHeight
102 private boolean _has_graphHeight;
107 private java.lang.String _id;
112 private boolean _scoreOnly = false;
115 * keeps track of state for field: _scoreOnly
117 private boolean _has_scoreOnly;
122 private double _score;
125 * keeps track of state for field: _score
127 private boolean _has_score;
132 private boolean _visible;
135 * keeps track of state for field: _visible
137 private boolean _has_visible;
140 * Field _centreColLabels.
142 private boolean _centreColLabels;
145 * keeps track of state for field: _centreColLabels
147 private boolean _has_centreColLabels;
150 * Field _scaleColLabels.
152 private boolean _scaleColLabels;
155 * keeps track of state for field: _scaleColLabels
157 private boolean _has_scaleColLabels;
160 * Field _showAllColLabels.
162 private boolean _showAllColLabels;
165 * keeps track of state for field: _showAllColLabels
167 private boolean _has_showAllColLabels;
170 * is an autocalculated annotation row
172 private boolean _autoCalculated = false;
175 * keeps track of state for field: _autoCalculated
177 private boolean _has_autoCalculated;
180 * is to be shown below the alignment - introduced in Jalview 2.8 for
181 * visualizing T-COFFEE alignment scores
183 private boolean _belowAlignment = true;
186 * keeps track of state for field: _belowAlignment
188 private boolean _has_belowAlignment;
191 * Optional string identifier used to group sets of annotation produced by a
192 * particular calculation. Values are opaque strings but have semantic meaning
193 * to Jalview's renderer, data importer and calculation system.
195 private java.lang.String _calcId;
198 * Field _annotationElementList.
200 private java.util.Vector _annotationElementList;
205 private java.lang.String _label;
208 * Field _description.
210 private java.lang.String _description;
213 * Field _thresholdLine.
215 private jalview.schemabinding.version2.ThresholdLine _thresholdLine;
224 this._annotationElementList = new java.util.Vector();
234 * @param vAnnotationElement
235 * @throws java.lang.IndexOutOfBoundsException
236 * if the index given is outside the bounds of the collection
238 public void addAnnotationElement(
239 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
240 throws java.lang.IndexOutOfBoundsException
242 this._annotationElementList.addElement(vAnnotationElement);
249 * @param vAnnotationElement
250 * @throws java.lang.IndexOutOfBoundsException
251 * if the index given is outside the bounds of the collection
253 public void addAnnotationElement(
255 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
256 throws java.lang.IndexOutOfBoundsException
258 this._annotationElementList.add(index, vAnnotationElement);
263 public void deleteAutoCalculated()
265 this._has_autoCalculated = false;
270 public void deleteBelowAlignment()
272 this._has_belowAlignment = false;
277 public void deleteCentreColLabels()
279 this._has_centreColLabels = false;
284 public void deleteGraph()
286 this._has_graph = false;
291 public void deleteGraphColour()
293 this._has_graphColour = false;
298 public void deleteGraphGroup()
300 this._has_graphGroup = false;
305 public void deleteGraphHeight()
307 this._has_graphHeight = false;
312 public void deleteGraphType()
314 this._has_graphType = false;
319 public void deleteScaleColLabels()
321 this._has_scaleColLabels = false;
326 public void deleteScore()
328 this._has_score = false;
333 public void deleteScoreOnly()
335 this._has_scoreOnly = false;
340 public void deleteShowAllColLabels()
342 this._has_showAllColLabels = false;
347 public void deleteVisible()
349 this._has_visible = false;
353 * Method enumerateAnnotationElement.
355 * @return an Enumeration over all
356 * jalview.schemabinding.version2.AnnotationElement elements
358 public java.util.Enumeration enumerateAnnotationElement()
360 return this._annotationElementList.elements();
364 * Method getAnnotationElement.
367 * @throws java.lang.IndexOutOfBoundsException
368 * if the index given is outside the bounds of the collection
369 * @return the value of the jalview.schemabinding.version2.AnnotationElement
372 public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(
373 final int index) throws java.lang.IndexOutOfBoundsException
375 // check bounds for index
376 if (index < 0 || index >= this._annotationElementList.size())
378 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
379 "getAnnotationElement",
380 Integer.valueOf(index).toString(),
381 Integer.valueOf((this._annotationElementList.size() - 1)).toString()
385 return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList
390 * Method getAnnotationElement.Returns the contents of the collection in an
393 * Note: Just in case the collection contents are changing in another thread,
394 * we pass a 0-length Array of the correct type into the API call. This way we
395 * <i>know</i> that the Array returned is of exactly the correct length.
397 * @return this collection as an Array
399 public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement()
401 jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];
402 return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList
407 * Method getAnnotationElementCount.
409 * @return the size of this collection
411 public int getAnnotationElementCount()
413 return this._annotationElementList.size();
417 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
418 * the following description: is an autocalculated annotation row
420 * @return the value of field 'AutoCalculated'.
422 public boolean getAutoCalculated()
424 return this._autoCalculated;
428 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
429 * the following description: is to be shown below the alignment - introduced
430 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
432 * @return the value of field 'BelowAlignment'.
434 public boolean getBelowAlignment()
436 return this._belowAlignment;
440 * Returns the value of field 'calcId'. The field 'calcId' has the following
441 * description: Optional string identifier used to group sets of annotation
442 * produced by a particular calculation. Values are opaque strings but have
443 * semantic meaning to Jalview's renderer, data importer and calculation
446 * @return the value of field 'CalcId'.
448 public java.lang.String getCalcId()
454 * Returns the value of field 'centreColLabels'.
456 * @return the value of field 'CentreColLabels'.
458 public boolean getCentreColLabels()
460 return this._centreColLabels;
464 * Returns the value of field 'description'.
466 * @return the value of field 'Description'.
468 public java.lang.String getDescription()
470 return this._description;
474 * Returns the value of field 'graph'.
476 * @return the value of field 'Graph'.
478 public boolean getGraph()
484 * Returns the value of field 'graphColour'.
486 * @return the value of field 'GraphColour'.
488 public int getGraphColour()
490 return this._graphColour;
494 * Returns the value of field 'graphGroup'.
496 * @return the value of field 'GraphGroup'.
498 public int getGraphGroup()
500 return this._graphGroup;
504 * Returns the value of field 'graphHeight'. The field 'graphHeight' has the
505 * following description: height in pixels for the graph if this is a
506 * graph-type annotation.
508 * @return the value of field 'GraphHeight'.
510 public int getGraphHeight()
512 return this._graphHeight;
516 * Returns the value of field 'graphType'.
518 * @return the value of field 'GraphType'.
520 public int getGraphType()
522 return this._graphType;
526 * Returns the value of field 'groupRef'.
528 * @return the value of field 'GroupRef'.
530 public java.lang.String getGroupRef()
532 return this._groupRef;
536 * Returns the value of field 'id'.
538 * @return the value of field 'Id'.
540 public java.lang.String getId()
546 * Returns the value of field 'label'.
548 * @return the value of field 'Label'.
550 public java.lang.String getLabel()
556 * Returns the value of field 'scaleColLabels'.
558 * @return the value of field 'ScaleColLabels'.
560 public boolean getScaleColLabels()
562 return this._scaleColLabels;
566 * Returns the value of field 'score'.
568 * @return the value of field 'Score'.
570 public double getScore()
576 * Returns the value of field 'scoreOnly'.
578 * @return the value of field 'ScoreOnly'.
580 public boolean getScoreOnly()
582 return this._scoreOnly;
586 * Returns the value of field 'sequenceRef'.
588 * @return the value of field 'SequenceRef'.
590 public java.lang.String getSequenceRef()
592 return this._sequenceRef;
596 * Returns the value of field 'showAllColLabels'.
598 * @return the value of field 'ShowAllColLabels'.
600 public boolean getShowAllColLabels()
602 return this._showAllColLabels;
606 * Returns the value of field 'thresholdLine'.
608 * @return the value of field 'ThresholdLine'.
610 public jalview.schemabinding.version2.ThresholdLine getThresholdLine()
612 return this._thresholdLine;
616 * Returns the value of field 'visible'.
618 * @return the value of field 'Visible'.
620 public boolean getVisible()
622 return this._visible;
626 * Method hasAutoCalculated.
628 * @return true if at least one AutoCalculated has been added
630 public boolean hasAutoCalculated()
632 return this._has_autoCalculated;
636 * Method hasBelowAlignment.
638 * @return true if at least one BelowAlignment has been added
640 public boolean hasBelowAlignment()
642 return this._has_belowAlignment;
646 * Method hasCentreColLabels.
648 * @return true if at least one CentreColLabels has been added
650 public boolean hasCentreColLabels()
652 return this._has_centreColLabels;
658 * @return true if at least one Graph has been added
660 public boolean hasGraph()
662 return this._has_graph;
666 * Method hasGraphColour.
668 * @return true if at least one GraphColour has been added
670 public boolean hasGraphColour()
672 return this._has_graphColour;
676 * Method hasGraphGroup.
678 * @return true if at least one GraphGroup has been added
680 public boolean hasGraphGroup()
682 return this._has_graphGroup;
686 * Method hasGraphHeight.
688 * @return true if at least one GraphHeight has been added
690 public boolean hasGraphHeight()
692 return this._has_graphHeight;
696 * Method hasGraphType.
698 * @return true if at least one GraphType has been added
700 public boolean hasGraphType()
702 return this._has_graphType;
706 * Method hasScaleColLabels.
708 * @return true if at least one ScaleColLabels has been added
710 public boolean hasScaleColLabels()
712 return this._has_scaleColLabels;
718 * @return true if at least one Score has been added
720 public boolean hasScore()
722 return this._has_score;
726 * Method hasScoreOnly.
728 * @return true if at least one ScoreOnly has been added
730 public boolean hasScoreOnly()
732 return this._has_scoreOnly;
736 * Method hasShowAllColLabels.
738 * @return true if at least one ShowAllColLabels has been added
740 public boolean hasShowAllColLabels()
742 return this._has_showAllColLabels;
748 * @return true if at least one Visible has been added
750 public boolean hasVisible()
752 return this._has_visible;
756 * Returns the value of field 'autoCalculated'. The field 'autoCalculated' has
757 * the following description: is an autocalculated annotation row
759 * @return the value of field 'AutoCalculated'.
761 public boolean isAutoCalculated()
763 return this._autoCalculated;
767 * Returns the value of field 'belowAlignment'. The field 'belowAlignment' has
768 * the following description: is to be shown below the alignment - introduced
769 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
771 * @return the value of field 'BelowAlignment'.
773 public boolean isBelowAlignment()
775 return this._belowAlignment;
779 * Returns the value of field 'centreColLabels'.
781 * @return the value of field 'CentreColLabels'.
783 public boolean isCentreColLabels()
785 return this._centreColLabels;
789 * Returns the value of field 'graph'.
791 * @return the value of field 'Graph'.
793 public boolean isGraph()
799 * Returns the value of field 'scaleColLabels'.
801 * @return the value of field 'ScaleColLabels'.
803 public boolean isScaleColLabels()
805 return this._scaleColLabels;
809 * Returns the value of field 'scoreOnly'.
811 * @return the value of field 'ScoreOnly'.
813 public boolean isScoreOnly()
815 return this._scoreOnly;
819 * Returns the value of field 'showAllColLabels'.
821 * @return the value of field 'ShowAllColLabels'.
823 public boolean isShowAllColLabels()
825 return this._showAllColLabels;
831 * @return true if this object is valid according to the schema
833 public boolean isValid()
838 } catch (org.exolab.castor.xml.ValidationException vex)
846 * Returns the value of field 'visible'.
848 * @return the value of field 'Visible'.
850 public boolean isVisible()
852 return this._visible;
859 * @throws org.exolab.castor.xml.MarshalException
860 * if object is null or if any SAXException is thrown during
862 * @throws org.exolab.castor.xml.ValidationException
863 * if this object is an invalid instance according to the schema
865 public void marshal(final java.io.Writer out)
866 throws org.exolab.castor.xml.MarshalException,
867 org.exolab.castor.xml.ValidationException
869 Marshaller.marshal(this, out);
876 * @throws java.io.IOException
877 * if an IOException occurs during marshaling
878 * @throws org.exolab.castor.xml.ValidationException
879 * if this object is an invalid instance according to the schema
880 * @throws org.exolab.castor.xml.MarshalException
881 * if object is null or if any SAXException is thrown during
884 public void marshal(final org.xml.sax.ContentHandler handler)
885 throws java.io.IOException,
886 org.exolab.castor.xml.MarshalException,
887 org.exolab.castor.xml.ValidationException
889 Marshaller.marshal(this, handler);
894 public void removeAllAnnotationElement()
896 this._annotationElementList.clear();
900 * Method removeAnnotationElement.
902 * @param vAnnotationElement
903 * @return true if the object was removed from the collection.
905 public boolean removeAnnotationElement(
906 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
908 boolean removed = _annotationElementList.remove(vAnnotationElement);
913 * Method removeAnnotationElementAt.
916 * @return the element removed from the collection
918 public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(
921 java.lang.Object obj = this._annotationElementList.remove(index);
922 return (jalview.schemabinding.version2.AnnotationElement) obj;
929 * @param vAnnotationElement
930 * @throws java.lang.IndexOutOfBoundsException
931 * if the index given is outside the bounds of the collection
933 public void setAnnotationElement(
935 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
936 throws java.lang.IndexOutOfBoundsException
938 // check bounds for index
939 if (index < 0 || index >= this._annotationElementList.size())
941 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
942 "setAnnotationElement",
943 Integer.valueOf(index).toString(),
944 Integer.valueOf((this._annotationElementList.size() - 1)).toString()
948 this._annotationElementList.set(index, vAnnotationElement);
954 * @param vAnnotationElementArray
956 public void setAnnotationElement(
957 final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray)
960 _annotationElementList.clear();
962 for (int i = 0; i < vAnnotationElementArray.length; i++)
964 this._annotationElementList.add(vAnnotationElementArray[i]);
969 * Sets the value of field 'autoCalculated'. The field 'autoCalculated' has
970 * the following description: is an autocalculated annotation row
972 * @param autoCalculated
973 * the value of field 'autoCalculated'.
975 public void setAutoCalculated(final boolean autoCalculated)
977 this._autoCalculated = autoCalculated;
978 this._has_autoCalculated = true;
982 * Sets the value of field 'belowAlignment'. The field 'belowAlignment' has
983 * the following description: is to be shown below the alignment - introduced
984 * in Jalview 2.8 for visualizing T-COFFEE alignment scores
986 * @param belowAlignment
987 * the value of field 'belowAlignment'.
989 public void setBelowAlignment(final boolean belowAlignment)
991 this._belowAlignment = belowAlignment;
992 this._has_belowAlignment = true;
996 * Sets the value of field 'calcId'. The field 'calcId' has the following
997 * description: Optional string identifier used to group sets of annotation
998 * produced by a particular calculation. Values are opaque strings but have
999 * semantic meaning to Jalview's renderer, data importer and calculation
1003 * the value of field 'calcId'.
1005 public void setCalcId(final java.lang.String calcId)
1007 this._calcId = calcId;
1011 * Sets the value of field 'centreColLabels'.
1013 * @param centreColLabels
1014 * the value of field 'centreColLabels'.
1016 public void setCentreColLabels(final boolean centreColLabels)
1018 this._centreColLabels = centreColLabels;
1019 this._has_centreColLabels = true;
1023 * Sets the value of field 'description'.
1025 * @param description
1026 * the value of field 'description'.
1028 public void setDescription(final java.lang.String description)
1030 this._description = description;
1034 * Sets the value of field 'graph'.
1037 * the value of field 'graph'.
1039 public void setGraph(final boolean graph)
1041 this._graph = graph;
1042 this._has_graph = true;
1046 * Sets the value of field 'graphColour'.
1048 * @param graphColour
1049 * the value of field 'graphColour'.
1051 public void setGraphColour(final int graphColour)
1053 this._graphColour = graphColour;
1054 this._has_graphColour = true;
1058 * Sets the value of field 'graphGroup'.
1061 * the value of field 'graphGroup'.
1063 public void setGraphGroup(final int graphGroup)
1065 this._graphGroup = graphGroup;
1066 this._has_graphGroup = true;
1070 * Sets the value of field 'graphHeight'. The field 'graphHeight' has the
1071 * following description: height in pixels for the graph if this is a
1072 * graph-type annotation.
1074 * @param graphHeight
1075 * the value of field 'graphHeight'.
1077 public void setGraphHeight(final int graphHeight)
1079 this._graphHeight = graphHeight;
1080 this._has_graphHeight = true;
1084 * Sets the value of field 'graphType'.
1087 * the value of field 'graphType'.
1089 public void setGraphType(final int graphType)
1091 this._graphType = graphType;
1092 this._has_graphType = true;
1096 * Sets the value of field 'groupRef'.
1099 * the value of field 'groupRef'.
1101 public void setGroupRef(final java.lang.String groupRef)
1103 this._groupRef = groupRef;
1107 * Sets the value of field 'id'.
1110 * the value of field 'id'.
1112 public void setId(final java.lang.String id)
1118 * Sets the value of field 'label'.
1121 * the value of field 'label'.
1123 public void setLabel(final java.lang.String label)
1125 this._label = label;
1129 * Sets the value of field 'scaleColLabels'.
1131 * @param scaleColLabels
1132 * the value of field 'scaleColLabels'.
1134 public void setScaleColLabels(final boolean scaleColLabels)
1136 this._scaleColLabels = scaleColLabels;
1137 this._has_scaleColLabels = true;
1141 * Sets the value of field 'score'.
1144 * the value of field 'score'.
1146 public void setScore(final double score)
1148 this._score = score;
1149 this._has_score = true;
1153 * Sets the value of field 'scoreOnly'.
1156 * the value of field 'scoreOnly'.
1158 public void setScoreOnly(final boolean scoreOnly)
1160 this._scoreOnly = scoreOnly;
1161 this._has_scoreOnly = true;
1165 * Sets the value of field 'sequenceRef'.
1167 * @param sequenceRef
1168 * the value of field 'sequenceRef'.
1170 public void setSequenceRef(final java.lang.String sequenceRef)
1172 this._sequenceRef = sequenceRef;
1176 * Sets the value of field 'showAllColLabels'.
1178 * @param showAllColLabels
1179 * the value of field 'showAllColLabels'
1181 public void setShowAllColLabels(final boolean showAllColLabels)
1183 this._showAllColLabels = showAllColLabels;
1184 this._has_showAllColLabels = true;
1188 * Sets the value of field 'thresholdLine'.
1190 * @param thresholdLine
1191 * the value of field 'thresholdLine'.
1193 public void setThresholdLine(
1194 final jalview.schemabinding.version2.ThresholdLine thresholdLine)
1196 this._thresholdLine = thresholdLine;
1200 * Sets the value of field 'visible'.
1203 * the value of field 'visible'.
1205 public void setVisible(final boolean visible)
1207 this._visible = visible;
1208 this._has_visible = true;
1215 * @throws org.exolab.castor.xml.MarshalException
1216 * if object is null or if any SAXException is thrown during
1218 * @throws org.exolab.castor.xml.ValidationException
1219 * if this object is an invalid instance according to the schema
1220 * @return the unmarshaled jalview.schemabinding.version2.Annotation
1222 public static jalview.schemabinding.version2.Annotation unmarshal(
1223 final java.io.Reader reader)
1224 throws org.exolab.castor.xml.MarshalException,
1225 org.exolab.castor.xml.ValidationException
1227 return (jalview.schemabinding.version2.Annotation) Unmarshaller
1228 .unmarshal(jalview.schemabinding.version2.Annotation.class,
1235 * @throws org.exolab.castor.xml.ValidationException
1236 * if this object is an invalid instance according to the schema
1238 public void validate() throws org.exolab.castor.xml.ValidationException
1240 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1241 validator.validate(this);