apply gpl development license
[jalview.git] / src / jalview / schemabinding / version2 / Annotation.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2;\r
20 \r
21   //---------------------------------/\r
22  //- Imported classes and packages -/\r
23 //---------------------------------/\r
24 \r
25 import org.exolab.castor.xml.Marshaller;\r
26 import org.exolab.castor.xml.Unmarshaller;\r
27 \r
28 /**\r
29  * Class Annotation.\r
30  * \r
31  * @version $Revision$ $Date$\r
32  */\r
33 public class Annotation implements java.io.Serializable {\r
34 \r
35 \r
36       //--------------------------/\r
37      //- Class/Member Variables -/\r
38     //--------------------------/\r
39 \r
40     /**\r
41      * Field _graph.\r
42      */\r
43     private boolean _graph;\r
44 \r
45     /**\r
46      * keeps track of state for field: _graph\r
47      */\r
48     private boolean _has_graph;\r
49 \r
50     /**\r
51      * Field _graphType.\r
52      */\r
53     private int _graphType;\r
54 \r
55     /**\r
56      * keeps track of state for field: _graphType\r
57      */\r
58     private boolean _has_graphType;\r
59 \r
60     /**\r
61      * Field _sequenceRef.\r
62      */\r
63     private java.lang.String _sequenceRef;\r
64 \r
65     /**\r
66      * Field _graphColour.\r
67      */\r
68     private int _graphColour;\r
69 \r
70     /**\r
71      * keeps track of state for field: _graphColour\r
72      */\r
73     private boolean _has_graphColour;\r
74 \r
75     /**\r
76      * Field _graphGroup.\r
77      */\r
78     private int _graphGroup;\r
79 \r
80     /**\r
81      * keeps track of state for field: _graphGroup\r
82      */\r
83     private boolean _has_graphGroup;\r
84 \r
85     /**\r
86      * Field _id.\r
87      */\r
88     private java.lang.String _id;\r
89 \r
90     /**\r
91      * Field _scoreOnly.\r
92      */\r
93     private boolean _scoreOnly = false;\r
94 \r
95     /**\r
96      * keeps track of state for field: _scoreOnly\r
97      */\r
98     private boolean _has_scoreOnly;\r
99 \r
100     /**\r
101      * Field _score.\r
102      */\r
103     private double _score;\r
104 \r
105     /**\r
106      * keeps track of state for field: _score\r
107      */\r
108     private boolean _has_score;\r
109 \r
110     /**\r
111      * Field _visible.\r
112      */\r
113     private boolean _visible;\r
114 \r
115     /**\r
116      * keeps track of state for field: _visible\r
117      */\r
118     private boolean _has_visible;\r
119 \r
120     /**\r
121      * Field _annotationElementList.\r
122      */\r
123     private java.util.Vector _annotationElementList;\r
124 \r
125     /**\r
126      * Field _label.\r
127      */\r
128     private java.lang.String _label;\r
129 \r
130     /**\r
131      * Field _description.\r
132      */\r
133     private java.lang.String _description;\r
134 \r
135     /**\r
136      * Field _thresholdLine.\r
137      */\r
138     private jalview.schemabinding.version2.ThresholdLine _thresholdLine;\r
139 \r
140 \r
141       //----------------/\r
142      //- Constructors -/\r
143     //----------------/\r
144 \r
145     public Annotation() {\r
146         super();\r
147         this._annotationElementList = new java.util.Vector();\r
148     }\r
149 \r
150 \r
151       //-----------/\r
152      //- Methods -/\r
153     //-----------/\r
154 \r
155     /**\r
156      * \r
157      * \r
158      * @param vAnnotationElement\r
159      * @throws java.lang.IndexOutOfBoundsException if the index\r
160      * given is outside the bounds of the collection\r
161      */\r
162     public void addAnnotationElement(\r
163             final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)\r
164     throws java.lang.IndexOutOfBoundsException {\r
165         this._annotationElementList.addElement(vAnnotationElement);\r
166     }\r
167 \r
168     /**\r
169      * \r
170      * \r
171      * @param index\r
172      * @param vAnnotationElement\r
173      * @throws java.lang.IndexOutOfBoundsException if the index\r
174      * given is outside the bounds of the collection\r
175      */\r
176     public void addAnnotationElement(\r
177             final int index,\r
178             final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)\r
179     throws java.lang.IndexOutOfBoundsException {\r
180         this._annotationElementList.add(index, vAnnotationElement);\r
181     }\r
182 \r
183     /**\r
184      */\r
185     public void deleteGraph(\r
186     ) {\r
187         this._has_graph= false;\r
188     }\r
189 \r
190     /**\r
191      */\r
192     public void deleteGraphColour(\r
193     ) {\r
194         this._has_graphColour= false;\r
195     }\r
196 \r
197     /**\r
198      */\r
199     public void deleteGraphGroup(\r
200     ) {\r
201         this._has_graphGroup= false;\r
202     }\r
203 \r
204     /**\r
205      */\r
206     public void deleteGraphType(\r
207     ) {\r
208         this._has_graphType= false;\r
209     }\r
210 \r
211     /**\r
212      */\r
213     public void deleteScore(\r
214     ) {\r
215         this._has_score= false;\r
216     }\r
217 \r
218     /**\r
219      */\r
220     public void deleteScoreOnly(\r
221     ) {\r
222         this._has_scoreOnly= false;\r
223     }\r
224 \r
225     /**\r
226      */\r
227     public void deleteVisible(\r
228     ) {\r
229         this._has_visible= false;\r
230     }\r
231 \r
232     /**\r
233      * Method enumerateAnnotationElement.\r
234      * \r
235      * @return an Enumeration over all\r
236      * jalview.schemabinding.version2.AnnotationElement elements\r
237      */\r
238     public java.util.Enumeration enumerateAnnotationElement(\r
239     ) {\r
240         return this._annotationElementList.elements();\r
241     }\r
242 \r
243     /**\r
244      * Method getAnnotationElement.\r
245      * \r
246      * @param index\r
247      * @throws java.lang.IndexOutOfBoundsException if the index\r
248      * given is outside the bounds of the collection\r
249      * @return the value of the\r
250      * jalview.schemabinding.version2.AnnotationElement at the\r
251      * given index\r
252      */\r
253     public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(\r
254             final int index)\r
255     throws java.lang.IndexOutOfBoundsException {\r
256         // check bounds for index\r
257         if (index < 0 || index >= this._annotationElementList.size()) {\r
258             throw new IndexOutOfBoundsException("getAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]");\r
259         }\r
260         \r
261         return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList.get(index);\r
262     }\r
263 \r
264     /**\r
265      * Method getAnnotationElement.Returns the contents of the\r
266      * collection in an Array.  <p>Note:  Just in case the\r
267      * collection contents are changing in another thread, we pass\r
268      * a 0-length Array of the correct type into the API call. \r
269      * This way we <i>know</i> that the Array returned is of\r
270      * exactly the correct length.\r
271      * \r
272      * @return this collection as an Array\r
273      */\r
274     public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement(\r
275     ) {\r
276         jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];\r
277         return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList.toArray(array);\r
278     }\r
279 \r
280     /**\r
281      * Method getAnnotationElementCount.\r
282      * \r
283      * @return the size of this collection\r
284      */\r
285     public int getAnnotationElementCount(\r
286     ) {\r
287         return this._annotationElementList.size();\r
288     }\r
289 \r
290     /**\r
291      * Returns the value of field 'description'.\r
292      * \r
293      * @return the value of field 'Description'.\r
294      */\r
295     public java.lang.String getDescription(\r
296     ) {\r
297         return this._description;\r
298     }\r
299 \r
300     /**\r
301      * Returns the value of field 'graph'.\r
302      * \r
303      * @return the value of field 'Graph'.\r
304      */\r
305     public boolean getGraph(\r
306     ) {\r
307         return this._graph;\r
308     }\r
309 \r
310     /**\r
311      * Returns the value of field 'graphColour'.\r
312      * \r
313      * @return the value of field 'GraphColour'.\r
314      */\r
315     public int getGraphColour(\r
316     ) {\r
317         return this._graphColour;\r
318     }\r
319 \r
320     /**\r
321      * Returns the value of field 'graphGroup'.\r
322      * \r
323      * @return the value of field 'GraphGroup'.\r
324      */\r
325     public int getGraphGroup(\r
326     ) {\r
327         return this._graphGroup;\r
328     }\r
329 \r
330     /**\r
331      * Returns the value of field 'graphType'.\r
332      * \r
333      * @return the value of field 'GraphType'.\r
334      */\r
335     public int getGraphType(\r
336     ) {\r
337         return this._graphType;\r
338     }\r
339 \r
340     /**\r
341      * Returns the value of field 'id'.\r
342      * \r
343      * @return the value of field 'Id'.\r
344      */\r
345     public java.lang.String getId(\r
346     ) {\r
347         return this._id;\r
348     }\r
349 \r
350     /**\r
351      * Returns the value of field 'label'.\r
352      * \r
353      * @return the value of field 'Label'.\r
354      */\r
355     public java.lang.String getLabel(\r
356     ) {\r
357         return this._label;\r
358     }\r
359 \r
360     /**\r
361      * Returns the value of field 'score'.\r
362      * \r
363      * @return the value of field 'Score'.\r
364      */\r
365     public double getScore(\r
366     ) {\r
367         return this._score;\r
368     }\r
369 \r
370     /**\r
371      * Returns the value of field 'scoreOnly'.\r
372      * \r
373      * @return the value of field 'ScoreOnly'.\r
374      */\r
375     public boolean getScoreOnly(\r
376     ) {\r
377         return this._scoreOnly;\r
378     }\r
379 \r
380     /**\r
381      * Returns the value of field 'sequenceRef'.\r
382      * \r
383      * @return the value of field 'SequenceRef'.\r
384      */\r
385     public java.lang.String getSequenceRef(\r
386     ) {\r
387         return this._sequenceRef;\r
388     }\r
389 \r
390     /**\r
391      * Returns the value of field 'thresholdLine'.\r
392      * \r
393      * @return the value of field 'ThresholdLine'.\r
394      */\r
395     public jalview.schemabinding.version2.ThresholdLine getThresholdLine(\r
396     ) {\r
397         return this._thresholdLine;\r
398     }\r
399 \r
400     /**\r
401      * Returns the value of field 'visible'.\r
402      * \r
403      * @return the value of field 'Visible'.\r
404      */\r
405     public boolean getVisible(\r
406     ) {\r
407         return this._visible;\r
408     }\r
409 \r
410     /**\r
411      * Method hasGraph.\r
412      * \r
413      * @return true if at least one Graph has been added\r
414      */\r
415     public boolean hasGraph(\r
416     ) {\r
417         return this._has_graph;\r
418     }\r
419 \r
420     /**\r
421      * Method hasGraphColour.\r
422      * \r
423      * @return true if at least one GraphColour has been added\r
424      */\r
425     public boolean hasGraphColour(\r
426     ) {\r
427         return this._has_graphColour;\r
428     }\r
429 \r
430     /**\r
431      * Method hasGraphGroup.\r
432      * \r
433      * @return true if at least one GraphGroup has been added\r
434      */\r
435     public boolean hasGraphGroup(\r
436     ) {\r
437         return this._has_graphGroup;\r
438     }\r
439 \r
440     /**\r
441      * Method hasGraphType.\r
442      * \r
443      * @return true if at least one GraphType has been added\r
444      */\r
445     public boolean hasGraphType(\r
446     ) {\r
447         return this._has_graphType;\r
448     }\r
449 \r
450     /**\r
451      * Method hasScore.\r
452      * \r
453      * @return true if at least one Score has been added\r
454      */\r
455     public boolean hasScore(\r
456     ) {\r
457         return this._has_score;\r
458     }\r
459 \r
460     /**\r
461      * Method hasScoreOnly.\r
462      * \r
463      * @return true if at least one ScoreOnly has been added\r
464      */\r
465     public boolean hasScoreOnly(\r
466     ) {\r
467         return this._has_scoreOnly;\r
468     }\r
469 \r
470     /**\r
471      * Method hasVisible.\r
472      * \r
473      * @return true if at least one Visible has been added\r
474      */\r
475     public boolean hasVisible(\r
476     ) {\r
477         return this._has_visible;\r
478     }\r
479 \r
480     /**\r
481      * Returns the value of field 'graph'.\r
482      * \r
483      * @return the value of field 'Graph'.\r
484      */\r
485     public boolean isGraph(\r
486     ) {\r
487         return this._graph;\r
488     }\r
489 \r
490     /**\r
491      * Returns the value of field 'scoreOnly'.\r
492      * \r
493      * @return the value of field 'ScoreOnly'.\r
494      */\r
495     public boolean isScoreOnly(\r
496     ) {\r
497         return this._scoreOnly;\r
498     }\r
499 \r
500     /**\r
501      * Method isValid.\r
502      * \r
503      * @return true if this object is valid according to the schema\r
504      */\r
505     public boolean isValid(\r
506     ) {\r
507         try {\r
508             validate();\r
509         } catch (org.exolab.castor.xml.ValidationException vex) {\r
510             return false;\r
511         }\r
512         return true;\r
513     }\r
514 \r
515     /**\r
516      * Returns the value of field 'visible'.\r
517      * \r
518      * @return the value of field 'Visible'.\r
519      */\r
520     public boolean isVisible(\r
521     ) {\r
522         return this._visible;\r
523     }\r
524 \r
525     /**\r
526      * \r
527      * \r
528      * @param out\r
529      * @throws org.exolab.castor.xml.MarshalException if object is\r
530      * null or if any SAXException is thrown during marshaling\r
531      * @throws org.exolab.castor.xml.ValidationException if this\r
532      * object is an invalid instance according to the schema\r
533      */\r
534     public void marshal(\r
535             final java.io.Writer out)\r
536     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
537         Marshaller.marshal(this, out);\r
538     }\r
539 \r
540     /**\r
541      * \r
542      * \r
543      * @param handler\r
544      * @throws java.io.IOException if an IOException occurs during\r
545      * marshaling\r
546      * @throws org.exolab.castor.xml.ValidationException if this\r
547      * object is an invalid instance according to the schema\r
548      * @throws org.exolab.castor.xml.MarshalException if object is\r
549      * null or if any SAXException is thrown during marshaling\r
550      */\r
551     public void marshal(\r
552             final org.xml.sax.ContentHandler handler)\r
553     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
554         Marshaller.marshal(this, handler);\r
555     }\r
556 \r
557     /**\r
558      */\r
559     public void removeAllAnnotationElement(\r
560     ) {\r
561         this._annotationElementList.clear();\r
562     }\r
563 \r
564     /**\r
565      * Method removeAnnotationElement.\r
566      * \r
567      * @param vAnnotationElement\r
568      * @return true if the object was removed from the collection.\r
569      */\r
570     public boolean removeAnnotationElement(\r
571             final jalview.schemabinding.version2.AnnotationElement vAnnotationElement) {\r
572         boolean removed = _annotationElementList.remove(vAnnotationElement);\r
573         return removed;\r
574     }\r
575 \r
576     /**\r
577      * Method removeAnnotationElementAt.\r
578      * \r
579      * @param index\r
580      * @return the element removed from the collection\r
581      */\r
582     public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(\r
583             final int index) {\r
584         java.lang.Object obj = this._annotationElementList.remove(index);\r
585         return (jalview.schemabinding.version2.AnnotationElement) obj;\r
586     }\r
587 \r
588     /**\r
589      * \r
590      * \r
591      * @param index\r
592      * @param vAnnotationElement\r
593      * @throws java.lang.IndexOutOfBoundsException if the index\r
594      * given is outside the bounds of the collection\r
595      */\r
596     public void setAnnotationElement(\r
597             final int index,\r
598             final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)\r
599     throws java.lang.IndexOutOfBoundsException {\r
600         // check bounds for index\r
601         if (index < 0 || index >= this._annotationElementList.size()) {\r
602             throw new IndexOutOfBoundsException("setAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]");\r
603         }\r
604         \r
605         this._annotationElementList.set(index, vAnnotationElement);\r
606     }\r
607 \r
608     /**\r
609      * \r
610      * \r
611      * @param vAnnotationElementArray\r
612      */\r
613     public void setAnnotationElement(\r
614             final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray) {\r
615         //-- copy array\r
616         _annotationElementList.clear();\r
617         \r
618         for (int i = 0; i < vAnnotationElementArray.length; i++) {\r
619                 this._annotationElementList.add(vAnnotationElementArray[i]);\r
620         }\r
621     }\r
622 \r
623     /**\r
624      * Sets the value of field 'description'.\r
625      * \r
626      * @param description the value of field 'description'.\r
627      */\r
628     public void setDescription(\r
629             final java.lang.String description) {\r
630         this._description = description;\r
631     }\r
632 \r
633     /**\r
634      * Sets the value of field 'graph'.\r
635      * \r
636      * @param graph the value of field 'graph'.\r
637      */\r
638     public void setGraph(\r
639             final boolean graph) {\r
640         this._graph = graph;\r
641         this._has_graph = true;\r
642     }\r
643 \r
644     /**\r
645      * Sets the value of field 'graphColour'.\r
646      * \r
647      * @param graphColour the value of field 'graphColour'.\r
648      */\r
649     public void setGraphColour(\r
650             final int graphColour) {\r
651         this._graphColour = graphColour;\r
652         this._has_graphColour = true;\r
653     }\r
654 \r
655     /**\r
656      * Sets the value of field 'graphGroup'.\r
657      * \r
658      * @param graphGroup the value of field 'graphGroup'.\r
659      */\r
660     public void setGraphGroup(\r
661             final int graphGroup) {\r
662         this._graphGroup = graphGroup;\r
663         this._has_graphGroup = true;\r
664     }\r
665 \r
666     /**\r
667      * Sets the value of field 'graphType'.\r
668      * \r
669      * @param graphType the value of field 'graphType'.\r
670      */\r
671     public void setGraphType(\r
672             final int graphType) {\r
673         this._graphType = graphType;\r
674         this._has_graphType = true;\r
675     }\r
676 \r
677     /**\r
678      * Sets the value of field 'id'.\r
679      * \r
680      * @param id the value of field 'id'.\r
681      */\r
682     public void setId(\r
683             final java.lang.String id) {\r
684         this._id = id;\r
685     }\r
686 \r
687     /**\r
688      * Sets the value of field 'label'.\r
689      * \r
690      * @param label the value of field 'label'.\r
691      */\r
692     public void setLabel(\r
693             final java.lang.String label) {\r
694         this._label = label;\r
695     }\r
696 \r
697     /**\r
698      * Sets the value of field 'score'.\r
699      * \r
700      * @param score the value of field 'score'.\r
701      */\r
702     public void setScore(\r
703             final double score) {\r
704         this._score = score;\r
705         this._has_score = true;\r
706     }\r
707 \r
708     /**\r
709      * Sets the value of field 'scoreOnly'.\r
710      * \r
711      * @param scoreOnly the value of field 'scoreOnly'.\r
712      */\r
713     public void setScoreOnly(\r
714             final boolean scoreOnly) {\r
715         this._scoreOnly = scoreOnly;\r
716         this._has_scoreOnly = true;\r
717     }\r
718 \r
719     /**\r
720      * Sets the value of field 'sequenceRef'.\r
721      * \r
722      * @param sequenceRef the value of field 'sequenceRef'.\r
723      */\r
724     public void setSequenceRef(\r
725             final java.lang.String sequenceRef) {\r
726         this._sequenceRef = sequenceRef;\r
727     }\r
728 \r
729     /**\r
730      * Sets the value of field 'thresholdLine'.\r
731      * \r
732      * @param thresholdLine the value of field 'thresholdLine'.\r
733      */\r
734     public void setThresholdLine(\r
735             final jalview.schemabinding.version2.ThresholdLine thresholdLine) {\r
736         this._thresholdLine = thresholdLine;\r
737     }\r
738 \r
739     /**\r
740      * Sets the value of field 'visible'.\r
741      * \r
742      * @param visible the value of field 'visible'.\r
743      */\r
744     public void setVisible(\r
745             final boolean visible) {\r
746         this._visible = visible;\r
747         this._has_visible = true;\r
748     }\r
749 \r
750     /**\r
751      * Method unmarshal.\r
752      * \r
753      * @param reader\r
754      * @throws org.exolab.castor.xml.MarshalException if object is\r
755      * null or if any SAXException is thrown during marshaling\r
756      * @throws org.exolab.castor.xml.ValidationException if this\r
757      * object is an invalid instance according to the schema\r
758      * @return the unmarshaled\r
759      * jalview.schemabinding.version2.Annotation\r
760      */\r
761     public static jalview.schemabinding.version2.Annotation unmarshal(\r
762             final java.io.Reader reader)\r
763     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
764         return (jalview.schemabinding.version2.Annotation) Unmarshaller.unmarshal(jalview.schemabinding.version2.Annotation.class, reader);\r
765     }\r
766 \r
767     /**\r
768      * \r
769      * \r
770      * @throws org.exolab.castor.xml.ValidationException if this\r
771      * object is an invalid instance according to the schema\r
772      */\r
773     public void validate(\r
774     )\r
775     throws org.exolab.castor.xml.ValidationException {\r
776         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
777         validator.validate(this);\r
778     }\r
779 \r
780 }\r