8e03945f248eb90c1d531ce2c44183dbef3ee497
[jalview.git] / src / jalview / binding / JalviewModelSequence.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 JalviewModelSequence.
29  * 
30  * @version $Revision$ $Date$
31  */
32 public class JalviewModelSequence implements java.io.Serializable
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * Field _JSeqList.
41    */
42   private java.util.Vector _JSeqList;
43
44   /**
45    * Field _JGroupList.
46    */
47   private java.util.Vector _JGroupList;
48
49   /**
50    * Field _viewportList.
51    */
52   private java.util.Vector _viewportList;
53
54   /**
55    * Field _userColoursList.
56    */
57   private java.util.Vector _userColoursList;
58
59   /**
60    * Field _treeList.
61    */
62   private java.util.Vector _treeList;
63
64   /**
65    * Field _featureSettings.
66    */
67   private jalview.binding.FeatureSettings _featureSettings;
68
69   // ----------------/
70   // - Constructors -/
71   // ----------------/
72
73   public JalviewModelSequence()
74   {
75     super();
76     this._JSeqList = new java.util.Vector();
77     this._JGroupList = new java.util.Vector();
78     this._viewportList = new java.util.Vector();
79     this._userColoursList = new java.util.Vector();
80     this._treeList = new java.util.Vector();
81   }
82
83   // -----------/
84   // - Methods -/
85   // -----------/
86
87   /**
88    * 
89    * 
90    * @param vJGroup
91    * @throws java.lang.IndexOutOfBoundsException
92    *           if the index given is outside the bounds of the collection
93    */
94   public void addJGroup(final jalview.binding.JGroup vJGroup)
95           throws java.lang.IndexOutOfBoundsException
96   {
97     this._JGroupList.addElement(vJGroup);
98   }
99
100   /**
101    * 
102    * 
103    * @param index
104    * @param vJGroup
105    * @throws java.lang.IndexOutOfBoundsException
106    *           if the index given is outside the bounds of the collection
107    */
108   public void addJGroup(final int index,
109           final jalview.binding.JGroup vJGroup)
110           throws java.lang.IndexOutOfBoundsException
111   {
112     this._JGroupList.add(index, vJGroup);
113   }
114
115   /**
116    * 
117    * 
118    * @param vJSeq
119    * @throws java.lang.IndexOutOfBoundsException
120    *           if the index given is outside the bounds of the collection
121    */
122   public void addJSeq(final jalview.binding.JSeq vJSeq)
123           throws java.lang.IndexOutOfBoundsException
124   {
125     this._JSeqList.addElement(vJSeq);
126   }
127
128   /**
129    * 
130    * 
131    * @param index
132    * @param vJSeq
133    * @throws java.lang.IndexOutOfBoundsException
134    *           if the index given is outside the bounds of the collection
135    */
136   public void addJSeq(final int index, final jalview.binding.JSeq vJSeq)
137           throws java.lang.IndexOutOfBoundsException
138   {
139     this._JSeqList.add(index, vJSeq);
140   }
141
142   /**
143    * 
144    * 
145    * @param vTree
146    * @throws java.lang.IndexOutOfBoundsException
147    *           if the index given is outside the bounds of the collection
148    */
149   public void addTree(final jalview.binding.Tree vTree)
150           throws java.lang.IndexOutOfBoundsException
151   {
152     this._treeList.addElement(vTree);
153   }
154
155   /**
156    * 
157    * 
158    * @param index
159    * @param vTree
160    * @throws java.lang.IndexOutOfBoundsException
161    *           if the index given is outside the bounds of the collection
162    */
163   public void addTree(final int index, final jalview.binding.Tree vTree)
164           throws java.lang.IndexOutOfBoundsException
165   {
166     this._treeList.add(index, vTree);
167   }
168
169   /**
170    * 
171    * 
172    * @param vUserColours
173    * @throws java.lang.IndexOutOfBoundsException
174    *           if the index given is outside the bounds of the collection
175    */
176   public void addUserColours(final jalview.binding.UserColours vUserColours)
177           throws java.lang.IndexOutOfBoundsException
178   {
179     this._userColoursList.addElement(vUserColours);
180   }
181
182   /**
183    * 
184    * 
185    * @param index
186    * @param vUserColours
187    * @throws java.lang.IndexOutOfBoundsException
188    *           if the index given is outside the bounds of the collection
189    */
190   public void addUserColours(final int index,
191           final jalview.binding.UserColours vUserColours)
192           throws java.lang.IndexOutOfBoundsException
193   {
194     this._userColoursList.add(index, vUserColours);
195   }
196
197   /**
198    * 
199    * 
200    * @param vViewport
201    * @throws java.lang.IndexOutOfBoundsException
202    *           if the index given is outside the bounds of the collection
203    */
204   public void addViewport(final jalview.binding.Viewport vViewport)
205           throws java.lang.IndexOutOfBoundsException
206   {
207     this._viewportList.addElement(vViewport);
208   }
209
210   /**
211    * 
212    * 
213    * @param index
214    * @param vViewport
215    * @throws java.lang.IndexOutOfBoundsException
216    *           if the index given is outside the bounds of the collection
217    */
218   public void addViewport(final int index,
219           final jalview.binding.Viewport vViewport)
220           throws java.lang.IndexOutOfBoundsException
221   {
222     this._viewportList.add(index, vViewport);
223   }
224
225   /**
226    * Method enumerateJGroup.
227    * 
228    * @return an Enumeration over all jalview.binding.JGroup elements
229    */
230   public java.util.Enumeration enumerateJGroup()
231   {
232     return this._JGroupList.elements();
233   }
234
235   /**
236    * Method enumerateJSeq.
237    * 
238    * @return an Enumeration over all jalview.binding.JSeq elements
239    */
240   public java.util.Enumeration enumerateJSeq()
241   {
242     return this._JSeqList.elements();
243   }
244
245   /**
246    * Method enumerateTree.
247    * 
248    * @return an Enumeration over all jalview.binding.Tree elements
249    */
250   public java.util.Enumeration enumerateTree()
251   {
252     return this._treeList.elements();
253   }
254
255   /**
256    * Method enumerateUserColours.
257    * 
258    * @return an Enumeration over all jalview.binding.UserColours elements
259    */
260   public java.util.Enumeration enumerateUserColours()
261   {
262     return this._userColoursList.elements();
263   }
264
265   /**
266    * Method enumerateViewport.
267    * 
268    * @return an Enumeration over all jalview.binding.Viewport elements
269    */
270   public java.util.Enumeration enumerateViewport()
271   {
272     return this._viewportList.elements();
273   }
274
275   /**
276    * Returns the value of field 'featureSettings'.
277    * 
278    * @return the value of field 'FeatureSettings'.
279    */
280   public jalview.binding.FeatureSettings getFeatureSettings()
281   {
282     return this._featureSettings;
283   }
284
285   /**
286    * Method getJGroup.
287    * 
288    * @param index
289    * @throws java.lang.IndexOutOfBoundsException
290    *           if the index given is outside the bounds of the collection
291    * @return the value of the jalview.binding.JGroup at the given index
292    */
293   public jalview.binding.JGroup getJGroup(final int index)
294           throws java.lang.IndexOutOfBoundsException
295   {
296     // check bounds for index
297     if (index < 0 || index >= this._JGroupList.size())
298     {
299       throw new IndexOutOfBoundsException("getJGroup: Index value '"
300               + index + "' not in range [0.."
301               + (this._JGroupList.size() - 1) + "]");
302     }
303
304     return (jalview.binding.JGroup) _JGroupList.get(index);
305   }
306
307   /**
308    * Method getJGroup.Returns the contents of the collection in an Array.
309    * <p>
310    * Note: Just in case the collection contents are changing in another thread,
311    * we pass a 0-length Array of the correct type into the API call. This way we
312    * <i>know</i> that the Array returned is of exactly the correct length.
313    * 
314    * @return this collection as an Array
315    */
316   public jalview.binding.JGroup[] getJGroup()
317   {
318     jalview.binding.JGroup[] array = new jalview.binding.JGroup[0];
319     return (jalview.binding.JGroup[]) this._JGroupList.toArray(array);
320   }
321
322   /**
323    * Method getJGroupCount.
324    * 
325    * @return the size of this collection
326    */
327   public int getJGroupCount()
328   {
329     return this._JGroupList.size();
330   }
331
332   /**
333    * Method getJSeq.
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 jalview.binding.JSeq at the given index
339    */
340   public jalview.binding.JSeq getJSeq(final int index)
341           throws java.lang.IndexOutOfBoundsException
342   {
343     // check bounds for index
344     if (index < 0 || index >= this._JSeqList.size())
345     {
346       throw new IndexOutOfBoundsException("getJSeq: Index value '" + index
347               + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
348     }
349
350     return (jalview.binding.JSeq) _JSeqList.get(index);
351   }
352
353   /**
354    * Method getJSeq.Returns the contents of the collection in an Array.
355    * <p>
356    * Note: Just in case the collection contents are changing in another thread,
357    * we pass a 0-length Array of the correct type into the API call. This way we
358    * <i>know</i> that the Array returned is of exactly the correct length.
359    * 
360    * @return this collection as an Array
361    */
362   public jalview.binding.JSeq[] getJSeq()
363   {
364     jalview.binding.JSeq[] array = new jalview.binding.JSeq[0];
365     return (jalview.binding.JSeq[]) this._JSeqList.toArray(array);
366   }
367
368   /**
369    * Method getJSeqCount.
370    * 
371    * @return the size of this collection
372    */
373   public int getJSeqCount()
374   {
375     return this._JSeqList.size();
376   }
377
378   /**
379    * Method getTree.
380    * 
381    * @param index
382    * @throws java.lang.IndexOutOfBoundsException
383    *           if the index given is outside the bounds of the collection
384    * @return the value of the jalview.binding.Tree at the given index
385    */
386   public jalview.binding.Tree getTree(final int index)
387           throws java.lang.IndexOutOfBoundsException
388   {
389     // check bounds for index
390     if (index < 0 || index >= this._treeList.size())
391     {
392       throw new IndexOutOfBoundsException("getTree: Index value '" + index
393               + "' not in range [0.." + (this._treeList.size() - 1) + "]");
394     }
395
396     return (jalview.binding.Tree) _treeList.get(index);
397   }
398
399   /**
400    * Method getTree.Returns the contents of the collection in an Array.
401    * <p>
402    * Note: Just in case the collection contents are changing in another thread,
403    * we pass a 0-length Array of the correct type into the API call. This way we
404    * <i>know</i> that the Array returned is of exactly the correct length.
405    * 
406    * @return this collection as an Array
407    */
408   public jalview.binding.Tree[] getTree()
409   {
410     jalview.binding.Tree[] array = new jalview.binding.Tree[0];
411     return (jalview.binding.Tree[]) this._treeList.toArray(array);
412   }
413
414   /**
415    * Method getTreeCount.
416    * 
417    * @return the size of this collection
418    */
419   public int getTreeCount()
420   {
421     return this._treeList.size();
422   }
423
424   /**
425    * Method getUserColours.
426    * 
427    * @param index
428    * @throws java.lang.IndexOutOfBoundsException
429    *           if the index given is outside the bounds of the collection
430    * @return the value of the jalview.binding.UserColours at the given index
431    */
432   public jalview.binding.UserColours getUserColours(final int index)
433           throws java.lang.IndexOutOfBoundsException
434   {
435     // check bounds for index
436     if (index < 0 || index >= this._userColoursList.size())
437     {
438       throw new IndexOutOfBoundsException("getUserColours: Index value '"
439               + index + "' not in range [0.."
440               + (this._userColoursList.size() - 1) + "]");
441     }
442
443     return (jalview.binding.UserColours) _userColoursList.get(index);
444   }
445
446   /**
447    * Method getUserColours.Returns the contents of the collection in an Array.
448    * <p>
449    * Note: Just in case the collection contents are changing in another thread,
450    * we pass a 0-length Array of the correct type into the API call. This way we
451    * <i>know</i> that the Array returned is of exactly the correct length.
452    * 
453    * @return this collection as an Array
454    */
455   public jalview.binding.UserColours[] getUserColours()
456   {
457     jalview.binding.UserColours[] array = new jalview.binding.UserColours[0];
458     return (jalview.binding.UserColours[]) this._userColoursList
459             .toArray(array);
460   }
461
462   /**
463    * Method getUserColoursCount.
464    * 
465    * @return the size of this collection
466    */
467   public int getUserColoursCount()
468   {
469     return this._userColoursList.size();
470   }
471
472   /**
473    * Method getViewport.
474    * 
475    * @param index
476    * @throws java.lang.IndexOutOfBoundsException
477    *           if the index given is outside the bounds of the collection
478    * @return the value of the jalview.binding.Viewport at the given index
479    */
480   public jalview.binding.Viewport getViewport(final int index)
481           throws java.lang.IndexOutOfBoundsException
482   {
483     // check bounds for index
484     if (index < 0 || index >= this._viewportList.size())
485     {
486       throw new IndexOutOfBoundsException("getViewport: Index value '"
487               + index + "' not in range [0.."
488               + (this._viewportList.size() - 1) + "]");
489     }
490
491     return (jalview.binding.Viewport) _viewportList.get(index);
492   }
493
494   /**
495    * Method getViewport.Returns the contents of the collection in an Array.
496    * <p>
497    * Note: Just in case the collection contents are changing in another thread,
498    * we pass a 0-length Array of the correct type into the API call. This way we
499    * <i>know</i> that the Array returned is of exactly the correct length.
500    * 
501    * @return this collection as an Array
502    */
503   public jalview.binding.Viewport[] getViewport()
504   {
505     jalview.binding.Viewport[] array = new jalview.binding.Viewport[0];
506     return (jalview.binding.Viewport[]) this._viewportList.toArray(array);
507   }
508
509   /**
510    * Method getViewportCount.
511    * 
512    * @return the size of this collection
513    */
514   public int getViewportCount()
515   {
516     return this._viewportList.size();
517   }
518
519   /**
520    * Method isValid.
521    * 
522    * @return true if this object is valid according to the schema
523    */
524   public boolean isValid()
525   {
526     try
527     {
528       validate();
529     } catch (org.exolab.castor.xml.ValidationException vex)
530     {
531       return false;
532     }
533     return true;
534   }
535
536   /**
537    * 
538    * 
539    * @param out
540    * @throws org.exolab.castor.xml.MarshalException
541    *           if object is null or if any SAXException is thrown during
542    *           marshaling
543    * @throws org.exolab.castor.xml.ValidationException
544    *           if this object is an invalid instance according to the schema
545    */
546   public void marshal(final java.io.Writer out)
547           throws org.exolab.castor.xml.MarshalException,
548           org.exolab.castor.xml.ValidationException
549   {
550     Marshaller.marshal(this, out);
551   }
552
553   /**
554    * 
555    * 
556    * @param handler
557    * @throws java.io.IOException
558    *           if an IOException occurs during marshaling
559    * @throws org.exolab.castor.xml.ValidationException
560    *           if this object is an invalid instance according to the schema
561    * @throws org.exolab.castor.xml.MarshalException
562    *           if object is null or if any SAXException is thrown during
563    *           marshaling
564    */
565   public void marshal(final org.xml.sax.ContentHandler handler)
566           throws java.io.IOException,
567           org.exolab.castor.xml.MarshalException,
568           org.exolab.castor.xml.ValidationException
569   {
570     Marshaller.marshal(this, handler);
571   }
572
573   /**
574      */
575   public void removeAllJGroup()
576   {
577     this._JGroupList.clear();
578   }
579
580   /**
581      */
582   public void removeAllJSeq()
583   {
584     this._JSeqList.clear();
585   }
586
587   /**
588      */
589   public void removeAllTree()
590   {
591     this._treeList.clear();
592   }
593
594   /**
595      */
596   public void removeAllUserColours()
597   {
598     this._userColoursList.clear();
599   }
600
601   /**
602      */
603   public void removeAllViewport()
604   {
605     this._viewportList.clear();
606   }
607
608   /**
609    * Method removeJGroup.
610    * 
611    * @param vJGroup
612    * @return true if the object was removed from the collection.
613    */
614   public boolean removeJGroup(final jalview.binding.JGroup vJGroup)
615   {
616     boolean removed = _JGroupList.remove(vJGroup);
617     return removed;
618   }
619
620   /**
621    * Method removeJGroupAt.
622    * 
623    * @param index
624    * @return the element removed from the collection
625    */
626   public jalview.binding.JGroup removeJGroupAt(final int index)
627   {
628     java.lang.Object obj = this._JGroupList.remove(index);
629     return (jalview.binding.JGroup) obj;
630   }
631
632   /**
633    * Method removeJSeq.
634    * 
635    * @param vJSeq
636    * @return true if the object was removed from the collection.
637    */
638   public boolean removeJSeq(final jalview.binding.JSeq vJSeq)
639   {
640     boolean removed = _JSeqList.remove(vJSeq);
641     return removed;
642   }
643
644   /**
645    * Method removeJSeqAt.
646    * 
647    * @param index
648    * @return the element removed from the collection
649    */
650   public jalview.binding.JSeq removeJSeqAt(final int index)
651   {
652     java.lang.Object obj = this._JSeqList.remove(index);
653     return (jalview.binding.JSeq) obj;
654   }
655
656   /**
657    * Method removeTree.
658    * 
659    * @param vTree
660    * @return true if the object was removed from the collection.
661    */
662   public boolean removeTree(final jalview.binding.Tree vTree)
663   {
664     boolean removed = _treeList.remove(vTree);
665     return removed;
666   }
667
668   /**
669    * Method removeTreeAt.
670    * 
671    * @param index
672    * @return the element removed from the collection
673    */
674   public jalview.binding.Tree removeTreeAt(final int index)
675   {
676     java.lang.Object obj = this._treeList.remove(index);
677     return (jalview.binding.Tree) obj;
678   }
679
680   /**
681    * Method removeUserColours.
682    * 
683    * @param vUserColours
684    * @return true if the object was removed from the collection.
685    */
686   public boolean removeUserColours(
687           final jalview.binding.UserColours vUserColours)
688   {
689     boolean removed = _userColoursList.remove(vUserColours);
690     return removed;
691   }
692
693   /**
694    * Method removeUserColoursAt.
695    * 
696    * @param index
697    * @return the element removed from the collection
698    */
699   public jalview.binding.UserColours removeUserColoursAt(final int index)
700   {
701     java.lang.Object obj = this._userColoursList.remove(index);
702     return (jalview.binding.UserColours) obj;
703   }
704
705   /**
706    * Method removeViewport.
707    * 
708    * @param vViewport
709    * @return true if the object was removed from the collection.
710    */
711   public boolean removeViewport(final jalview.binding.Viewport vViewport)
712   {
713     boolean removed = _viewportList.remove(vViewport);
714     return removed;
715   }
716
717   /**
718    * Method removeViewportAt.
719    * 
720    * @param index
721    * @return the element removed from the collection
722    */
723   public jalview.binding.Viewport removeViewportAt(final int index)
724   {
725     java.lang.Object obj = this._viewportList.remove(index);
726     return (jalview.binding.Viewport) obj;
727   }
728
729   /**
730    * Sets the value of field 'featureSettings'.
731    * 
732    * @param featureSettings
733    *          the value of field 'featureSettings'.
734    */
735   public void setFeatureSettings(
736           final jalview.binding.FeatureSettings featureSettings)
737   {
738     this._featureSettings = featureSettings;
739   }
740
741   /**
742    * 
743    * 
744    * @param index
745    * @param vJGroup
746    * @throws java.lang.IndexOutOfBoundsException
747    *           if the index given is outside the bounds of the collection
748    */
749   public void setJGroup(final int index,
750           final jalview.binding.JGroup vJGroup)
751           throws java.lang.IndexOutOfBoundsException
752   {
753     // check bounds for index
754     if (index < 0 || index >= this._JGroupList.size())
755     {
756       throw new IndexOutOfBoundsException("setJGroup: Index value '"
757               + index + "' not in range [0.."
758               + (this._JGroupList.size() - 1) + "]");
759     }
760
761     this._JGroupList.set(index, vJGroup);
762   }
763
764   /**
765    * 
766    * 
767    * @param vJGroupArray
768    */
769   public void setJGroup(final jalview.binding.JGroup[] vJGroupArray)
770   {
771     // -- copy array
772     _JGroupList.clear();
773
774     for (int i = 0; i < vJGroupArray.length; i++)
775     {
776       this._JGroupList.add(vJGroupArray[i]);
777     }
778   }
779
780   /**
781    * 
782    * 
783    * @param index
784    * @param vJSeq
785    * @throws java.lang.IndexOutOfBoundsException
786    *           if the index given is outside the bounds of the collection
787    */
788   public void setJSeq(final int index, final jalview.binding.JSeq vJSeq)
789           throws java.lang.IndexOutOfBoundsException
790   {
791     // check bounds for index
792     if (index < 0 || index >= this._JSeqList.size())
793     {
794       throw new IndexOutOfBoundsException("setJSeq: Index value '" + index
795               + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
796     }
797
798     this._JSeqList.set(index, vJSeq);
799   }
800
801   /**
802    * 
803    * 
804    * @param vJSeqArray
805    */
806   public void setJSeq(final jalview.binding.JSeq[] vJSeqArray)
807   {
808     // -- copy array
809     _JSeqList.clear();
810
811     for (int i = 0; i < vJSeqArray.length; i++)
812     {
813       this._JSeqList.add(vJSeqArray[i]);
814     }
815   }
816
817   /**
818    * 
819    * 
820    * @param index
821    * @param vTree
822    * @throws java.lang.IndexOutOfBoundsException
823    *           if the index given is outside the bounds of the collection
824    */
825   public void setTree(final int index, final jalview.binding.Tree vTree)
826           throws java.lang.IndexOutOfBoundsException
827   {
828     // check bounds for index
829     if (index < 0 || index >= this._treeList.size())
830     {
831       throw new IndexOutOfBoundsException("setTree: Index value '" + index
832               + "' not in range [0.." + (this._treeList.size() - 1) + "]");
833     }
834
835     this._treeList.set(index, vTree);
836   }
837
838   /**
839    * 
840    * 
841    * @param vTreeArray
842    */
843   public void setTree(final jalview.binding.Tree[] vTreeArray)
844   {
845     // -- copy array
846     _treeList.clear();
847
848     for (int i = 0; i < vTreeArray.length; i++)
849     {
850       this._treeList.add(vTreeArray[i]);
851     }
852   }
853
854   /**
855    * 
856    * 
857    * @param index
858    * @param vUserColours
859    * @throws java.lang.IndexOutOfBoundsException
860    *           if the index given is outside the bounds of the collection
861    */
862   public void setUserColours(final int index,
863           final jalview.binding.UserColours vUserColours)
864           throws java.lang.IndexOutOfBoundsException
865   {
866     // check bounds for index
867     if (index < 0 || index >= this._userColoursList.size())
868     {
869       throw new IndexOutOfBoundsException("setUserColours: Index value '"
870               + index + "' not in range [0.."
871               + (this._userColoursList.size() - 1) + "]");
872     }
873
874     this._userColoursList.set(index, vUserColours);
875   }
876
877   /**
878    * 
879    * 
880    * @param vUserColoursArray
881    */
882   public void setUserColours(
883           final jalview.binding.UserColours[] vUserColoursArray)
884   {
885     // -- copy array
886     _userColoursList.clear();
887
888     for (int i = 0; i < vUserColoursArray.length; i++)
889     {
890       this._userColoursList.add(vUserColoursArray[i]);
891     }
892   }
893
894   /**
895    * 
896    * 
897    * @param index
898    * @param vViewport
899    * @throws java.lang.IndexOutOfBoundsException
900    *           if the index given is outside the bounds of the collection
901    */
902   public void setViewport(final int index,
903           final jalview.binding.Viewport vViewport)
904           throws java.lang.IndexOutOfBoundsException
905   {
906     // check bounds for index
907     if (index < 0 || index >= this._viewportList.size())
908     {
909       throw new IndexOutOfBoundsException("setViewport: Index value '"
910               + index + "' not in range [0.."
911               + (this._viewportList.size() - 1) + "]");
912     }
913
914     this._viewportList.set(index, vViewport);
915   }
916
917   /**
918    * 
919    * 
920    * @param vViewportArray
921    */
922   public void setViewport(final jalview.binding.Viewport[] vViewportArray)
923   {
924     // -- copy array
925     _viewportList.clear();
926
927     for (int i = 0; i < vViewportArray.length; i++)
928     {
929       this._viewportList.add(vViewportArray[i]);
930     }
931   }
932
933   /**
934    * Method unmarshal.
935    * 
936    * @param reader
937    * @throws org.exolab.castor.xml.MarshalException
938    *           if object is null or if any SAXException is thrown during
939    *           marshaling
940    * @throws org.exolab.castor.xml.ValidationException
941    *           if this object is an invalid instance according to the schema
942    * @return the unmarshaled jalview.binding.JalviewModelSequence
943    */
944   public static jalview.binding.JalviewModelSequence unmarshal(
945           final java.io.Reader reader)
946           throws org.exolab.castor.xml.MarshalException,
947           org.exolab.castor.xml.ValidationException
948   {
949     return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal(
950             jalview.binding.JalviewModelSequence.class, reader);
951   }
952
953   /**
954    * 
955    * 
956    * @throws org.exolab.castor.xml.ValidationException
957    *           if this object is an invalid instance according to the schema
958    */
959   public void validate() throws org.exolab.castor.xml.ValidationException
960   {
961     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
962     validator.validate(this);
963   }
964
965 }