JAL-1517 fix copyright for 2.8.2
[jalview.git] / src / jalview / binding / JGroup.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.binding;
22
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
26
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
29
30 /**
31  * Class JGroup.
32  * 
33  * @version $Revision$ $Date$
34  */
35 public class JGroup implements java.io.Serializable
36 {
37
38   // --------------------------/
39   // - Class/Member Variables -/
40   // --------------------------/
41
42   /**
43    * Field _start.
44    */
45   private int _start;
46
47   /**
48    * keeps track of state for field: _start
49    */
50   private boolean _has_start;
51
52   /**
53    * Field _end.
54    */
55   private int _end;
56
57   /**
58    * keeps track of state for field: _end
59    */
60   private boolean _has_end;
61
62   /**
63    * Field _name.
64    */
65   private java.lang.String _name;
66
67   /**
68    * Field _colour.
69    */
70   private java.lang.String _colour;
71
72   /**
73    * Field _consThreshold.
74    */
75   private int _consThreshold;
76
77   /**
78    * keeps track of state for field: _consThreshold
79    */
80   private boolean _has_consThreshold;
81
82   /**
83    * Field _pidThreshold.
84    */
85   private int _pidThreshold;
86
87   /**
88    * keeps track of state for field: _pidThreshold
89    */
90   private boolean _has_pidThreshold;
91
92   /**
93    * Field _outlineColour.
94    */
95   private int _outlineColour;
96
97   /**
98    * keeps track of state for field: _outlineColour
99    */
100   private boolean _has_outlineColour;
101
102   /**
103    * Field _displayBoxes.
104    */
105   private boolean _displayBoxes;
106
107   /**
108    * keeps track of state for field: _displayBoxes
109    */
110   private boolean _has_displayBoxes;
111
112   /**
113    * Field _displayText.
114    */
115   private boolean _displayText;
116
117   /**
118    * keeps track of state for field: _displayText
119    */
120   private boolean _has_displayText;
121
122   /**
123    * Field _colourText.
124    */
125   private boolean _colourText;
126
127   /**
128    * keeps track of state for field: _colourText
129    */
130   private boolean _has_colourText;
131
132   /**
133    * Field _seqList.
134    */
135   private java.util.Vector _seqList;
136
137   // ----------------/
138   // - Constructors -/
139   // ----------------/
140
141   public JGroup()
142   {
143     super();
144     this._seqList = new java.util.Vector();
145   }
146
147   // -----------/
148   // - Methods -/
149   // -----------/
150
151   /**
152    * 
153    * 
154    * @param vSeq
155    * @throws java.lang.IndexOutOfBoundsException
156    *           if the index given is outside the bounds of the collection
157    */
158   public void addSeq(final int vSeq)
159           throws java.lang.IndexOutOfBoundsException
160   {
161     this._seqList.addElement(new java.lang.Integer(vSeq));
162   }
163
164   /**
165    * 
166    * 
167    * @param index
168    * @param vSeq
169    * @throws java.lang.IndexOutOfBoundsException
170    *           if the index given is outside the bounds of the collection
171    */
172   public void addSeq(final int index, final int vSeq)
173           throws java.lang.IndexOutOfBoundsException
174   {
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
339    *           if the index given is outside the bounds of the collection
340    * @return the value of the int at the given index
341    */
342   public int getSeq(final int index)
343           throws java.lang.IndexOutOfBoundsException
344   {
345     // check bounds for index
346     if (index < 0 || index >= this._seqList.size())
347     {
348       throw new IndexOutOfBoundsException("getSeq: Index value '" + index
349               + "' not in range [0.." + (this._seqList.size() - 1) + "]");
350     }
351
352     return ((java.lang.Integer) _seqList.get(index)).intValue();
353   }
354
355   /**
356    * Method getSeq.Returns the contents of the collection in an Array.
357    * 
358    * @return this collection as an Array
359    */
360   public int[] getSeq()
361   {
362     int size = this._seqList.size();
363     int[] array = new int[size];
364     java.util.Iterator iter = _seqList.iterator();
365     for (int index = 0; index < size; index++)
366     {
367       array[index] = ((java.lang.Integer) iter.next()).intValue();
368     }
369     return array;
370   }
371
372   /**
373    * Method getSeqCount.
374    * 
375    * @return the size of this collection
376    */
377   public int getSeqCount()
378   {
379     return this._seqList.size();
380   }
381
382   /**
383    * Returns the value of field 'start'.
384    * 
385    * @return the value of field 'Start'.
386    */
387   public int getStart()
388   {
389     return this._start;
390   }
391
392   /**
393    * Method hasColourText.
394    * 
395    * @return true if at least one ColourText has been added
396    */
397   public boolean hasColourText()
398   {
399     return this._has_colourText;
400   }
401
402   /**
403    * Method hasConsThreshold.
404    * 
405    * @return true if at least one ConsThreshold has been added
406    */
407   public boolean hasConsThreshold()
408   {
409     return this._has_consThreshold;
410   }
411
412   /**
413    * Method hasDisplayBoxes.
414    * 
415    * @return true if at least one DisplayBoxes has been added
416    */
417   public boolean hasDisplayBoxes()
418   {
419     return this._has_displayBoxes;
420   }
421
422   /**
423    * Method hasDisplayText.
424    * 
425    * @return true if at least one DisplayText has been added
426    */
427   public boolean hasDisplayText()
428   {
429     return this._has_displayText;
430   }
431
432   /**
433    * Method hasEnd.
434    * 
435    * @return true if at least one End has been added
436    */
437   public boolean hasEnd()
438   {
439     return this._has_end;
440   }
441
442   /**
443    * Method hasOutlineColour.
444    * 
445    * @return true if at least one OutlineColour has been added
446    */
447   public boolean hasOutlineColour()
448   {
449     return this._has_outlineColour;
450   }
451
452   /**
453    * Method hasPidThreshold.
454    * 
455    * @return true if at least one PidThreshold has been added
456    */
457   public boolean hasPidThreshold()
458   {
459     return this._has_pidThreshold;
460   }
461
462   /**
463    * Method hasStart.
464    * 
465    * @return true if at least one Start has been added
466    */
467   public boolean hasStart()
468   {
469     return this._has_start;
470   }
471
472   /**
473    * Returns the value of field 'colourText'.
474    * 
475    * @return the value of field 'ColourText'.
476    */
477   public boolean isColourText()
478   {
479     return this._colourText;
480   }
481
482   /**
483    * Returns the value of field 'displayBoxes'.
484    * 
485    * @return the value of field 'DisplayBoxes'.
486    */
487   public boolean isDisplayBoxes()
488   {
489     return this._displayBoxes;
490   }
491
492   /**
493    * Returns the value of field 'displayText'.
494    * 
495    * @return the value of field 'DisplayText'.
496    */
497   public boolean isDisplayText()
498   {
499     return this._displayText;
500   }
501
502   /**
503    * Method isValid.
504    * 
505    * @return true if this object is valid according to the schema
506    */
507   public boolean isValid()
508   {
509     try
510     {
511       validate();
512     } catch (org.exolab.castor.xml.ValidationException vex)
513     {
514       return false;
515     }
516     return true;
517   }
518
519   /**
520    * 
521    * 
522    * @param out
523    * @throws org.exolab.castor.xml.MarshalException
524    *           if object is null or if any SAXException is thrown during
525    *           marshaling
526    * @throws org.exolab.castor.xml.ValidationException
527    *           if this object is an invalid instance according to the schema
528    */
529   public void marshal(final java.io.Writer out)
530           throws org.exolab.castor.xml.MarshalException,
531           org.exolab.castor.xml.ValidationException
532   {
533     Marshaller.marshal(this, out);
534   }
535
536   /**
537    * 
538    * 
539    * @param handler
540    * @throws java.io.IOException
541    *           if an IOException occurs during marshaling
542    * @throws org.exolab.castor.xml.ValidationException
543    *           if this object is an invalid instance according to the schema
544    * @throws org.exolab.castor.xml.MarshalException
545    *           if object is null or if any SAXException is thrown during
546    *           marshaling
547    */
548   public void marshal(final org.xml.sax.ContentHandler handler)
549           throws java.io.IOException,
550           org.exolab.castor.xml.MarshalException,
551           org.exolab.castor.xml.ValidationException
552   {
553     Marshaller.marshal(this, handler);
554   }
555
556   /**
557      */
558   public void removeAllSeq()
559   {
560     this._seqList.clear();
561   }
562
563   /**
564    * Method removeSeq.
565    * 
566    * @param vSeq
567    * @return true if the object was removed from the collection.
568    */
569   public boolean removeSeq(final int vSeq)
570   {
571     boolean removed = _seqList.remove(new java.lang.Integer(vSeq));
572     return removed;
573   }
574
575   /**
576    * Method removeSeqAt.
577    * 
578    * @param index
579    * @return the element removed from the collection
580    */
581   public int removeSeqAt(final int index)
582   {
583     java.lang.Object obj = this._seqList.remove(index);
584     return ((java.lang.Integer) obj).intValue();
585   }
586
587   /**
588    * Sets the value of field 'colour'.
589    * 
590    * @param colour
591    *          the value of field 'colour'.
592    */
593   public void setColour(final java.lang.String colour)
594   {
595     this._colour = colour;
596   }
597
598   /**
599    * Sets the value of field 'colourText'.
600    * 
601    * @param colourText
602    *          the value of field 'colourText'.
603    */
604   public void setColourText(final boolean colourText)
605   {
606     this._colourText = colourText;
607     this._has_colourText = true;
608   }
609
610   /**
611    * Sets the value of field 'consThreshold'.
612    * 
613    * @param consThreshold
614    *          the value of field 'consThreshold'.
615    */
616   public void setConsThreshold(final int consThreshold)
617   {
618     this._consThreshold = consThreshold;
619     this._has_consThreshold = true;
620   }
621
622   /**
623    * Sets the value of field 'displayBoxes'.
624    * 
625    * @param displayBoxes
626    *          the value of field 'displayBoxes'.
627    */
628   public void setDisplayBoxes(final boolean displayBoxes)
629   {
630     this._displayBoxes = displayBoxes;
631     this._has_displayBoxes = true;
632   }
633
634   /**
635    * Sets the value of field 'displayText'.
636    * 
637    * @param displayText
638    *          the value of field 'displayText'.
639    */
640   public void setDisplayText(final boolean displayText)
641   {
642     this._displayText = displayText;
643     this._has_displayText = true;
644   }
645
646   /**
647    * Sets the value of field 'end'.
648    * 
649    * @param end
650    *          the value of field 'end'.
651    */
652   public void setEnd(final int end)
653   {
654     this._end = end;
655     this._has_end = true;
656   }
657
658   /**
659    * Sets the value of field 'name'.
660    * 
661    * @param name
662    *          the value of field 'name'.
663    */
664   public void setName(final java.lang.String name)
665   {
666     this._name = name;
667   }
668
669   /**
670    * Sets the value of field 'outlineColour'.
671    * 
672    * @param outlineColour
673    *          the value of field 'outlineColour'.
674    */
675   public void setOutlineColour(final int outlineColour)
676   {
677     this._outlineColour = outlineColour;
678     this._has_outlineColour = true;
679   }
680
681   /**
682    * Sets the value of field 'pidThreshold'.
683    * 
684    * @param pidThreshold
685    *          the value of field 'pidThreshold'.
686    */
687   public void setPidThreshold(final int pidThreshold)
688   {
689     this._pidThreshold = pidThreshold;
690     this._has_pidThreshold = true;
691   }
692
693   /**
694    * 
695    * 
696    * @param index
697    * @param vSeq
698    * @throws java.lang.IndexOutOfBoundsException
699    *           if the index given is outside the bounds of the collection
700    */
701   public void setSeq(final int index, final int vSeq)
702           throws java.lang.IndexOutOfBoundsException
703   {
704     // check bounds for index
705     if (index < 0 || index >= this._seqList.size())
706     {
707       throw new IndexOutOfBoundsException("setSeq: Index value '" + index
708               + "' not in range [0.." + (this._seqList.size() - 1) + "]");
709     }
710
711     this._seqList.set(index, new java.lang.Integer(vSeq));
712   }
713
714   /**
715    * 
716    * 
717    * @param vSeqArray
718    */
719   public void setSeq(final int[] vSeqArray)
720   {
721     // -- copy array
722     _seqList.clear();
723
724     for (int i = 0; i < vSeqArray.length; i++)
725     {
726       this._seqList.add(new java.lang.Integer(vSeqArray[i]));
727     }
728   }
729
730   /**
731    * Sets the value of field 'start'.
732    * 
733    * @param start
734    *          the value of field 'start'.
735    */
736   public void setStart(final int start)
737   {
738     this._start = start;
739     this._has_start = true;
740   }
741
742   /**
743    * Method unmarshal.
744    * 
745    * @param reader
746    * @throws org.exolab.castor.xml.MarshalException
747    *           if object is null or if any SAXException is thrown during
748    *           marshaling
749    * @throws org.exolab.castor.xml.ValidationException
750    *           if this object is an invalid instance according to the schema
751    * @return the unmarshaled jalview.binding.JGroup
752    */
753   public static jalview.binding.JGroup unmarshal(final java.io.Reader reader)
754           throws org.exolab.castor.xml.MarshalException,
755           org.exolab.castor.xml.ValidationException
756   {
757     return (jalview.binding.JGroup) Unmarshaller.unmarshal(
758             jalview.binding.JGroup.class, reader);
759   }
760
761   /**
762    * 
763    * 
764    * @throws org.exolab.castor.xml.ValidationException
765    *           if this object is an invalid instance according to the schema
766    */
767   public void validate() throws org.exolab.castor.xml.ValidationException
768   {
769     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
770     validator.validate(this);
771   }
772
773 }