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
5 * This file is part of Jalview.
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.
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.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
28 * Class JalviewModelSequence.
30 * @version $Revision$ $Date$
32 public class JalviewModelSequence implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
42 private java.util.Vector _JSeqList;
47 private java.util.Vector _JGroupList;
50 * Field _viewportList.
52 private java.util.Vector _viewportList;
55 * Field _userColoursList.
57 private java.util.Vector _userColoursList;
62 private java.util.Vector _treeList;
65 * Field _featureSettings.
67 private jalview.schemabinding.version2.FeatureSettings _featureSettings;
73 public JalviewModelSequence()
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();
91 * @throws java.lang.IndexOutOfBoundsException
92 * if the index given is outside the bounds of the collection
94 public void addJGroup(final jalview.schemabinding.version2.JGroup vJGroup)
95 throws java.lang.IndexOutOfBoundsException
97 this._JGroupList.addElement(vJGroup);
105 * @throws java.lang.IndexOutOfBoundsException
106 * if the index given is outside the bounds of the collection
108 public void addJGroup(final int index,
109 final jalview.schemabinding.version2.JGroup vJGroup)
110 throws java.lang.IndexOutOfBoundsException
112 this._JGroupList.add(index, vJGroup);
119 * @throws java.lang.IndexOutOfBoundsException
120 * if the index given is outside the bounds of the collection
122 public void addJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
123 throws java.lang.IndexOutOfBoundsException
125 this._JSeqList.addElement(vJSeq);
133 * @throws java.lang.IndexOutOfBoundsException
134 * if the index given is outside the bounds of the collection
136 public void addJSeq(final int index,
137 final jalview.schemabinding.version2.JSeq vJSeq)
138 throws java.lang.IndexOutOfBoundsException
140 this._JSeqList.add(index, vJSeq);
147 * @throws java.lang.IndexOutOfBoundsException
148 * if the index given is outside the bounds of the collection
150 public void addTree(final jalview.schemabinding.version2.Tree vTree)
151 throws java.lang.IndexOutOfBoundsException
153 this._treeList.addElement(vTree);
161 * @throws java.lang.IndexOutOfBoundsException
162 * if the index given is outside the bounds of the collection
164 public void addTree(final int index,
165 final jalview.schemabinding.version2.Tree vTree)
166 throws java.lang.IndexOutOfBoundsException
168 this._treeList.add(index, vTree);
174 * @param vUserColours
175 * @throws java.lang.IndexOutOfBoundsException
176 * if the index given is outside the bounds of the collection
178 public void addUserColours(
179 final jalview.schemabinding.version2.UserColours vUserColours)
180 throws java.lang.IndexOutOfBoundsException
182 this._userColoursList.addElement(vUserColours);
189 * @param vUserColours
190 * @throws java.lang.IndexOutOfBoundsException
191 * if the index given is outside the bounds of the collection
193 public void addUserColours(final int index,
194 final jalview.schemabinding.version2.UserColours vUserColours)
195 throws java.lang.IndexOutOfBoundsException
197 this._userColoursList.add(index, vUserColours);
204 * @throws java.lang.IndexOutOfBoundsException
205 * if the index given is outside the bounds of the collection
207 public void addViewport(
208 final jalview.schemabinding.version2.Viewport vViewport)
209 throws java.lang.IndexOutOfBoundsException
211 this._viewportList.addElement(vViewport);
219 * @throws java.lang.IndexOutOfBoundsException
220 * if the index given is outside the bounds of the collection
222 public void addViewport(final int index,
223 final jalview.schemabinding.version2.Viewport vViewport)
224 throws java.lang.IndexOutOfBoundsException
226 this._viewportList.add(index, vViewport);
230 * Method enumerateJGroup.
232 * @return an Enumeration over all jalview.schemabinding.version2.JGroup
235 public java.util.Enumeration enumerateJGroup()
237 return this._JGroupList.elements();
241 * Method enumerateJSeq.
243 * @return an Enumeration over all jalview.schemabinding.version2.JSeq
246 public java.util.Enumeration enumerateJSeq()
248 return this._JSeqList.elements();
252 * Method enumerateTree.
254 * @return an Enumeration over all jalview.schemabinding.version2.Tree
257 public java.util.Enumeration enumerateTree()
259 return this._treeList.elements();
263 * Method enumerateUserColours.
265 * @return an Enumeration over all jalview.schemabinding.version2.UserColours
268 public java.util.Enumeration enumerateUserColours()
270 return this._userColoursList.elements();
274 * Method enumerateViewport.
276 * @return an Enumeration over all jalview.schemabinding.version2.Viewport
279 public java.util.Enumeration enumerateViewport()
281 return this._viewportList.elements();
285 * Returns the value of field 'featureSettings'.
287 * @return the value of field 'FeatureSettings'.
289 public jalview.schemabinding.version2.FeatureSettings getFeatureSettings()
291 return this._featureSettings;
298 * @throws java.lang.IndexOutOfBoundsException
299 * if the index given is outside the bounds of the collection
300 * @return the value of the jalview.schemabinding.version2.JGroup at the given
303 public jalview.schemabinding.version2.JGroup getJGroup(final int index)
304 throws java.lang.IndexOutOfBoundsException
306 // check bounds for index
307 if (index < 0 || index >= this._JGroupList.size())
309 throw new IndexOutOfBoundsException("getJGroup: Index value '"
310 + index + "' not in range [0.."
311 + (this._JGroupList.size() - 1) + "]");
314 return (jalview.schemabinding.version2.JGroup) _JGroupList.get(index);
318 * Method getJGroup.Returns the contents of the collection in an Array.
320 * Note: Just in case the collection contents are changing in another thread,
321 * we pass a 0-length Array of the correct type into the API call. This way we
322 * <i>know</i> that the Array returned is of exactly the correct length.
324 * @return this collection as an Array
326 public jalview.schemabinding.version2.JGroup[] getJGroup()
328 jalview.schemabinding.version2.JGroup[] array = new jalview.schemabinding.version2.JGroup[0];
329 return (jalview.schemabinding.version2.JGroup[]) this._JGroupList
334 * Method getJGroupCount.
336 * @return the size of this collection
338 public int getJGroupCount()
340 return this._JGroupList.size();
347 * @throws java.lang.IndexOutOfBoundsException
348 * if the index given is outside the bounds of the collection
349 * @return the value of the jalview.schemabinding.version2.JSeq at the given
352 public jalview.schemabinding.version2.JSeq getJSeq(final int index)
353 throws java.lang.IndexOutOfBoundsException
355 // check bounds for index
356 if (index < 0 || index >= this._JSeqList.size())
358 throw new IndexOutOfBoundsException("getJSeq: Index value '" + index
359 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
362 return (jalview.schemabinding.version2.JSeq) _JSeqList.get(index);
366 * Method getJSeq.Returns the contents of the collection in an Array.
368 * Note: Just in case the collection contents are changing in another thread,
369 * we pass a 0-length Array of the correct type into the API call. This way we
370 * <i>know</i> that the Array returned is of exactly the correct length.
372 * @return this collection as an Array
374 public jalview.schemabinding.version2.JSeq[] getJSeq()
376 jalview.schemabinding.version2.JSeq[] array = new jalview.schemabinding.version2.JSeq[0];
377 return (jalview.schemabinding.version2.JSeq[]) this._JSeqList
382 * Method getJSeqCount.
384 * @return the size of this collection
386 public int getJSeqCount()
388 return this._JSeqList.size();
395 * @throws java.lang.IndexOutOfBoundsException
396 * if the index given is outside the bounds of the collection
397 * @return the value of the jalview.schemabinding.version2.Tree at the given
400 public jalview.schemabinding.version2.Tree getTree(final int index)
401 throws java.lang.IndexOutOfBoundsException
403 // check bounds for index
404 if (index < 0 || index >= this._treeList.size())
406 throw new IndexOutOfBoundsException("getTree: Index value '" + index
407 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
410 return (jalview.schemabinding.version2.Tree) _treeList.get(index);
414 * Method getTree.Returns the contents of the collection in an Array.
416 * Note: Just in case the collection contents are changing in another thread,
417 * we pass a 0-length Array of the correct type into the API call. This way we
418 * <i>know</i> that the Array returned is of exactly the correct length.
420 * @return this collection as an Array
422 public jalview.schemabinding.version2.Tree[] getTree()
424 jalview.schemabinding.version2.Tree[] array = new jalview.schemabinding.version2.Tree[0];
425 return (jalview.schemabinding.version2.Tree[]) this._treeList
430 * Method getTreeCount.
432 * @return the size of this collection
434 public int getTreeCount()
436 return this._treeList.size();
440 * Method getUserColours.
443 * @throws java.lang.IndexOutOfBoundsException
444 * if the index given is outside the bounds of the collection
445 * @return the value of the jalview.schemabinding.version2.UserColours at the
448 public jalview.schemabinding.version2.UserColours getUserColours(
449 final int index) throws java.lang.IndexOutOfBoundsException
451 // check bounds for index
452 if (index < 0 || index >= this._userColoursList.size())
454 throw new IndexOutOfBoundsException("getUserColours: Index value '"
455 + index + "' not in range [0.."
456 + (this._userColoursList.size() - 1) + "]");
459 return (jalview.schemabinding.version2.UserColours) _userColoursList
464 * Method getUserColours.Returns the contents of the collection in an Array.
466 * Note: Just in case the collection contents are changing in another thread,
467 * we pass a 0-length Array of the correct type into the API call. This way we
468 * <i>know</i> that the Array returned is of exactly the correct length.
470 * @return this collection as an Array
472 public jalview.schemabinding.version2.UserColours[] getUserColours()
474 jalview.schemabinding.version2.UserColours[] array = new jalview.schemabinding.version2.UserColours[0];
475 return (jalview.schemabinding.version2.UserColours[]) this._userColoursList
480 * Method getUserColoursCount.
482 * @return the size of this collection
484 public int getUserColoursCount()
486 return this._userColoursList.size();
490 * Method getViewport.
493 * @throws java.lang.IndexOutOfBoundsException
494 * if the index given is outside the bounds of the collection
495 * @return the value of the jalview.schemabinding.version2.Viewport at the
498 public jalview.schemabinding.version2.Viewport getViewport(final int index)
499 throws java.lang.IndexOutOfBoundsException
501 // check bounds for index
502 if (index < 0 || index >= this._viewportList.size())
504 throw new IndexOutOfBoundsException("getViewport: Index value '"
505 + index + "' not in range [0.."
506 + (this._viewportList.size() - 1) + "]");
509 return (jalview.schemabinding.version2.Viewport) _viewportList
514 * Method getViewport.Returns the contents of the collection in an Array.
516 * Note: Just in case the collection contents are changing in another thread,
517 * we pass a 0-length Array of the correct type into the API call. This way we
518 * <i>know</i> that the Array returned is of exactly the correct length.
520 * @return this collection as an Array
522 public jalview.schemabinding.version2.Viewport[] getViewport()
524 jalview.schemabinding.version2.Viewport[] array = new jalview.schemabinding.version2.Viewport[0];
525 return (jalview.schemabinding.version2.Viewport[]) this._viewportList
530 * Method getViewportCount.
532 * @return the size of this collection
534 public int getViewportCount()
536 return this._viewportList.size();
542 * @return true if this object is valid according to the schema
544 public boolean isValid()
549 } catch (org.exolab.castor.xml.ValidationException vex)
560 * @throws org.exolab.castor.xml.MarshalException
561 * if object is null or if any SAXException is thrown during
563 * @throws org.exolab.castor.xml.ValidationException
564 * if this object is an invalid instance according to the schema
566 public void marshal(final java.io.Writer out)
567 throws org.exolab.castor.xml.MarshalException,
568 org.exolab.castor.xml.ValidationException
570 Marshaller.marshal(this, out);
577 * @throws java.io.IOException
578 * if an IOException occurs during marshaling
579 * @throws org.exolab.castor.xml.ValidationException
580 * if this object is an invalid instance according to the schema
581 * @throws org.exolab.castor.xml.MarshalException
582 * if object is null or if any SAXException is thrown during
585 public void marshal(final org.xml.sax.ContentHandler handler)
586 throws java.io.IOException,
587 org.exolab.castor.xml.MarshalException,
588 org.exolab.castor.xml.ValidationException
590 Marshaller.marshal(this, handler);
595 public void removeAllJGroup()
597 this._JGroupList.clear();
602 public void removeAllJSeq()
604 this._JSeqList.clear();
609 public void removeAllTree()
611 this._treeList.clear();
616 public void removeAllUserColours()
618 this._userColoursList.clear();
623 public void removeAllViewport()
625 this._viewportList.clear();
629 * Method removeJGroup.
632 * @return true if the object was removed from the collection.
634 public boolean removeJGroup(
635 final jalview.schemabinding.version2.JGroup vJGroup)
637 boolean removed = _JGroupList.remove(vJGroup);
642 * Method removeJGroupAt.
645 * @return the element removed from the collection
647 public jalview.schemabinding.version2.JGroup removeJGroupAt(
650 java.lang.Object obj = this._JGroupList.remove(index);
651 return (jalview.schemabinding.version2.JGroup) obj;
658 * @return true if the object was removed from the collection.
660 public boolean removeJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
662 boolean removed = _JSeqList.remove(vJSeq);
667 * Method removeJSeqAt.
670 * @return the element removed from the collection
672 public jalview.schemabinding.version2.JSeq removeJSeqAt(final int index)
674 java.lang.Object obj = this._JSeqList.remove(index);
675 return (jalview.schemabinding.version2.JSeq) obj;
682 * @return true if the object was removed from the collection.
684 public boolean removeTree(final jalview.schemabinding.version2.Tree vTree)
686 boolean removed = _treeList.remove(vTree);
691 * Method removeTreeAt.
694 * @return the element removed from the collection
696 public jalview.schemabinding.version2.Tree removeTreeAt(final int index)
698 java.lang.Object obj = this._treeList.remove(index);
699 return (jalview.schemabinding.version2.Tree) obj;
703 * Method removeUserColours.
705 * @param vUserColours
706 * @return true if the object was removed from the collection.
708 public boolean removeUserColours(
709 final jalview.schemabinding.version2.UserColours vUserColours)
711 boolean removed = _userColoursList.remove(vUserColours);
716 * Method removeUserColoursAt.
719 * @return the element removed from the collection
721 public jalview.schemabinding.version2.UserColours removeUserColoursAt(
724 java.lang.Object obj = this._userColoursList.remove(index);
725 return (jalview.schemabinding.version2.UserColours) obj;
729 * Method removeViewport.
732 * @return true if the object was removed from the collection.
734 public boolean removeViewport(
735 final jalview.schemabinding.version2.Viewport vViewport)
737 boolean removed = _viewportList.remove(vViewport);
742 * Method removeViewportAt.
745 * @return the element removed from the collection
747 public jalview.schemabinding.version2.Viewport removeViewportAt(
750 java.lang.Object obj = this._viewportList.remove(index);
751 return (jalview.schemabinding.version2.Viewport) obj;
755 * Sets the value of field 'featureSettings'.
757 * @param featureSettings
758 * the value of field 'featureSettings'.
760 public void setFeatureSettings(
761 final jalview.schemabinding.version2.FeatureSettings featureSettings)
763 this._featureSettings = featureSettings;
771 * @throws java.lang.IndexOutOfBoundsException
772 * if the index given is outside the bounds of the collection
774 public void setJGroup(final int index,
775 final jalview.schemabinding.version2.JGroup vJGroup)
776 throws java.lang.IndexOutOfBoundsException
778 // check bounds for index
779 if (index < 0 || index >= this._JGroupList.size())
781 throw new IndexOutOfBoundsException("setJGroup: Index value '"
782 + index + "' not in range [0.."
783 + (this._JGroupList.size() - 1) + "]");
786 this._JGroupList.set(index, vJGroup);
792 * @param vJGroupArray
794 public void setJGroup(
795 final jalview.schemabinding.version2.JGroup[] vJGroupArray)
800 for (int i = 0; i < vJGroupArray.length; i++)
802 this._JGroupList.add(vJGroupArray[i]);
811 * @throws java.lang.IndexOutOfBoundsException
812 * if the index given is outside the bounds of the collection
814 public void setJSeq(final int index,
815 final jalview.schemabinding.version2.JSeq vJSeq)
816 throws java.lang.IndexOutOfBoundsException
818 // check bounds for index
819 if (index < 0 || index >= this._JSeqList.size())
821 throw new IndexOutOfBoundsException("setJSeq: Index value '" + index
822 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
825 this._JSeqList.set(index, vJSeq);
833 public void setJSeq(final jalview.schemabinding.version2.JSeq[] vJSeqArray)
838 for (int i = 0; i < vJSeqArray.length; i++)
840 this._JSeqList.add(vJSeqArray[i]);
849 * @throws java.lang.IndexOutOfBoundsException
850 * if the index given is outside the bounds of the collection
852 public void setTree(final int index,
853 final jalview.schemabinding.version2.Tree vTree)
854 throws java.lang.IndexOutOfBoundsException
856 // check bounds for index
857 if (index < 0 || index >= this._treeList.size())
859 throw new IndexOutOfBoundsException("setTree: Index value '" + index
860 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
863 this._treeList.set(index, vTree);
871 public void setTree(final jalview.schemabinding.version2.Tree[] vTreeArray)
876 for (int i = 0; i < vTreeArray.length; i++)
878 this._treeList.add(vTreeArray[i]);
886 * @param vUserColours
887 * @throws java.lang.IndexOutOfBoundsException
888 * if the index given is outside the bounds of the collection
890 public void setUserColours(final int index,
891 final jalview.schemabinding.version2.UserColours vUserColours)
892 throws java.lang.IndexOutOfBoundsException
894 // check bounds for index
895 if (index < 0 || index >= this._userColoursList.size())
897 throw new IndexOutOfBoundsException("setUserColours: Index value '"
898 + index + "' not in range [0.."
899 + (this._userColoursList.size() - 1) + "]");
902 this._userColoursList.set(index, vUserColours);
908 * @param vUserColoursArray
910 public void setUserColours(
911 final jalview.schemabinding.version2.UserColours[] vUserColoursArray)
914 _userColoursList.clear();
916 for (int i = 0; i < vUserColoursArray.length; i++)
918 this._userColoursList.add(vUserColoursArray[i]);
927 * @throws java.lang.IndexOutOfBoundsException
928 * if the index given is outside the bounds of the collection
930 public void setViewport(final int index,
931 final jalview.schemabinding.version2.Viewport vViewport)
932 throws java.lang.IndexOutOfBoundsException
934 // check bounds for index
935 if (index < 0 || index >= this._viewportList.size())
937 throw new IndexOutOfBoundsException("setViewport: Index value '"
938 + index + "' not in range [0.."
939 + (this._viewportList.size() - 1) + "]");
942 this._viewportList.set(index, vViewport);
948 * @param vViewportArray
950 public void setViewport(
951 final jalview.schemabinding.version2.Viewport[] vViewportArray)
954 _viewportList.clear();
956 for (int i = 0; i < vViewportArray.length; i++)
958 this._viewportList.add(vViewportArray[i]);
966 * @throws org.exolab.castor.xml.MarshalException
967 * if object is null or if any SAXException is thrown during
969 * @throws org.exolab.castor.xml.ValidationException
970 * if this object is an invalid instance according to the schema
971 * @return the unmarshaled jalview.schemabinding.version2.JalviewModelSequence
973 public static jalview.schemabinding.version2.JalviewModelSequence unmarshal(
974 final java.io.Reader reader)
975 throws org.exolab.castor.xml.MarshalException,
976 org.exolab.castor.xml.ValidationException
978 return (jalview.schemabinding.version2.JalviewModelSequence) Unmarshaller
980 jalview.schemabinding.version2.JalviewModelSequence.class,
987 * @throws org.exolab.castor.xml.ValidationException
988 * if this object is an invalid instance according to the schema
990 public void validate() throws org.exolab.castor.xml.ValidationException
992 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
993 validator.validate(this);