merge from 2_4_Release branch
[jalview.git] / src / jalview / binding / JGroup.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3  * Copyright (C) 2008 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   // - 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
526    *                 schema
527    */
528   public void marshal(final java.io.Writer out)
529           throws org.exolab.castor.xml.MarshalException,
530           org.exolab.castor.xml.ValidationException
531   {
532     Marshaller.marshal(this, out);
533   }
534
535   /**
536    * 
537    * 
538    * @param handler
539    * @throws java.io.IOException
540    *                 if an IOException occurs during marshaling
541    * @throws org.exolab.castor.xml.ValidationException
542    *                 if this object is an invalid instance according to the
543    *                 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
751    *                 schema
752    * @return the unmarshaled jalview.binding.JGroup
753    */
754   public static jalview.binding.JGroup unmarshal(final java.io.Reader reader)
755           throws org.exolab.castor.xml.MarshalException,
756           org.exolab.castor.xml.ValidationException
757   {
758     return (jalview.binding.JGroup) Unmarshaller.unmarshal(
759             jalview.binding.JGroup.class, reader);
760   }
761
762   /**
763    * 
764    * 
765    * @throws org.exolab.castor.xml.ValidationException
766    *                 if this object is an invalid instance according to the
767    *                 schema
768    */
769   public void validate() throws org.exolab.castor.xml.ValidationException
770   {
771     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
772     validator.validate(this);
773   }
774
775 }