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;
31 * @version $Revision$ $Date$
33 public class JGroup implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
46 * keeps track of state for field: _start
48 private boolean _has_start;
56 * keeps track of state for field: _end
58 private boolean _has_end;
63 private java.lang.String _name;
68 private java.lang.String _colour;
71 * Field _consThreshold.
73 private int _consThreshold;
76 * keeps track of state for field: _consThreshold
78 private boolean _has_consThreshold;
81 * Field _pidThreshold.
83 private int _pidThreshold;
86 * keeps track of state for field: _pidThreshold
88 private boolean _has_pidThreshold;
91 * Field _outlineColour.
93 private int _outlineColour;
96 * keeps track of state for field: _outlineColour
98 private boolean _has_outlineColour;
101 * Field _displayBoxes.
103 private boolean _displayBoxes;
106 * keeps track of state for field: _displayBoxes
108 private boolean _has_displayBoxes;
111 * Field _displayText.
113 private boolean _displayText;
116 * keeps track of state for field: _displayText
118 private boolean _has_displayText;
123 private boolean _colourText;
126 * keeps track of state for field: _colourText
128 private boolean _has_colourText;
133 private java.util.Vector _seqList;
142 this._seqList = new java.util.Vector();
153 * @throws java.lang.IndexOutOfBoundsException
154 * if the index given is outside the bounds of the collection
156 public void addSeq(final int vSeq)
157 throws java.lang.IndexOutOfBoundsException
159 this._seqList.addElement(new java.lang.Integer(vSeq));
167 * @throws java.lang.IndexOutOfBoundsException
168 * if the index given is outside the bounds of the collection
170 public void addSeq(final int index, final int vSeq)
171 throws java.lang.IndexOutOfBoundsException
173 this._seqList.add(index, new java.lang.Integer(vSeq));
178 public void deleteColourText()
180 this._has_colourText = false;
185 public void deleteConsThreshold()
187 this._has_consThreshold = false;
192 public void deleteDisplayBoxes()
194 this._has_displayBoxes = false;
199 public void deleteDisplayText()
201 this._has_displayText = false;
206 public void deleteEnd()
208 this._has_end = false;
213 public void deleteOutlineColour()
215 this._has_outlineColour = false;
220 public void deletePidThreshold()
222 this._has_pidThreshold = false;
227 public void deleteStart()
229 this._has_start = false;
233 * Method enumerateSeq.
235 * @return an Enumeration over all int elements
237 public java.util.Enumeration enumerateSeq()
239 return this._seqList.elements();
243 * Returns the value of field 'colour'.
245 * @return the value of field 'Colour'.
247 public java.lang.String getColour()
253 * Returns the value of field 'colourText'.
255 * @return the value of field 'ColourText'.
257 public boolean getColourText()
259 return this._colourText;
263 * Returns the value of field 'consThreshold'.
265 * @return the value of field 'ConsThreshold'.
267 public int getConsThreshold()
269 return this._consThreshold;
273 * Returns the value of field 'displayBoxes'.
275 * @return the value of field 'DisplayBoxes'.
277 public boolean getDisplayBoxes()
279 return this._displayBoxes;
283 * Returns the value of field 'displayText'.
285 * @return the value of field 'DisplayText'.
287 public boolean getDisplayText()
289 return this._displayText;
293 * Returns the value of field 'end'.
295 * @return the value of field 'End'.
303 * Returns the value of field 'name'.
305 * @return the value of field 'Name'.
307 public java.lang.String getName()
313 * Returns the value of field 'outlineColour'.
315 * @return the value of field 'OutlineColour'.
317 public int getOutlineColour()
319 return this._outlineColour;
323 * Returns the value of field 'pidThreshold'.
325 * @return the value of field 'PidThreshold'.
327 public int getPidThreshold()
329 return this._pidThreshold;
336 * @throws java.lang.IndexOutOfBoundsException
337 * if the index given is outside the bounds of the collection
338 * @return the value of the int at the given index
340 public int getSeq(final int index)
341 throws java.lang.IndexOutOfBoundsException
343 // check bounds for index
344 if (index < 0 || index >= this._seqList.size())
346 throw new IndexOutOfBoundsException("getSeq: Index value '" + index
347 + "' not in range [0.." + (this._seqList.size() - 1) + "]");
350 return ((java.lang.Integer) _seqList.get(index)).intValue();
354 * Method getSeq.Returns the contents of the collection in an Array.
356 * @return this collection as an Array
358 public int[] getSeq()
360 int size = this._seqList.size();
361 int[] array = new int[size];
362 java.util.Iterator iter = _seqList.iterator();
363 for (int index = 0; index < size; index++)
365 array[index] = ((java.lang.Integer) iter.next()).intValue();
371 * Method getSeqCount.
373 * @return the size of this collection
375 public int getSeqCount()
377 return this._seqList.size();
381 * Returns the value of field 'start'.
383 * @return the value of field 'Start'.
385 public int getStart()
391 * Method hasColourText.
393 * @return true if at least one ColourText has been added
395 public boolean hasColourText()
397 return this._has_colourText;
401 * Method hasConsThreshold.
403 * @return true if at least one ConsThreshold has been added
405 public boolean hasConsThreshold()
407 return this._has_consThreshold;
411 * Method hasDisplayBoxes.
413 * @return true if at least one DisplayBoxes has been added
415 public boolean hasDisplayBoxes()
417 return this._has_displayBoxes;
421 * Method hasDisplayText.
423 * @return true if at least one DisplayText has been added
425 public boolean hasDisplayText()
427 return this._has_displayText;
433 * @return true if at least one End has been added
435 public boolean hasEnd()
437 return this._has_end;
441 * Method hasOutlineColour.
443 * @return true if at least one OutlineColour has been added
445 public boolean hasOutlineColour()
447 return this._has_outlineColour;
451 * Method hasPidThreshold.
453 * @return true if at least one PidThreshold has been added
455 public boolean hasPidThreshold()
457 return this._has_pidThreshold;
463 * @return true if at least one Start has been added
465 public boolean hasStart()
467 return this._has_start;
471 * Returns the value of field 'colourText'.
473 * @return the value of field 'ColourText'.
475 public boolean isColourText()
477 return this._colourText;
481 * Returns the value of field 'displayBoxes'.
483 * @return the value of field 'DisplayBoxes'.
485 public boolean isDisplayBoxes()
487 return this._displayBoxes;
491 * Returns the value of field 'displayText'.
493 * @return the value of field 'DisplayText'.
495 public boolean isDisplayText()
497 return this._displayText;
503 * @return true if this object is valid according to the schema
505 public boolean isValid()
510 } catch (org.exolab.castor.xml.ValidationException vex)
521 * @throws org.exolab.castor.xml.MarshalException
522 * if object is null or if any SAXException is thrown during
524 * @throws org.exolab.castor.xml.ValidationException
525 * if this object is an invalid instance according to the
528 public void marshal(final java.io.Writer out)
529 throws org.exolab.castor.xml.MarshalException,
530 org.exolab.castor.xml.ValidationException
532 Marshaller.marshal(this, out);
539 * @throws java.io.IOException
540 * if an IOException occurs during marshaling
541 * @throws org.exolab.castor.xml.ValidationException
542 * if this object is an invalid instance according to the
544 * @throws org.exolab.castor.xml.MarshalException
545 * if object is null or if any SAXException is thrown during
548 public void marshal(final org.xml.sax.ContentHandler handler)
549 throws java.io.IOException,
550 org.exolab.castor.xml.MarshalException,
551 org.exolab.castor.xml.ValidationException
553 Marshaller.marshal(this, handler);
558 public void removeAllSeq()
560 this._seqList.clear();
567 * @return true if the object was removed from the collection.
569 public boolean removeSeq(final int vSeq)
571 boolean removed = _seqList.remove(new java.lang.Integer(vSeq));
576 * Method removeSeqAt.
579 * @return the element removed from the collection
581 public int removeSeqAt(final int index)
583 java.lang.Object obj = this._seqList.remove(index);
584 return ((java.lang.Integer) obj).intValue();
588 * Sets the value of field 'colour'.
591 * the value of field 'colour'.
593 public void setColour(final java.lang.String colour)
595 this._colour = colour;
599 * Sets the value of field 'colourText'.
602 * the value of field 'colourText'.
604 public void setColourText(final boolean colourText)
606 this._colourText = colourText;
607 this._has_colourText = true;
611 * Sets the value of field 'consThreshold'.
613 * @param consThreshold
614 * the value of field 'consThreshold'.
616 public void setConsThreshold(final int consThreshold)
618 this._consThreshold = consThreshold;
619 this._has_consThreshold = true;
623 * Sets the value of field 'displayBoxes'.
625 * @param displayBoxes
626 * the value of field 'displayBoxes'.
628 public void setDisplayBoxes(final boolean displayBoxes)
630 this._displayBoxes = displayBoxes;
631 this._has_displayBoxes = true;
635 * Sets the value of field 'displayText'.
638 * the value of field 'displayText'.
640 public void setDisplayText(final boolean displayText)
642 this._displayText = displayText;
643 this._has_displayText = true;
647 * Sets the value of field 'end'.
650 * the value of field 'end'.
652 public void setEnd(final int end)
655 this._has_end = true;
659 * Sets the value of field 'name'.
662 * the value of field 'name'.
664 public void setName(final java.lang.String name)
670 * Sets the value of field 'outlineColour'.
672 * @param outlineColour
673 * the value of field 'outlineColour'.
675 public void setOutlineColour(final int outlineColour)
677 this._outlineColour = outlineColour;
678 this._has_outlineColour = true;
682 * Sets the value of field 'pidThreshold'.
684 * @param pidThreshold
685 * the value of field 'pidThreshold'.
687 public void setPidThreshold(final int pidThreshold)
689 this._pidThreshold = pidThreshold;
690 this._has_pidThreshold = true;
698 * @throws java.lang.IndexOutOfBoundsException
699 * if the index given is outside the bounds of the collection
701 public void setSeq(final int index, final int vSeq)
702 throws java.lang.IndexOutOfBoundsException
704 // check bounds for index
705 if (index < 0 || index >= this._seqList.size())
707 throw new IndexOutOfBoundsException("setSeq: Index value '" + index
708 + "' not in range [0.." + (this._seqList.size() - 1) + "]");
711 this._seqList.set(index, new java.lang.Integer(vSeq));
719 public void setSeq(final int[] vSeqArray)
724 for (int i = 0; i < vSeqArray.length; i++)
726 this._seqList.add(new java.lang.Integer(vSeqArray[i]));
731 * Sets the value of field 'start'.
734 * the value of field 'start'.
736 public void setStart(final int start)
739 this._has_start = true;
746 * @throws org.exolab.castor.xml.MarshalException
747 * if object is null or if any SAXException is thrown during
749 * @throws org.exolab.castor.xml.ValidationException
750 * if this object is an invalid instance according to the
752 * @return the unmarshaled jalview.binding.JGroup
754 public static jalview.binding.JGroup unmarshal(final java.io.Reader reader)
755 throws org.exolab.castor.xml.MarshalException,
756 org.exolab.castor.xml.ValidationException
758 return (jalview.binding.JGroup) Unmarshaller.unmarshal(
759 jalview.binding.JGroup.class, reader);
765 * @throws org.exolab.castor.xml.ValidationException
766 * if this object is an invalid instance according to the
769 public void validate() throws org.exolab.castor.xml.ValidationException
771 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
772 validator.validate(this);