2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.binding;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class JGroup implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
50 * keeps track of state for field: _start
52 private boolean _has_start;
60 * keeps track of state for field: _end
62 private boolean _has_end;
67 private java.lang.String _name;
72 private java.lang.String _colour;
75 * Field _consThreshold.
77 private int _consThreshold;
80 * keeps track of state for field: _consThreshold
82 private boolean _has_consThreshold;
85 * Field _pidThreshold.
87 private int _pidThreshold;
90 * keeps track of state for field: _pidThreshold
92 private boolean _has_pidThreshold;
95 * Field _outlineColour.
97 private int _outlineColour;
100 * keeps track of state for field: _outlineColour
102 private boolean _has_outlineColour;
105 * Field _displayBoxes.
107 private boolean _displayBoxes;
110 * keeps track of state for field: _displayBoxes
112 private boolean _has_displayBoxes;
115 * Field _displayText.
117 private boolean _displayText;
120 * keeps track of state for field: _displayText
122 private boolean _has_displayText;
127 private boolean _colourText;
130 * keeps track of state for field: _colourText
132 private boolean _has_colourText;
137 private java.util.Vector _seqList;
146 this._seqList = new java.util.Vector();
157 * @throws java.lang.IndexOutOfBoundsException
158 * if the index given is outside the bounds of the collection
160 public void addSeq(final int vSeq)
161 throws java.lang.IndexOutOfBoundsException
163 this._seqList.addElement(new java.lang.Integer(vSeq));
171 * @throws java.lang.IndexOutOfBoundsException
172 * if the index given is outside the bounds of the collection
174 public void addSeq(final int index, final int vSeq)
175 throws java.lang.IndexOutOfBoundsException
177 this._seqList.add(index, new java.lang.Integer(vSeq));
182 public void deleteColourText()
184 this._has_colourText = false;
189 public void deleteConsThreshold()
191 this._has_consThreshold = false;
196 public void deleteDisplayBoxes()
198 this._has_displayBoxes = false;
203 public void deleteDisplayText()
205 this._has_displayText = false;
210 public void deleteEnd()
212 this._has_end = false;
217 public void deleteOutlineColour()
219 this._has_outlineColour = false;
224 public void deletePidThreshold()
226 this._has_pidThreshold = false;
231 public void deleteStart()
233 this._has_start = false;
237 * Method enumerateSeq.
239 * @return an Enumeration over all int elements
241 public java.util.Enumeration enumerateSeq()
243 return this._seqList.elements();
247 * Returns the value of field 'colour'.
249 * @return the value of field 'Colour'.
251 public java.lang.String getColour()
257 * Returns the value of field 'colourText'.
259 * @return the value of field 'ColourText'.
261 public boolean getColourText()
263 return this._colourText;
267 * Returns the value of field 'consThreshold'.
269 * @return the value of field 'ConsThreshold'.
271 public int getConsThreshold()
273 return this._consThreshold;
277 * Returns the value of field 'displayBoxes'.
279 * @return the value of field 'DisplayBoxes'.
281 public boolean getDisplayBoxes()
283 return this._displayBoxes;
287 * Returns the value of field 'displayText'.
289 * @return the value of field 'DisplayText'.
291 public boolean getDisplayText()
293 return this._displayText;
297 * Returns the value of field 'end'.
299 * @return the value of field 'End'.
307 * Returns the value of field 'name'.
309 * @return the value of field 'Name'.
311 public java.lang.String getName()
317 * Returns the value of field 'outlineColour'.
319 * @return the value of field 'OutlineColour'.
321 public int getOutlineColour()
323 return this._outlineColour;
327 * Returns the value of field 'pidThreshold'.
329 * @return the value of field 'PidThreshold'.
331 public int getPidThreshold()
333 return this._pidThreshold;
340 * @throws java.lang.IndexOutOfBoundsException
341 * if the index given is outside the bounds of the collection
342 * @return the value of the int at the given index
344 public int getSeq(final int index)
345 throws java.lang.IndexOutOfBoundsException
347 // check bounds for index
348 if (index < 0 || index >= this._seqList.size())
350 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
352 Integer.valueOf(index).toString(),
353 Integer.valueOf((this._seqList.size() - 1)).toString()
357 return ((java.lang.Integer) _seqList.get(index)).intValue();
361 * Method getSeq.Returns the contents of the collection in an Array.
363 * @return this collection as an Array
365 public int[] getSeq()
367 int size = this._seqList.size();
368 int[] array = new int[size];
369 java.util.Iterator iter = _seqList.iterator();
370 for (int index = 0; index < size; index++)
372 array[index] = ((java.lang.Integer) iter.next()).intValue();
378 * Method getSeqCount.
380 * @return the size of this collection
382 public int getSeqCount()
384 return this._seqList.size();
388 * Returns the value of field 'start'.
390 * @return the value of field 'Start'.
392 public int getStart()
398 * Method hasColourText.
400 * @return true if at least one ColourText has been added
402 public boolean hasColourText()
404 return this._has_colourText;
408 * Method hasConsThreshold.
410 * @return true if at least one ConsThreshold has been added
412 public boolean hasConsThreshold()
414 return this._has_consThreshold;
418 * Method hasDisplayBoxes.
420 * @return true if at least one DisplayBoxes has been added
422 public boolean hasDisplayBoxes()
424 return this._has_displayBoxes;
428 * Method hasDisplayText.
430 * @return true if at least one DisplayText has been added
432 public boolean hasDisplayText()
434 return this._has_displayText;
440 * @return true if at least one End has been added
442 public boolean hasEnd()
444 return this._has_end;
448 * Method hasOutlineColour.
450 * @return true if at least one OutlineColour has been added
452 public boolean hasOutlineColour()
454 return this._has_outlineColour;
458 * Method hasPidThreshold.
460 * @return true if at least one PidThreshold has been added
462 public boolean hasPidThreshold()
464 return this._has_pidThreshold;
470 * @return true if at least one Start has been added
472 public boolean hasStart()
474 return this._has_start;
478 * Returns the value of field 'colourText'.
480 * @return the value of field 'ColourText'.
482 public boolean isColourText()
484 return this._colourText;
488 * Returns the value of field 'displayBoxes'.
490 * @return the value of field 'DisplayBoxes'.
492 public boolean isDisplayBoxes()
494 return this._displayBoxes;
498 * Returns the value of field 'displayText'.
500 * @return the value of field 'DisplayText'.
502 public boolean isDisplayText()
504 return this._displayText;
510 * @return true if this object is valid according to the schema
512 public boolean isValid()
517 } catch (org.exolab.castor.xml.ValidationException vex)
528 * @throws org.exolab.castor.xml.MarshalException
529 * if object is null or if any SAXException is thrown during
531 * @throws org.exolab.castor.xml.ValidationException
532 * if this object is an invalid instance according to the schema
534 public void marshal(final java.io.Writer out)
535 throws org.exolab.castor.xml.MarshalException,
536 org.exolab.castor.xml.ValidationException
538 Marshaller.marshal(this, out);
545 * @throws java.io.IOException
546 * if an IOException occurs during marshaling
547 * @throws org.exolab.castor.xml.ValidationException
548 * if this object is an invalid instance according to the schema
549 * @throws org.exolab.castor.xml.MarshalException
550 * if object is null or if any SAXException is thrown during
553 public void marshal(final org.xml.sax.ContentHandler handler)
554 throws java.io.IOException,
555 org.exolab.castor.xml.MarshalException,
556 org.exolab.castor.xml.ValidationException
558 Marshaller.marshal(this, handler);
563 public void removeAllSeq()
565 this._seqList.clear();
572 * @return true if the object was removed from the collection.
574 public boolean removeSeq(final int vSeq)
576 boolean removed = _seqList.remove(new java.lang.Integer(vSeq));
581 * Method removeSeqAt.
584 * @return the element removed from the collection
586 public int removeSeqAt(final int index)
588 java.lang.Object obj = this._seqList.remove(index);
589 return ((java.lang.Integer) obj).intValue();
593 * Sets the value of field 'colour'.
596 * the value of field 'colour'.
598 public void setColour(final java.lang.String colour)
600 this._colour = colour;
604 * Sets the value of field 'colourText'.
607 * the value of field 'colourText'.
609 public void setColourText(final boolean colourText)
611 this._colourText = colourText;
612 this._has_colourText = true;
616 * Sets the value of field 'consThreshold'.
618 * @param consThreshold
619 * the value of field 'consThreshold'.
621 public void setConsThreshold(final int consThreshold)
623 this._consThreshold = consThreshold;
624 this._has_consThreshold = true;
628 * Sets the value of field 'displayBoxes'.
630 * @param displayBoxes
631 * the value of field 'displayBoxes'.
633 public void setDisplayBoxes(final boolean displayBoxes)
635 this._displayBoxes = displayBoxes;
636 this._has_displayBoxes = true;
640 * Sets the value of field 'displayText'.
643 * the value of field 'displayText'.
645 public void setDisplayText(final boolean displayText)
647 this._displayText = displayText;
648 this._has_displayText = true;
652 * Sets the value of field 'end'.
655 * the value of field 'end'.
657 public void setEnd(final int end)
660 this._has_end = true;
664 * Sets the value of field 'name'.
667 * the value of field 'name'.
669 public void setName(final java.lang.String name)
675 * Sets the value of field 'outlineColour'.
677 * @param outlineColour
678 * the value of field 'outlineColour'.
680 public void setOutlineColour(final int outlineColour)
682 this._outlineColour = outlineColour;
683 this._has_outlineColour = true;
687 * Sets the value of field 'pidThreshold'.
689 * @param pidThreshold
690 * the value of field 'pidThreshold'.
692 public void setPidThreshold(final int pidThreshold)
694 this._pidThreshold = pidThreshold;
695 this._has_pidThreshold = true;
703 * @throws java.lang.IndexOutOfBoundsException
704 * if the index given is outside the bounds of the collection
706 public void setSeq(final int index, final int vSeq)
707 throws java.lang.IndexOutOfBoundsException
709 // check bounds for index
710 if (index < 0 || index >= this._seqList.size())
712 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
714 Integer.valueOf(index).toString(),
715 Integer.valueOf((this._seqList.size() - 1)).toString()
719 this._seqList.set(index, new java.lang.Integer(vSeq));
727 public void setSeq(final int[] vSeqArray)
732 for (int i = 0; i < vSeqArray.length; i++)
734 this._seqList.add(new java.lang.Integer(vSeqArray[i]));
739 * Sets the value of field 'start'.
742 * the value of field 'start'.
744 public void setStart(final int start)
747 this._has_start = true;
754 * @throws org.exolab.castor.xml.MarshalException
755 * if object is null or if any SAXException is thrown during
757 * @throws org.exolab.castor.xml.ValidationException
758 * if this object is an invalid instance according to the schema
759 * @return the unmarshaled jalview.binding.JGroup
761 public static jalview.binding.JGroup unmarshal(final java.io.Reader reader)
762 throws org.exolab.castor.xml.MarshalException,
763 org.exolab.castor.xml.ValidationException
765 return (jalview.binding.JGroup) Unmarshaller.unmarshal(
766 jalview.binding.JGroup.class, reader);
772 * @throws org.exolab.castor.xml.ValidationException
773 * if this object is an invalid instance according to the schema
775 public void validate() throws org.exolab.castor.xml.ValidationException
777 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
778 validator.validate(this);