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