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