2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.binding;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
29 * Class JalviewModelSequence.
31 * @version $Revision$ $Date$
33 public class JalviewModelSequence implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private java.util.Vector _JSeqList;
48 private java.util.Vector _JGroupList;
51 * Field _viewportList.
53 private java.util.Vector _viewportList;
56 * Field _userColoursList.
58 private java.util.Vector _userColoursList;
63 private java.util.Vector _treeList;
66 * Field _featureSettings.
68 private jalview.binding.FeatureSettings _featureSettings;
74 public JalviewModelSequence()
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();
92 * @throws java.lang.IndexOutOfBoundsException
93 * if the index given is outside the bounds of the collection
95 public void addJGroup(final jalview.binding.JGroup vJGroup)
96 throws java.lang.IndexOutOfBoundsException
98 this._JGroupList.addElement(vJGroup);
106 * @throws java.lang.IndexOutOfBoundsException
107 * if the index given is outside the bounds of the collection
109 public void addJGroup(final int index,
110 final jalview.binding.JGroup vJGroup)
111 throws java.lang.IndexOutOfBoundsException
113 this._JGroupList.add(index, vJGroup);
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
123 public void addJSeq(final jalview.binding.JSeq vJSeq)
124 throws java.lang.IndexOutOfBoundsException
126 this._JSeqList.addElement(vJSeq);
134 * @throws java.lang.IndexOutOfBoundsException
135 * if the index given is outside the bounds of the collection
137 public void addJSeq(final int index, final jalview.binding.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.binding.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, final jalview.binding.Tree vTree)
165 throws java.lang.IndexOutOfBoundsException
167 this._treeList.add(index, vTree);
173 * @param vUserColours
174 * @throws java.lang.IndexOutOfBoundsException
175 * if the index given is outside the bounds of the collection
177 public void addUserColours(final jalview.binding.UserColours vUserColours)
178 throws java.lang.IndexOutOfBoundsException
180 this._userColoursList.addElement(vUserColours);
187 * @param vUserColours
188 * @throws java.lang.IndexOutOfBoundsException
189 * if the index given is outside the bounds of the collection
191 public void addUserColours(final int index,
192 final jalview.binding.UserColours vUserColours)
193 throws java.lang.IndexOutOfBoundsException
195 this._userColoursList.add(index, vUserColours);
202 * @throws java.lang.IndexOutOfBoundsException
203 * if the index given is outside the bounds of the collection
205 public void addViewport(final jalview.binding.Viewport vViewport)
206 throws java.lang.IndexOutOfBoundsException
208 this._viewportList.addElement(vViewport);
216 * @throws java.lang.IndexOutOfBoundsException
217 * if the index given is outside the bounds of the collection
219 public void addViewport(final int index,
220 final jalview.binding.Viewport vViewport)
221 throws java.lang.IndexOutOfBoundsException
223 this._viewportList.add(index, vViewport);
227 * Method enumerateJGroup.
229 * @return an Enumeration over all jalview.binding.JGroup elements
231 public java.util.Enumeration enumerateJGroup()
233 return this._JGroupList.elements();
237 * Method enumerateJSeq.
239 * @return an Enumeration over all jalview.binding.JSeq elements
241 public java.util.Enumeration enumerateJSeq()
243 return this._JSeqList.elements();
247 * Method enumerateTree.
249 * @return an Enumeration over all jalview.binding.Tree elements
251 public java.util.Enumeration enumerateTree()
253 return this._treeList.elements();
257 * Method enumerateUserColours.
259 * @return an Enumeration over all jalview.binding.UserColours elements
261 public java.util.Enumeration enumerateUserColours()
263 return this._userColoursList.elements();
267 * Method enumerateViewport.
269 * @return an Enumeration over all jalview.binding.Viewport elements
271 public java.util.Enumeration enumerateViewport()
273 return this._viewportList.elements();
277 * Returns the value of field 'featureSettings'.
279 * @return the value of field 'FeatureSettings'.
281 public jalview.binding.FeatureSettings getFeatureSettings()
283 return this._featureSettings;
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
294 public jalview.binding.JGroup getJGroup(final int index)
295 throws java.lang.IndexOutOfBoundsException
297 // check bounds for index
298 if (index < 0 || index >= this._JGroupList.size())
300 throw new IndexOutOfBoundsException("getJGroup: Index value '"
301 + index + "' not in range [0.."
302 + (this._JGroupList.size() - 1) + "]");
305 return (jalview.binding.JGroup) _JGroupList.get(index);
309 * Method getJGroup.Returns the contents of the collection in an Array.
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.
315 * @return this collection as an Array
317 public jalview.binding.JGroup[] getJGroup()
319 jalview.binding.JGroup[] array = new jalview.binding.JGroup[0];
320 return (jalview.binding.JGroup[]) this._JGroupList.toArray(array);
324 * Method getJGroupCount.
326 * @return the size of this collection
328 public int getJGroupCount()
330 return this._JGroupList.size();
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
341 public jalview.binding.JSeq getJSeq(final int index)
342 throws java.lang.IndexOutOfBoundsException
344 // check bounds for index
345 if (index < 0 || index >= this._JSeqList.size())
347 throw new IndexOutOfBoundsException("getJSeq: Index value '" + index
348 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
351 return (jalview.binding.JSeq) _JSeqList.get(index);
355 * Method getJSeq.Returns the contents of the collection in an Array.
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.
361 * @return this collection as an Array
363 public jalview.binding.JSeq[] getJSeq()
365 jalview.binding.JSeq[] array = new jalview.binding.JSeq[0];
366 return (jalview.binding.JSeq[]) this._JSeqList.toArray(array);
370 * Method getJSeqCount.
372 * @return the size of this collection
374 public int getJSeqCount()
376 return this._JSeqList.size();
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
387 public jalview.binding.Tree getTree(final int index)
388 throws java.lang.IndexOutOfBoundsException
390 // check bounds for index
391 if (index < 0 || index >= this._treeList.size())
393 throw new IndexOutOfBoundsException("getTree: Index value '" + index
394 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
397 return (jalview.binding.Tree) _treeList.get(index);
401 * Method getTree.Returns the contents of the collection in an Array.
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.
407 * @return this collection as an Array
409 public jalview.binding.Tree[] getTree()
411 jalview.binding.Tree[] array = new jalview.binding.Tree[0];
412 return (jalview.binding.Tree[]) this._treeList.toArray(array);
416 * Method getTreeCount.
418 * @return the size of this collection
420 public int getTreeCount()
422 return this._treeList.size();
426 * Method getUserColours.
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
433 public jalview.binding.UserColours getUserColours(final int index)
434 throws java.lang.IndexOutOfBoundsException
436 // check bounds for index
437 if (index < 0 || index >= this._userColoursList.size())
439 throw new IndexOutOfBoundsException("getUserColours: Index value '"
440 + index + "' not in range [0.."
441 + (this._userColoursList.size() - 1) + "]");
444 return (jalview.binding.UserColours) _userColoursList.get(index);
448 * Method getUserColours.Returns the contents of the collection in an Array.
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.
454 * @return this collection as an Array
456 public jalview.binding.UserColours[] getUserColours()
458 jalview.binding.UserColours[] array = new jalview.binding.UserColours[0];
459 return (jalview.binding.UserColours[]) this._userColoursList
464 * Method getUserColoursCount.
466 * @return the size of this collection
468 public int getUserColoursCount()
470 return this._userColoursList.size();
474 * Method getViewport.
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
481 public jalview.binding.Viewport getViewport(final int index)
482 throws java.lang.IndexOutOfBoundsException
484 // check bounds for index
485 if (index < 0 || index >= this._viewportList.size())
487 throw new IndexOutOfBoundsException("getViewport: Index value '"
488 + index + "' not in range [0.."
489 + (this._viewportList.size() - 1) + "]");
492 return (jalview.binding.Viewport) _viewportList.get(index);
496 * Method getViewport.Returns the contents of the collection in an Array.
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.
502 * @return this collection as an Array
504 public jalview.binding.Viewport[] getViewport()
506 jalview.binding.Viewport[] array = new jalview.binding.Viewport[0];
507 return (jalview.binding.Viewport[]) this._viewportList.toArray(array);
511 * Method getViewportCount.
513 * @return the size of this collection
515 public int getViewportCount()
517 return this._viewportList.size();
523 * @return true if this object is valid according to the schema
525 public boolean isValid()
530 } catch (org.exolab.castor.xml.ValidationException vex)
541 * @throws org.exolab.castor.xml.MarshalException
542 * if object is null or if any SAXException is thrown during
544 * @throws org.exolab.castor.xml.ValidationException
545 * if this object is an invalid instance according to the schema
547 public void marshal(final java.io.Writer out)
548 throws org.exolab.castor.xml.MarshalException,
549 org.exolab.castor.xml.ValidationException
551 Marshaller.marshal(this, out);
558 * @throws java.io.IOException
559 * if an IOException occurs during marshaling
560 * @throws org.exolab.castor.xml.ValidationException
561 * if this object is an invalid instance according to the schema
562 * @throws org.exolab.castor.xml.MarshalException
563 * if object is null or if any SAXException is thrown during
566 public void marshal(final org.xml.sax.ContentHandler handler)
567 throws java.io.IOException,
568 org.exolab.castor.xml.MarshalException,
569 org.exolab.castor.xml.ValidationException
571 Marshaller.marshal(this, handler);
576 public void removeAllJGroup()
578 this._JGroupList.clear();
583 public void removeAllJSeq()
585 this._JSeqList.clear();
590 public void removeAllTree()
592 this._treeList.clear();
597 public void removeAllUserColours()
599 this._userColoursList.clear();
604 public void removeAllViewport()
606 this._viewportList.clear();
610 * Method removeJGroup.
613 * @return true if the object was removed from the collection.
615 public boolean removeJGroup(final jalview.binding.JGroup vJGroup)
617 boolean removed = _JGroupList.remove(vJGroup);
622 * Method removeJGroupAt.
625 * @return the element removed from the collection
627 public jalview.binding.JGroup removeJGroupAt(final int index)
629 java.lang.Object obj = this._JGroupList.remove(index);
630 return (jalview.binding.JGroup) obj;
637 * @return true if the object was removed from the collection.
639 public boolean removeJSeq(final jalview.binding.JSeq vJSeq)
641 boolean removed = _JSeqList.remove(vJSeq);
646 * Method removeJSeqAt.
649 * @return the element removed from the collection
651 public jalview.binding.JSeq removeJSeqAt(final int index)
653 java.lang.Object obj = this._JSeqList.remove(index);
654 return (jalview.binding.JSeq) obj;
661 * @return true if the object was removed from the collection.
663 public boolean removeTree(final jalview.binding.Tree vTree)
665 boolean removed = _treeList.remove(vTree);
670 * Method removeTreeAt.
673 * @return the element removed from the collection
675 public jalview.binding.Tree removeTreeAt(final int index)
677 java.lang.Object obj = this._treeList.remove(index);
678 return (jalview.binding.Tree) obj;
682 * Method removeUserColours.
684 * @param vUserColours
685 * @return true if the object was removed from the collection.
687 public boolean removeUserColours(
688 final jalview.binding.UserColours vUserColours)
690 boolean removed = _userColoursList.remove(vUserColours);
695 * Method removeUserColoursAt.
698 * @return the element removed from the collection
700 public jalview.binding.UserColours removeUserColoursAt(final int index)
702 java.lang.Object obj = this._userColoursList.remove(index);
703 return (jalview.binding.UserColours) obj;
707 * Method removeViewport.
710 * @return true if the object was removed from the collection.
712 public boolean removeViewport(final jalview.binding.Viewport vViewport)
714 boolean removed = _viewportList.remove(vViewport);
719 * Method removeViewportAt.
722 * @return the element removed from the collection
724 public jalview.binding.Viewport removeViewportAt(final int index)
726 java.lang.Object obj = this._viewportList.remove(index);
727 return (jalview.binding.Viewport) obj;
731 * Sets the value of field 'featureSettings'.
733 * @param featureSettings
734 * the value of field 'featureSettings'.
736 public void setFeatureSettings(
737 final jalview.binding.FeatureSettings featureSettings)
739 this._featureSettings = featureSettings;
747 * @throws java.lang.IndexOutOfBoundsException
748 * if the index given is outside the bounds of the collection
750 public void setJGroup(final int index,
751 final jalview.binding.JGroup vJGroup)
752 throws java.lang.IndexOutOfBoundsException
754 // check bounds for index
755 if (index < 0 || index >= this._JGroupList.size())
757 throw new IndexOutOfBoundsException("setJGroup: Index value '"
758 + index + "' not in range [0.."
759 + (this._JGroupList.size() - 1) + "]");
762 this._JGroupList.set(index, vJGroup);
768 * @param vJGroupArray
770 public void setJGroup(final jalview.binding.JGroup[] vJGroupArray)
775 for (int i = 0; i < vJGroupArray.length; i++)
777 this._JGroupList.add(vJGroupArray[i]);
786 * @throws java.lang.IndexOutOfBoundsException
787 * if the index given is outside the bounds of the collection
789 public void setJSeq(final int index, final jalview.binding.JSeq vJSeq)
790 throws java.lang.IndexOutOfBoundsException
792 // check bounds for index
793 if (index < 0 || index >= this._JSeqList.size())
795 throw new IndexOutOfBoundsException("setJSeq: Index value '" + index
796 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
799 this._JSeqList.set(index, vJSeq);
807 public void setJSeq(final jalview.binding.JSeq[] vJSeqArray)
812 for (int i = 0; i < vJSeqArray.length; i++)
814 this._JSeqList.add(vJSeqArray[i]);
823 * @throws java.lang.IndexOutOfBoundsException
824 * if the index given is outside the bounds of the collection
826 public void setTree(final int index, final jalview.binding.Tree vTree)
827 throws java.lang.IndexOutOfBoundsException
829 // check bounds for index
830 if (index < 0 || index >= this._treeList.size())
832 throw new IndexOutOfBoundsException("setTree: Index value '" + index
833 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
836 this._treeList.set(index, vTree);
844 public void setTree(final jalview.binding.Tree[] vTreeArray)
849 for (int i = 0; i < vTreeArray.length; i++)
851 this._treeList.add(vTreeArray[i]);
859 * @param vUserColours
860 * @throws java.lang.IndexOutOfBoundsException
861 * if the index given is outside the bounds of the collection
863 public void setUserColours(final int index,
864 final jalview.binding.UserColours vUserColours)
865 throws java.lang.IndexOutOfBoundsException
867 // check bounds for index
868 if (index < 0 || index >= this._userColoursList.size())
870 throw new IndexOutOfBoundsException("setUserColours: Index value '"
871 + index + "' not in range [0.."
872 + (this._userColoursList.size() - 1) + "]");
875 this._userColoursList.set(index, vUserColours);
881 * @param vUserColoursArray
883 public void setUserColours(
884 final jalview.binding.UserColours[] vUserColoursArray)
887 _userColoursList.clear();
889 for (int i = 0; i < vUserColoursArray.length; i++)
891 this._userColoursList.add(vUserColoursArray[i]);
900 * @throws java.lang.IndexOutOfBoundsException
901 * if the index given is outside the bounds of the collection
903 public void setViewport(final int index,
904 final jalview.binding.Viewport vViewport)
905 throws java.lang.IndexOutOfBoundsException
907 // check bounds for index
908 if (index < 0 || index >= this._viewportList.size())
910 throw new IndexOutOfBoundsException("setViewport: Index value '"
911 + index + "' not in range [0.."
912 + (this._viewportList.size() - 1) + "]");
915 this._viewportList.set(index, vViewport);
921 * @param vViewportArray
923 public void setViewport(final jalview.binding.Viewport[] vViewportArray)
926 _viewportList.clear();
928 for (int i = 0; i < vViewportArray.length; i++)
930 this._viewportList.add(vViewportArray[i]);
938 * @throws org.exolab.castor.xml.MarshalException
939 * if object is null or if any SAXException is thrown during
941 * @throws org.exolab.castor.xml.ValidationException
942 * if this object is an invalid instance according to the schema
943 * @return the unmarshaled jalview.binding.JalviewModelSequence
945 public static jalview.binding.JalviewModelSequence unmarshal(
946 final java.io.Reader reader)
947 throws org.exolab.castor.xml.MarshalException,
948 org.exolab.castor.xml.ValidationException
950 return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal(
951 jalview.binding.JalviewModelSequence.class, reader);
957 * @throws org.exolab.castor.xml.ValidationException
958 * if this object is an invalid instance according to the schema
960 public void validate() throws org.exolab.castor.xml.ValidationException
962 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
963 validator.validate(this);