329c526e89a04c66e5173d3ebde5c740c92b3432
[jalview.git] / src / jalview / binding / JGroup.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.binding;
20
21   //---------------------------------/
22  //- Imported classes and packages -/
23 //---------------------------------/
24
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
27
28 /**
29  * Class JGroup.
30  * 
31  * @version $Revision$ $Date$
32  */
33 public class JGroup implements java.io.Serializable {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * Field _start.
42      */
43     private int _start;
44
45     /**
46      * keeps track of state for field: _start
47      */
48     private boolean _has_start;
49
50     /**
51      * Field _end.
52      */
53     private int _end;
54
55     /**
56      * keeps track of state for field: _end
57      */
58     private boolean _has_end;
59
60     /**
61      * Field _name.
62      */
63     private java.lang.String _name;
64
65     /**
66      * Field _colour.
67      */
68     private java.lang.String _colour;
69
70     /**
71      * Field _consThreshold.
72      */
73     private int _consThreshold;
74
75     /**
76      * keeps track of state for field: _consThreshold
77      */
78     private boolean _has_consThreshold;
79
80     /**
81      * Field _pidThreshold.
82      */
83     private int _pidThreshold;
84
85     /**
86      * keeps track of state for field: _pidThreshold
87      */
88     private boolean _has_pidThreshold;
89
90     /**
91      * Field _outlineColour.
92      */
93     private int _outlineColour;
94
95     /**
96      * keeps track of state for field: _outlineColour
97      */
98     private boolean _has_outlineColour;
99
100     /**
101      * Field _displayBoxes.
102      */
103     private boolean _displayBoxes;
104
105     /**
106      * keeps track of state for field: _displayBoxes
107      */
108     private boolean _has_displayBoxes;
109
110     /**
111      * Field _displayText.
112      */
113     private boolean _displayText;
114
115     /**
116      * keeps track of state for field: _displayText
117      */
118     private boolean _has_displayText;
119
120     /**
121      * Field _colourText.
122      */
123     private boolean _colourText;
124
125     /**
126      * keeps track of state for field: _colourText
127      */
128     private boolean _has_colourText;
129
130     /**
131      * Field _seqList.
132      */
133     private java.util.Vector _seqList;
134
135
136       //----------------/
137      //- Constructors -/
138     //----------------/
139
140     public JGroup() {
141         super();
142         this._seqList = new java.util.Vector();
143     }
144
145
146       //-----------/
147      //- Methods -/
148     //-----------/
149
150     /**
151      * 
152      * 
153      * @param vSeq
154      * @throws java.lang.IndexOutOfBoundsException if the index
155      * given is outside the bounds of the collection
156      */
157     public void addSeq(
158             final int vSeq)
159     throws java.lang.IndexOutOfBoundsException {
160         this._seqList.addElement(new java.lang.Integer(vSeq));
161     }
162
163     /**
164      * 
165      * 
166      * @param index
167      * @param vSeq
168      * @throws java.lang.IndexOutOfBoundsException if the index
169      * given is outside the bounds of the collection
170      */
171     public void addSeq(
172             final int index,
173             final int vSeq)
174     throws java.lang.IndexOutOfBoundsException {
175         this._seqList.add(index, new java.lang.Integer(vSeq));
176     }
177
178     /**
179      */
180     public void deleteColourText(
181     ) {
182         this._has_colourText= false;
183     }
184
185     /**
186      */
187     public void deleteConsThreshold(
188     ) {
189         this._has_consThreshold= false;
190     }
191
192     /**
193      */
194     public void deleteDisplayBoxes(
195     ) {
196         this._has_displayBoxes= false;
197     }
198
199     /**
200      */
201     public void deleteDisplayText(
202     ) {
203         this._has_displayText= false;
204     }
205
206     /**
207      */
208     public void deleteEnd(
209     ) {
210         this._has_end= false;
211     }
212
213     /**
214      */
215     public void deleteOutlineColour(
216     ) {
217         this._has_outlineColour= false;
218     }
219
220     /**
221      */
222     public void deletePidThreshold(
223     ) {
224         this._has_pidThreshold= false;
225     }
226
227     /**
228      */
229     public void deleteStart(
230     ) {
231         this._has_start= false;
232     }
233
234     /**
235      * Method enumerateSeq.
236      * 
237      * @return an Enumeration over all int elements
238      */
239     public java.util.Enumeration enumerateSeq(
240     ) {
241         return this._seqList.elements();
242     }
243
244     /**
245      * Returns the value of field 'colour'.
246      * 
247      * @return the value of field 'Colour'.
248      */
249     public java.lang.String getColour(
250     ) {
251         return this._colour;
252     }
253
254     /**
255      * Returns the value of field 'colourText'.
256      * 
257      * @return the value of field 'ColourText'.
258      */
259     public boolean getColourText(
260     ) {
261         return this._colourText;
262     }
263
264     /**
265      * Returns the value of field 'consThreshold'.
266      * 
267      * @return the value of field 'ConsThreshold'.
268      */
269     public int getConsThreshold(
270     ) {
271         return this._consThreshold;
272     }
273
274     /**
275      * Returns the value of field 'displayBoxes'.
276      * 
277      * @return the value of field 'DisplayBoxes'.
278      */
279     public boolean getDisplayBoxes(
280     ) {
281         return this._displayBoxes;
282     }
283
284     /**
285      * Returns the value of field 'displayText'.
286      * 
287      * @return the value of field 'DisplayText'.
288      */
289     public boolean getDisplayText(
290     ) {
291         return this._displayText;
292     }
293
294     /**
295      * Returns the value of field 'end'.
296      * 
297      * @return the value of field 'End'.
298      */
299     public int getEnd(
300     ) {
301         return this._end;
302     }
303
304     /**
305      * Returns the value of field 'name'.
306      * 
307      * @return the value of field 'Name'.
308      */
309     public java.lang.String getName(
310     ) {
311         return this._name;
312     }
313
314     /**
315      * Returns the value of field 'outlineColour'.
316      * 
317      * @return the value of field 'OutlineColour'.
318      */
319     public int getOutlineColour(
320     ) {
321         return this._outlineColour;
322     }
323
324     /**
325      * Returns the value of field 'pidThreshold'.
326      * 
327      * @return the value of field 'PidThreshold'.
328      */
329     public int getPidThreshold(
330     ) {
331         return this._pidThreshold;
332     }
333
334     /**
335      * Method getSeq.
336      * 
337      * @param index
338      * @throws java.lang.IndexOutOfBoundsException if the index
339      * given is outside the bounds of the collection
340      * @return the value of the int at the given index
341      */
342     public int getSeq(
343             final int index)
344     throws java.lang.IndexOutOfBoundsException {
345         // check bounds for index
346         if (index < 0 || index >= this._seqList.size()) {
347             throw new IndexOutOfBoundsException("getSeq: Index value '" + index + "' not in range [0.." + (this._seqList.size() - 1) + "]");
348         }
349         
350         return ((java.lang.Integer) _seqList.get(index)).intValue();
351     }
352
353     /**
354      * Method getSeq.Returns the contents of the collection in an
355      * Array.  
356      * 
357      * @return this collection as an Array
358      */
359     public int[] getSeq(
360     ) {
361         int size = this._seqList.size();
362         int[] array = new int[size];
363         java.util.Iterator iter = _seqList.iterator();
364         for (int index = 0; index < size; index++) {
365             array[index] = ((java.lang.Integer) iter.next()).intValue();
366         }
367         return array;
368     }
369
370     /**
371      * Method getSeqCount.
372      * 
373      * @return the size of this collection
374      */
375     public int getSeqCount(
376     ) {
377         return this._seqList.size();
378     }
379
380     /**
381      * Returns the value of field 'start'.
382      * 
383      * @return the value of field 'Start'.
384      */
385     public int getStart(
386     ) {
387         return this._start;
388     }
389
390     /**
391      * Method hasColourText.
392      * 
393      * @return true if at least one ColourText has been added
394      */
395     public boolean hasColourText(
396     ) {
397         return this._has_colourText;
398     }
399
400     /**
401      * Method hasConsThreshold.
402      * 
403      * @return true if at least one ConsThreshold has been added
404      */
405     public boolean hasConsThreshold(
406     ) {
407         return this._has_consThreshold;
408     }
409
410     /**
411      * Method hasDisplayBoxes.
412      * 
413      * @return true if at least one DisplayBoxes has been added
414      */
415     public boolean hasDisplayBoxes(
416     ) {
417         return this._has_displayBoxes;
418     }
419
420     /**
421      * Method hasDisplayText.
422      * 
423      * @return true if at least one DisplayText has been added
424      */
425     public boolean hasDisplayText(
426     ) {
427         return this._has_displayText;
428     }
429
430     /**
431      * Method hasEnd.
432      * 
433      * @return true if at least one End has been added
434      */
435     public boolean hasEnd(
436     ) {
437         return this._has_end;
438     }
439
440     /**
441      * Method hasOutlineColour.
442      * 
443      * @return true if at least one OutlineColour has been added
444      */
445     public boolean hasOutlineColour(
446     ) {
447         return this._has_outlineColour;
448     }
449
450     /**
451      * Method hasPidThreshold.
452      * 
453      * @return true if at least one PidThreshold has been added
454      */
455     public boolean hasPidThreshold(
456     ) {
457         return this._has_pidThreshold;
458     }
459
460     /**
461      * Method hasStart.
462      * 
463      * @return true if at least one Start has been added
464      */
465     public boolean hasStart(
466     ) {
467         return this._has_start;
468     }
469
470     /**
471      * Returns the value of field 'colourText'.
472      * 
473      * @return the value of field 'ColourText'.
474      */
475     public boolean isColourText(
476     ) {
477         return this._colourText;
478     }
479
480     /**
481      * Returns the value of field 'displayBoxes'.
482      * 
483      * @return the value of field 'DisplayBoxes'.
484      */
485     public boolean isDisplayBoxes(
486     ) {
487         return this._displayBoxes;
488     }
489
490     /**
491      * Returns the value of field 'displayText'.
492      * 
493      * @return the value of field 'DisplayText'.
494      */
495     public boolean isDisplayText(
496     ) {
497         return this._displayText;
498     }
499
500     /**
501      * Method isValid.
502      * 
503      * @return true if this object is valid according to the schema
504      */
505     public boolean isValid(
506     ) {
507         try {
508             validate();
509         } catch (org.exolab.castor.xml.ValidationException vex) {
510             return false;
511         }
512         return true;
513     }
514
515     /**
516      * 
517      * 
518      * @param out
519      * @throws org.exolab.castor.xml.MarshalException if object is
520      * null or if any SAXException is thrown during marshaling
521      * @throws org.exolab.castor.xml.ValidationException if this
522      * object is an invalid instance according to the schema
523      */
524     public void marshal(
525             final java.io.Writer out)
526     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
527         Marshaller.marshal(this, out);
528     }
529
530     /**
531      * 
532      * 
533      * @param handler
534      * @throws java.io.IOException if an IOException occurs during
535      * marshaling
536      * @throws org.exolab.castor.xml.ValidationException if this
537      * object is an invalid instance according to the schema
538      * @throws org.exolab.castor.xml.MarshalException if object is
539      * null or if any SAXException is thrown during marshaling
540      */
541     public void marshal(
542             final org.xml.sax.ContentHandler handler)
543     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
544         Marshaller.marshal(this, handler);
545     }
546
547     /**
548      */
549     public void removeAllSeq(
550     ) {
551         this._seqList.clear();
552     }
553
554     /**
555      * Method removeSeq.
556      * 
557      * @param vSeq
558      * @return true if the object was removed from the collection.
559      */
560     public boolean removeSeq(
561             final int vSeq) {
562         boolean removed = _seqList.remove(new java.lang.Integer(vSeq));
563         return removed;
564     }
565
566     /**
567      * Method removeSeqAt.
568      * 
569      * @param index
570      * @return the element removed from the collection
571      */
572     public int removeSeqAt(
573             final int index) {
574         java.lang.Object obj = this._seqList.remove(index);
575         return ((java.lang.Integer) obj).intValue();
576     }
577
578     /**
579      * Sets the value of field 'colour'.
580      * 
581      * @param colour the value of field 'colour'.
582      */
583     public void setColour(
584             final java.lang.String colour) {
585         this._colour = colour;
586     }
587
588     /**
589      * Sets the value of field 'colourText'.
590      * 
591      * @param colourText the value of field 'colourText'.
592      */
593     public void setColourText(
594             final boolean colourText) {
595         this._colourText = colourText;
596         this._has_colourText = true;
597     }
598
599     /**
600      * Sets the value of field 'consThreshold'.
601      * 
602      * @param consThreshold the value of field 'consThreshold'.
603      */
604     public void setConsThreshold(
605             final int consThreshold) {
606         this._consThreshold = consThreshold;
607         this._has_consThreshold = true;
608     }
609
610     /**
611      * Sets the value of field 'displayBoxes'.
612      * 
613      * @param displayBoxes the value of field 'displayBoxes'.
614      */
615     public void setDisplayBoxes(
616             final boolean displayBoxes) {
617         this._displayBoxes = displayBoxes;
618         this._has_displayBoxes = true;
619     }
620
621     /**
622      * Sets the value of field 'displayText'.
623      * 
624      * @param displayText the value of field 'displayText'.
625      */
626     public void setDisplayText(
627             final boolean displayText) {
628         this._displayText = displayText;
629         this._has_displayText = true;
630     }
631
632     /**
633      * Sets the value of field 'end'.
634      * 
635      * @param end the value of field 'end'.
636      */
637     public void setEnd(
638             final int end) {
639         this._end = end;
640         this._has_end = true;
641     }
642
643     /**
644      * Sets the value of field 'name'.
645      * 
646      * @param name the value of field 'name'.
647      */
648     public void setName(
649             final java.lang.String name) {
650         this._name = name;
651     }
652
653     /**
654      * Sets the value of field 'outlineColour'.
655      * 
656      * @param outlineColour the value of field 'outlineColour'.
657      */
658     public void setOutlineColour(
659             final int outlineColour) {
660         this._outlineColour = outlineColour;
661         this._has_outlineColour = true;
662     }
663
664     /**
665      * Sets the value of field 'pidThreshold'.
666      * 
667      * @param pidThreshold the value of field 'pidThreshold'.
668      */
669     public void setPidThreshold(
670             final int pidThreshold) {
671         this._pidThreshold = pidThreshold;
672         this._has_pidThreshold = true;
673     }
674
675     /**
676      * 
677      * 
678      * @param index
679      * @param vSeq
680      * @throws java.lang.IndexOutOfBoundsException if the index
681      * given is outside the bounds of the collection
682      */
683     public void setSeq(
684             final int index,
685             final int vSeq)
686     throws java.lang.IndexOutOfBoundsException {
687         // check bounds for index
688         if (index < 0 || index >= this._seqList.size()) {
689             throw new IndexOutOfBoundsException("setSeq: Index value '" + index + "' not in range [0.." + (this._seqList.size() - 1) + "]");
690         }
691         
692         this._seqList.set(index, new java.lang.Integer(vSeq));
693     }
694
695     /**
696      * 
697      * 
698      * @param vSeqArray
699      */
700     public void setSeq(
701             final int[] vSeqArray) {
702         //-- copy array
703         _seqList.clear();
704         
705         for (int i = 0; i < vSeqArray.length; i++) {
706                 this._seqList.add(new java.lang.Integer(vSeqArray[i]));
707         }
708     }
709
710     /**
711      * Sets the value of field 'start'.
712      * 
713      * @param start the value of field 'start'.
714      */
715     public void setStart(
716             final int start) {
717         this._start = start;
718         this._has_start = true;
719     }
720
721     /**
722      * Method unmarshal.
723      * 
724      * @param reader
725      * @throws org.exolab.castor.xml.MarshalException if object is
726      * null or if any SAXException is thrown during marshaling
727      * @throws org.exolab.castor.xml.ValidationException if this
728      * object is an invalid instance according to the schema
729      * @return the unmarshaled jalview.binding.JGroup
730      */
731     public static jalview.binding.JGroup unmarshal(
732             final java.io.Reader reader)
733     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
734         return (jalview.binding.JGroup) Unmarshaller.unmarshal(jalview.binding.JGroup.class, reader);
735     }
736
737     /**
738      * 
739      * 
740      * @throws org.exolab.castor.xml.ValidationException if this
741      * object is an invalid instance according to the schema
742      */
743     public void validate(
744     )
745     throws org.exolab.castor.xml.ValidationException {
746         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
747         validator.validate(this);
748     }
749
750 }