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