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