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
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.
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.
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
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;
75 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();
93 * @throws java.lang.IndexOutOfBoundsException if the index
94 * given is outside the bounds of the collection
96 public void addJGroup(
97 final jalview.binding.JGroup vJGroup)
98 throws java.lang.IndexOutOfBoundsException {
99 this._JGroupList.addElement(vJGroup);
107 * @throws java.lang.IndexOutOfBoundsException if the index
108 * given is outside the bounds of the collection
110 public void addJGroup(
112 final jalview.binding.JGroup vJGroup)
113 throws java.lang.IndexOutOfBoundsException {
114 this._JGroupList.add(index, vJGroup);
121 * @throws java.lang.IndexOutOfBoundsException if the index
122 * given is outside the bounds of the collection
125 final jalview.binding.JSeq vJSeq)
126 throws java.lang.IndexOutOfBoundsException {
127 this._JSeqList.addElement(vJSeq);
135 * @throws java.lang.IndexOutOfBoundsException if the index
136 * given is outside the bounds of the collection
140 final jalview.binding.JSeq vJSeq)
141 throws java.lang.IndexOutOfBoundsException {
142 this._JSeqList.add(index, vJSeq);
149 * @throws java.lang.IndexOutOfBoundsException if the index
150 * given is outside the bounds of the collection
153 final jalview.binding.Tree vTree)
154 throws java.lang.IndexOutOfBoundsException {
155 this._treeList.addElement(vTree);
163 * @throws java.lang.IndexOutOfBoundsException if the index
164 * given is outside the bounds of the collection
168 final jalview.binding.Tree vTree)
169 throws java.lang.IndexOutOfBoundsException {
170 this._treeList.add(index, vTree);
176 * @param vUserColours
177 * @throws java.lang.IndexOutOfBoundsException if the index
178 * given is outside the bounds of the collection
180 public void addUserColours(
181 final jalview.binding.UserColours vUserColours)
182 throws java.lang.IndexOutOfBoundsException {
183 this._userColoursList.addElement(vUserColours);
190 * @param vUserColours
191 * @throws java.lang.IndexOutOfBoundsException if the index
192 * given is outside the bounds of the collection
194 public void addUserColours(
196 final jalview.binding.UserColours vUserColours)
197 throws java.lang.IndexOutOfBoundsException {
198 this._userColoursList.add(index, vUserColours);
205 * @throws java.lang.IndexOutOfBoundsException if the index
206 * given is outside the bounds of the collection
208 public void addViewport(
209 final jalview.binding.Viewport vViewport)
210 throws java.lang.IndexOutOfBoundsException {
211 this._viewportList.addElement(vViewport);
219 * @throws java.lang.IndexOutOfBoundsException if the index
220 * given is outside the bounds of the collection
222 public void addViewport(
224 final jalview.binding.Viewport vViewport)
225 throws java.lang.IndexOutOfBoundsException {
226 this._viewportList.add(index, vViewport);
230 * Method enumerateJGroup.
232 * @return an Enumeration over all jalview.binding.JGroup
235 public java.util.Enumeration enumerateJGroup(
237 return this._JGroupList.elements();
241 * Method enumerateJSeq.
243 * @return an Enumeration over all jalview.binding.JSeq elements
245 public java.util.Enumeration enumerateJSeq(
247 return this._JSeqList.elements();
251 * Method enumerateTree.
253 * @return an Enumeration over all jalview.binding.Tree elements
255 public java.util.Enumeration enumerateTree(
257 return this._treeList.elements();
261 * Method enumerateUserColours.
263 * @return an Enumeration over all jalview.binding.UserColours
266 public java.util.Enumeration enumerateUserColours(
268 return this._userColoursList.elements();
272 * Method enumerateViewport.
274 * @return an Enumeration over all jalview.binding.Viewport
277 public java.util.Enumeration enumerateViewport(
279 return this._viewportList.elements();
283 * Returns the value of field 'featureSettings'.
285 * @return the value of field 'FeatureSettings'.
287 public jalview.binding.FeatureSettings getFeatureSettings(
289 return this._featureSettings;
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
301 public jalview.binding.JGroup getJGroup(
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) + "]");
309 return (jalview.binding.JGroup) _JGroupList.get(index);
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.
319 * @return this collection as an Array
321 public jalview.binding.JGroup[] getJGroup(
323 jalview.binding.JGroup[] array = new jalview.binding.JGroup[0];
324 return (jalview.binding.JGroup[]) this._JGroupList.toArray(array);
328 * Method getJGroupCount.
330 * @return the size of this collection
332 public int getJGroupCount(
334 return this._JGroupList.size();
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
346 public jalview.binding.JSeq getJSeq(
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) + "]");
354 return (jalview.binding.JSeq) _JSeqList.get(index);
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.
364 * @return this collection as an Array
366 public jalview.binding.JSeq[] getJSeq(
368 jalview.binding.JSeq[] array = new jalview.binding.JSeq[0];
369 return (jalview.binding.JSeq[]) this._JSeqList.toArray(array);
373 * Method getJSeqCount.
375 * @return the size of this collection
377 public int getJSeqCount(
379 return this._JSeqList.size();
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
391 public jalview.binding.Tree getTree(
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) + "]");
399 return (jalview.binding.Tree) _treeList.get(index);
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.
409 * @return this collection as an Array
411 public jalview.binding.Tree[] getTree(
413 jalview.binding.Tree[] array = new jalview.binding.Tree[0];
414 return (jalview.binding.Tree[]) this._treeList.toArray(array);
418 * Method getTreeCount.
420 * @return the size of this collection
422 public int getTreeCount(
424 return this._treeList.size();
428 * Method getUserColours.
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
436 public jalview.binding.UserColours getUserColours(
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) + "]");
444 return (jalview.binding.UserColours) _userColoursList.get(index);
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.
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.toArray(array);
463 * Method getUserColoursCount.
465 * @return the size of this collection
467 public int getUserColoursCount(
469 return this._userColoursList.size();
473 * Method getViewport.
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
481 public jalview.binding.Viewport getViewport(
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) + "]");
489 return (jalview.binding.Viewport) _viewportList.get(index);
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.
499 * @return this collection as an Array
501 public jalview.binding.Viewport[] getViewport(
503 jalview.binding.Viewport[] array = new jalview.binding.Viewport[0];
504 return (jalview.binding.Viewport[]) this._viewportList.toArray(array);
508 * Method getViewportCount.
510 * @return the size of this collection
512 public int getViewportCount(
514 return this._viewportList.size();
520 * @return true if this object is valid according to the schema
522 public boolean isValid(
526 } catch (org.exolab.castor.xml.ValidationException vex) {
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
542 final java.io.Writer out)
543 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
544 Marshaller.marshal(this, out);
551 * @throws java.io.IOException if an IOException occurs during
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
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);
566 public void removeAllJGroup(
568 this._JGroupList.clear();
573 public void removeAllJSeq(
575 this._JSeqList.clear();
580 public void removeAllTree(
582 this._treeList.clear();
587 public void removeAllUserColours(
589 this._userColoursList.clear();
594 public void removeAllViewport(
596 this._viewportList.clear();
600 * Method removeJGroup.
603 * @return true if the object was removed from the collection.
605 public boolean removeJGroup(
606 final jalview.binding.JGroup vJGroup) {
607 boolean removed = _JGroupList.remove(vJGroup);
612 * Method removeJGroupAt.
615 * @return the element removed from the collection
617 public jalview.binding.JGroup removeJGroupAt(
619 java.lang.Object obj = this._JGroupList.remove(index);
620 return (jalview.binding.JGroup) obj;
627 * @return true if the object was removed from the collection.
629 public boolean removeJSeq(
630 final jalview.binding.JSeq vJSeq) {
631 boolean removed = _JSeqList.remove(vJSeq);
636 * Method removeJSeqAt.
639 * @return the element removed from the collection
641 public jalview.binding.JSeq removeJSeqAt(
643 java.lang.Object obj = this._JSeqList.remove(index);
644 return (jalview.binding.JSeq) obj;
651 * @return true if the object was removed from the collection.
653 public boolean removeTree(
654 final jalview.binding.Tree vTree) {
655 boolean removed = _treeList.remove(vTree);
660 * Method removeTreeAt.
663 * @return the element removed from the collection
665 public jalview.binding.Tree removeTreeAt(
667 java.lang.Object obj = this._treeList.remove(index);
668 return (jalview.binding.Tree) obj;
672 * Method removeUserColours.
674 * @param vUserColours
675 * @return true if the object was removed from the collection.
677 public boolean removeUserColours(
678 final jalview.binding.UserColours vUserColours) {
679 boolean removed = _userColoursList.remove(vUserColours);
684 * Method removeUserColoursAt.
687 * @return the element removed from the collection
689 public jalview.binding.UserColours removeUserColoursAt(
691 java.lang.Object obj = this._userColoursList.remove(index);
692 return (jalview.binding.UserColours) obj;
696 * Method removeViewport.
699 * @return true if the object was removed from the collection.
701 public boolean removeViewport(
702 final jalview.binding.Viewport vViewport) {
703 boolean removed = _viewportList.remove(vViewport);
708 * Method removeViewportAt.
711 * @return the element removed from the collection
713 public jalview.binding.Viewport removeViewportAt(
715 java.lang.Object obj = this._viewportList.remove(index);
716 return (jalview.binding.Viewport) obj;
720 * Sets the value of field 'featureSettings'.
722 * @param featureSettings the value of field 'featureSettings'.
724 public void setFeatureSettings(
725 final jalview.binding.FeatureSettings featureSettings) {
726 this._featureSettings = featureSettings;
734 * @throws java.lang.IndexOutOfBoundsException if the index
735 * given is outside the bounds of the collection
737 public void setJGroup(
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) + "]");
746 this._JGroupList.set(index, vJGroup);
752 * @param vJGroupArray
754 public void setJGroup(
755 final jalview.binding.JGroup[] vJGroupArray) {
759 for (int i = 0; i < vJGroupArray.length; i++) {
760 this._JGroupList.add(vJGroupArray[i]);
769 * @throws java.lang.IndexOutOfBoundsException if the index
770 * given is outside the bounds of the collection
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) + "]");
781 this._JSeqList.set(index, vJSeq);
790 final jalview.binding.JSeq[] vJSeqArray) {
794 for (int i = 0; i < vJSeqArray.length; i++) {
795 this._JSeqList.add(vJSeqArray[i]);
804 * @throws java.lang.IndexOutOfBoundsException if the index
805 * given is outside the bounds of the collection
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) + "]");
816 this._treeList.set(index, vTree);
825 final jalview.binding.Tree[] vTreeArray) {
829 for (int i = 0; i < vTreeArray.length; i++) {
830 this._treeList.add(vTreeArray[i]);
838 * @param vUserColours
839 * @throws java.lang.IndexOutOfBoundsException if the index
840 * given is outside the bounds of the collection
842 public void setUserColours(
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) + "]");
851 this._userColoursList.set(index, vUserColours);
857 * @param vUserColoursArray
859 public void setUserColours(
860 final jalview.binding.UserColours[] vUserColoursArray) {
862 _userColoursList.clear();
864 for (int i = 0; i < vUserColoursArray.length; i++) {
865 this._userColoursList.add(vUserColoursArray[i]);
874 * @throws java.lang.IndexOutOfBoundsException if the index
875 * given is outside the bounds of the collection
877 public void setViewport(
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) + "]");
886 this._viewportList.set(index, vViewport);
892 * @param vViewportArray
894 public void setViewport(
895 final jalview.binding.Viewport[] vViewportArray) {
897 _viewportList.clear();
899 for (int i = 0; i < vViewportArray.length; i++) {
900 this._viewportList.add(vViewportArray[i]);
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
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);
923 * @throws org.exolab.castor.xml.ValidationException if this
924 * object is an invalid instance according to the schema
926 public void validate(
928 throws org.exolab.castor.xml.ValidationException {
929 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
930 validator.validate(this);