JAL-1432 updated copyright notices
[jalview.git] / src / jalview / binding / JGroup.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
10  *  
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.
15  * 
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.
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   // - Constructors -/
137   // ----------------/
138
139   public JGroup()
140   {
141     super();
142     this._seqList = new java.util.Vector();
143   }
144
145   // -----------/
146   // - Methods -/
147   // -----------/
148
149   /**
150    * 
151    * 
152    * @param vSeq
153    * @throws java.lang.IndexOutOfBoundsException
154    *           if the index given is outside the bounds of the collection
155    */
156   public void addSeq(final int vSeq)
157           throws java.lang.IndexOutOfBoundsException
158   {
159     this._seqList.addElement(new java.lang.Integer(vSeq));
160   }
161
162   /**
163    * 
164    * 
165    * @param index
166    * @param vSeq
167    * @throws java.lang.IndexOutOfBoundsException
168    *           if the index given is outside the bounds of the collection
169    */
170   public void addSeq(final int index, final int vSeq)
171           throws java.lang.IndexOutOfBoundsException
172   {
173     this._seqList.add(index, new java.lang.Integer(vSeq));
174   }
175
176   /**
177      */
178   public void deleteColourText()
179   {
180     this._has_colourText = false;
181   }
182
183   /**
184      */
185   public void deleteConsThreshold()
186   {
187     this._has_consThreshold = false;
188   }
189
190   /**
191      */
192   public void deleteDisplayBoxes()
193   {
194     this._has_displayBoxes = false;
195   }
196
197   /**
198      */
199   public void deleteDisplayText()
200   {
201     this._has_displayText = false;
202   }
203
204   /**
205      */
206   public void deleteEnd()
207   {
208     this._has_end = false;
209   }
210
211   /**
212      */
213   public void deleteOutlineColour()
214   {
215     this._has_outlineColour = false;
216   }
217
218   /**
219      */
220   public void deletePidThreshold()
221   {
222     this._has_pidThreshold = false;
223   }
224
225   /**
226      */
227   public void deleteStart()
228   {
229     this._has_start = false;
230   }
231
232   /**
233    * Method enumerateSeq.
234    * 
235    * @return an Enumeration over all int elements
236    */
237   public java.util.Enumeration enumerateSeq()
238   {
239     return this._seqList.elements();
240   }
241
242   /**
243    * Returns the value of field 'colour'.
244    * 
245    * @return the value of field 'Colour'.
246    */
247   public java.lang.String getColour()
248   {
249     return this._colour;
250   }
251
252   /**
253    * Returns the value of field 'colourText'.
254    * 
255    * @return the value of field 'ColourText'.
256    */
257   public boolean getColourText()
258   {
259     return this._colourText;
260   }
261
262   /**
263    * Returns the value of field 'consThreshold'.
264    * 
265    * @return the value of field 'ConsThreshold'.
266    */
267   public int getConsThreshold()
268   {
269     return this._consThreshold;
270   }
271
272   /**
273    * Returns the value of field 'displayBoxes'.
274    * 
275    * @return the value of field 'DisplayBoxes'.
276    */
277   public boolean getDisplayBoxes()
278   {
279     return this._displayBoxes;
280   }
281
282   /**
283    * Returns the value of field 'displayText'.
284    * 
285    * @return the value of field 'DisplayText'.
286    */
287   public boolean getDisplayText()
288   {
289     return this._displayText;
290   }
291
292   /**
293    * Returns the value of field 'end'.
294    * 
295    * @return the value of field 'End'.
296    */
297   public int getEnd()
298   {
299     return this._end;
300   }
301
302   /**
303    * Returns the value of field 'name'.
304    * 
305    * @return the value of field 'Name'.
306    */
307   public java.lang.String getName()
308   {
309     return this._name;
310   }
311
312   /**
313    * Returns the value of field 'outlineColour'.
314    * 
315    * @return the value of field 'OutlineColour'.
316    */
317   public int getOutlineColour()
318   {
319     return this._outlineColour;
320   }
321
322   /**
323    * Returns the value of field 'pidThreshold'.
324    * 
325    * @return the value of field 'PidThreshold'.
326    */
327   public int getPidThreshold()
328   {
329     return this._pidThreshold;
330   }
331
332   /**
333    * Method getSeq.
334    * 
335    * @param index
336    * @throws java.lang.IndexOutOfBoundsException
337    *           if the index given is outside the bounds of the collection
338    * @return the value of the int at the given index
339    */
340   public int getSeq(final int index)
341           throws java.lang.IndexOutOfBoundsException
342   {
343     // check bounds for index
344     if (index < 0 || index >= this._seqList.size())
345     {
346       throw new IndexOutOfBoundsException("getSeq: Index value '" + index
347               + "' 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 Array.
355    * 
356    * @return this collection as an Array
357    */
358   public int[] getSeq()
359   {
360     int size = this._seqList.size();
361     int[] array = new int[size];
362     java.util.Iterator iter = _seqList.iterator();
363     for (int index = 0; index < size; index++)
364     {
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     {
509       validate();
510     } catch (org.exolab.castor.xml.ValidationException vex)
511     {
512       return false;
513     }
514     return true;
515   }
516
517   /**
518    * 
519    * 
520    * @param out
521    * @throws org.exolab.castor.xml.MarshalException
522    *           if object is null or if any SAXException is thrown during
523    *           marshaling
524    * @throws org.exolab.castor.xml.ValidationException
525    *           if this object is an invalid instance according to the schema
526    */
527   public void marshal(final java.io.Writer out)
528           throws org.exolab.castor.xml.MarshalException,
529           org.exolab.castor.xml.ValidationException
530   {
531     Marshaller.marshal(this, out);
532   }
533
534   /**
535    * 
536    * 
537    * @param handler
538    * @throws java.io.IOException
539    *           if an IOException occurs during marshaling
540    * @throws org.exolab.castor.xml.ValidationException
541    *           if this object is an invalid instance according to the schema
542    * @throws org.exolab.castor.xml.MarshalException
543    *           if object is null or if any SAXException is thrown during
544    *           marshaling
545    */
546   public void marshal(final org.xml.sax.ContentHandler handler)
547           throws java.io.IOException,
548           org.exolab.castor.xml.MarshalException,
549           org.exolab.castor.xml.ValidationException
550   {
551     Marshaller.marshal(this, handler);
552   }
553
554   /**
555      */
556   public void removeAllSeq()
557   {
558     this._seqList.clear();
559   }
560
561   /**
562    * Method removeSeq.
563    * 
564    * @param vSeq
565    * @return true if the object was removed from the collection.
566    */
567   public boolean removeSeq(final int vSeq)
568   {
569     boolean removed = _seqList.remove(new java.lang.Integer(vSeq));
570     return removed;
571   }
572
573   /**
574    * Method removeSeqAt.
575    * 
576    * @param index
577    * @return the element removed from the collection
578    */
579   public int removeSeqAt(final int index)
580   {
581     java.lang.Object obj = this._seqList.remove(index);
582     return ((java.lang.Integer) obj).intValue();
583   }
584
585   /**
586    * Sets the value of field 'colour'.
587    * 
588    * @param colour
589    *          the value of field 'colour'.
590    */
591   public void setColour(final java.lang.String colour)
592   {
593     this._colour = colour;
594   }
595
596   /**
597    * Sets the value of field 'colourText'.
598    * 
599    * @param colourText
600    *          the value of field 'colourText'.
601    */
602   public void setColourText(final boolean colourText)
603   {
604     this._colourText = colourText;
605     this._has_colourText = true;
606   }
607
608   /**
609    * Sets the value of field 'consThreshold'.
610    * 
611    * @param consThreshold
612    *          the value of field 'consThreshold'.
613    */
614   public void setConsThreshold(final int consThreshold)
615   {
616     this._consThreshold = consThreshold;
617     this._has_consThreshold = true;
618   }
619
620   /**
621    * Sets the value of field 'displayBoxes'.
622    * 
623    * @param displayBoxes
624    *          the value of field 'displayBoxes'.
625    */
626   public void setDisplayBoxes(final boolean displayBoxes)
627   {
628     this._displayBoxes = displayBoxes;
629     this._has_displayBoxes = true;
630   }
631
632   /**
633    * Sets the value of field 'displayText'.
634    * 
635    * @param displayText
636    *          the value of field 'displayText'.
637    */
638   public void setDisplayText(final boolean displayText)
639   {
640     this._displayText = displayText;
641     this._has_displayText = true;
642   }
643
644   /**
645    * Sets the value of field 'end'.
646    * 
647    * @param end
648    *          the value of field 'end'.
649    */
650   public void setEnd(final int end)
651   {
652     this._end = end;
653     this._has_end = true;
654   }
655
656   /**
657    * Sets the value of field 'name'.
658    * 
659    * @param name
660    *          the value of field 'name'.
661    */
662   public void setName(final java.lang.String name)
663   {
664     this._name = name;
665   }
666
667   /**
668    * Sets the value of field 'outlineColour'.
669    * 
670    * @param outlineColour
671    *          the value of field 'outlineColour'.
672    */
673   public void setOutlineColour(final int outlineColour)
674   {
675     this._outlineColour = outlineColour;
676     this._has_outlineColour = true;
677   }
678
679   /**
680    * Sets the value of field 'pidThreshold'.
681    * 
682    * @param pidThreshold
683    *          the value of field 'pidThreshold'.
684    */
685   public void setPidThreshold(final int pidThreshold)
686   {
687     this._pidThreshold = pidThreshold;
688     this._has_pidThreshold = true;
689   }
690
691   /**
692    * 
693    * 
694    * @param index
695    * @param vSeq
696    * @throws java.lang.IndexOutOfBoundsException
697    *           if the index given is outside the bounds of the collection
698    */
699   public void setSeq(final int index, final int vSeq)
700           throws java.lang.IndexOutOfBoundsException
701   {
702     // check bounds for index
703     if (index < 0 || index >= this._seqList.size())
704     {
705       throw new IndexOutOfBoundsException("setSeq: Index value '" + index
706               + "' not in range [0.." + (this._seqList.size() - 1) + "]");
707     }
708
709     this._seqList.set(index, new java.lang.Integer(vSeq));
710   }
711
712   /**
713    * 
714    * 
715    * @param vSeqArray
716    */
717   public void setSeq(final int[] vSeqArray)
718   {
719     // -- copy array
720     _seqList.clear();
721
722     for (int i = 0; i < vSeqArray.length; i++)
723     {
724       this._seqList.add(new java.lang.Integer(vSeqArray[i]));
725     }
726   }
727
728   /**
729    * Sets the value of field 'start'.
730    * 
731    * @param start
732    *          the value of field 'start'.
733    */
734   public void setStart(final int start)
735   {
736     this._start = start;
737     this._has_start = true;
738   }
739
740   /**
741    * Method unmarshal.
742    * 
743    * @param reader
744    * @throws org.exolab.castor.xml.MarshalException
745    *           if object is null or if any SAXException is thrown during
746    *           marshaling
747    * @throws org.exolab.castor.xml.ValidationException
748    *           if this object is an invalid instance according to the schema
749    * @return the unmarshaled jalview.binding.JGroup
750    */
751   public static jalview.binding.JGroup unmarshal(final java.io.Reader reader)
752           throws org.exolab.castor.xml.MarshalException,
753           org.exolab.castor.xml.ValidationException
754   {
755     return (jalview.binding.JGroup) Unmarshaller.unmarshal(
756             jalview.binding.JGroup.class, reader);
757   }
758
759   /**
760    * 
761    * 
762    * @throws org.exolab.castor.xml.ValidationException
763    *           if this object is an invalid instance according to the schema
764    */
765   public void validate() throws org.exolab.castor.xml.ValidationException
766   {
767     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
768     validator.validate(this);
769   }
770
771 }