2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemabinding.version2;
\r
21 // ---------------------------------/
\r
22 // - Imported classes and packages -/
\r
23 // ---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
31 * @version $Revision$ $Date$
\r
33 public class Annotation implements java.io.Serializable
\r
36 // --------------------------/
\r
37 // - Class/Member Variables -/
\r
38 // --------------------------/
\r
43 private boolean _graph;
\r
46 * keeps track of state for field: _graph
\r
48 private boolean _has_graph;
\r
53 private int _graphType;
\r
56 * keeps track of state for field: _graphType
\r
58 private boolean _has_graphType;
\r
61 * Field _sequenceRef.
\r
63 private java.lang.String _sequenceRef;
\r
66 * Field _graphColour.
\r
68 private int _graphColour;
\r
71 * keeps track of state for field: _graphColour
\r
73 private boolean _has_graphColour;
\r
76 * Field _graphGroup.
\r
78 private int _graphGroup;
\r
81 * keeps track of state for field: _graphGroup
\r
83 private boolean _has_graphGroup;
\r
88 private java.lang.String _id;
\r
93 private boolean _scoreOnly = false;
\r
96 * keeps track of state for field: _scoreOnly
\r
98 private boolean _has_scoreOnly;
\r
103 private double _score;
\r
106 * keeps track of state for field: _score
\r
108 private boolean _has_score;
\r
113 private boolean _visible;
\r
116 * keeps track of state for field: _visible
\r
118 private boolean _has_visible;
\r
121 * Field _annotationElementList.
\r
123 private java.util.Vector _annotationElementList;
\r
128 private java.lang.String _label;
\r
131 * Field _description.
\r
133 private java.lang.String _description;
\r
136 * Field _thresholdLine.
\r
138 private jalview.schemabinding.version2.ThresholdLine _thresholdLine;
\r
140 // ----------------/
\r
141 // - Constructors -/
\r
142 // ----------------/
\r
144 public Annotation()
\r
147 this._annotationElementList = new java.util.Vector();
\r
157 * @param vAnnotationElement
\r
158 * @throws java.lang.IndexOutOfBoundsException
\r
159 * if the index given is outside the bounds of the collection
\r
161 public void addAnnotationElement(
\r
162 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
\r
163 throws java.lang.IndexOutOfBoundsException
\r
165 this._annotationElementList.addElement(vAnnotationElement);
\r
172 * @param vAnnotationElement
\r
173 * @throws java.lang.IndexOutOfBoundsException
\r
174 * if the index given is outside the bounds of the collection
\r
176 public void addAnnotationElement(
\r
178 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
\r
179 throws java.lang.IndexOutOfBoundsException
\r
181 this._annotationElementList.add(index, vAnnotationElement);
\r
186 public void deleteGraph()
\r
188 this._has_graph = false;
\r
193 public void deleteGraphColour()
\r
195 this._has_graphColour = false;
\r
200 public void deleteGraphGroup()
\r
202 this._has_graphGroup = false;
\r
207 public void deleteGraphType()
\r
209 this._has_graphType = false;
\r
214 public void deleteScore()
\r
216 this._has_score = false;
\r
221 public void deleteScoreOnly()
\r
223 this._has_scoreOnly = false;
\r
228 public void deleteVisible()
\r
230 this._has_visible = false;
\r
234 * Method enumerateAnnotationElement.
\r
236 * @return an Enumeration over all
\r
237 * jalview.schemabinding.version2.AnnotationElement elements
\r
239 public java.util.Enumeration enumerateAnnotationElement()
\r
241 return this._annotationElementList.elements();
\r
245 * Method getAnnotationElement.
\r
248 * @throws java.lang.IndexOutOfBoundsException
\r
249 * if the index given is outside the bounds of the collection
\r
250 * @return the value of the jalview.schemabinding.version2.AnnotationElement
\r
251 * at the given index
\r
253 public jalview.schemabinding.version2.AnnotationElement getAnnotationElement(
\r
254 final int index) throws java.lang.IndexOutOfBoundsException
\r
256 // check bounds for index
\r
257 if (index < 0 || index >= this._annotationElementList.size())
\r
259 throw new IndexOutOfBoundsException(
\r
260 "getAnnotationElement: Index value '" + index
\r
261 + "' not in range [0.."
\r
262 + (this._annotationElementList.size() - 1) + "]");
\r
265 return (jalview.schemabinding.version2.AnnotationElement) _annotationElementList
\r
270 * Method getAnnotationElement.Returns the contents of the collection in an
\r
273 * Note: Just in case the collection contents are changing in another thread,
\r
274 * we pass a 0-length Array of the correct type into the API call. This way we
\r
275 * <i>know</i> that the Array returned is of exactly the correct length.
\r
277 * @return this collection as an Array
\r
279 public jalview.schemabinding.version2.AnnotationElement[] getAnnotationElement()
\r
281 jalview.schemabinding.version2.AnnotationElement[] array = new jalview.schemabinding.version2.AnnotationElement[0];
\r
282 return (jalview.schemabinding.version2.AnnotationElement[]) this._annotationElementList
\r
287 * Method getAnnotationElementCount.
\r
289 * @return the size of this collection
\r
291 public int getAnnotationElementCount()
\r
293 return this._annotationElementList.size();
\r
297 * Returns the value of field 'description'.
\r
299 * @return the value of field 'Description'.
\r
301 public java.lang.String getDescription()
\r
303 return this._description;
\r
307 * Returns the value of field 'graph'.
\r
309 * @return the value of field 'Graph'.
\r
311 public boolean getGraph()
\r
313 return this._graph;
\r
317 * Returns the value of field 'graphColour'.
\r
319 * @return the value of field 'GraphColour'.
\r
321 public int getGraphColour()
\r
323 return this._graphColour;
\r
327 * Returns the value of field 'graphGroup'.
\r
329 * @return the value of field 'GraphGroup'.
\r
331 public int getGraphGroup()
\r
333 return this._graphGroup;
\r
337 * Returns the value of field 'graphType'.
\r
339 * @return the value of field 'GraphType'.
\r
341 public int getGraphType()
\r
343 return this._graphType;
\r
347 * Returns the value of field 'id'.
\r
349 * @return the value of field 'Id'.
\r
351 public java.lang.String getId()
\r
357 * Returns the value of field 'label'.
\r
359 * @return the value of field 'Label'.
\r
361 public java.lang.String getLabel()
\r
363 return this._label;
\r
367 * Returns the value of field 'score'.
\r
369 * @return the value of field 'Score'.
\r
371 public double getScore()
\r
373 return this._score;
\r
377 * Returns the value of field 'scoreOnly'.
\r
379 * @return the value of field 'ScoreOnly'.
\r
381 public boolean getScoreOnly()
\r
383 return this._scoreOnly;
\r
387 * Returns the value of field 'sequenceRef'.
\r
389 * @return the value of field 'SequenceRef'.
\r
391 public java.lang.String getSequenceRef()
\r
393 return this._sequenceRef;
\r
397 * Returns the value of field 'thresholdLine'.
\r
399 * @return the value of field 'ThresholdLine'.
\r
401 public jalview.schemabinding.version2.ThresholdLine getThresholdLine()
\r
403 return this._thresholdLine;
\r
407 * Returns the value of field 'visible'.
\r
409 * @return the value of field 'Visible'.
\r
411 public boolean getVisible()
\r
413 return this._visible;
\r
419 * @return true if at least one Graph has been added
\r
421 public boolean hasGraph()
\r
423 return this._has_graph;
\r
427 * Method hasGraphColour.
\r
429 * @return true if at least one GraphColour has been added
\r
431 public boolean hasGraphColour()
\r
433 return this._has_graphColour;
\r
437 * Method hasGraphGroup.
\r
439 * @return true if at least one GraphGroup has been added
\r
441 public boolean hasGraphGroup()
\r
443 return this._has_graphGroup;
\r
447 * Method hasGraphType.
\r
449 * @return true if at least one GraphType has been added
\r
451 public boolean hasGraphType()
\r
453 return this._has_graphType;
\r
459 * @return true if at least one Score has been added
\r
461 public boolean hasScore()
\r
463 return this._has_score;
\r
467 * Method hasScoreOnly.
\r
469 * @return true if at least one ScoreOnly has been added
\r
471 public boolean hasScoreOnly()
\r
473 return this._has_scoreOnly;
\r
477 * Method hasVisible.
\r
479 * @return true if at least one Visible has been added
\r
481 public boolean hasVisible()
\r
483 return this._has_visible;
\r
487 * Returns the value of field 'graph'.
\r
489 * @return the value of field 'Graph'.
\r
491 public boolean isGraph()
\r
493 return this._graph;
\r
497 * Returns the value of field 'scoreOnly'.
\r
499 * @return the value of field 'ScoreOnly'.
\r
501 public boolean isScoreOnly()
\r
503 return this._scoreOnly;
\r
509 * @return true if this object is valid according to the schema
\r
511 public boolean isValid()
\r
516 } catch (org.exolab.castor.xml.ValidationException vex)
\r
524 * Returns the value of field 'visible'.
\r
526 * @return the value of field 'Visible'.
\r
528 public boolean isVisible()
\r
530 return this._visible;
\r
537 * @throws org.exolab.castor.xml.MarshalException
\r
538 * if object is null or if any SAXException is thrown during
\r
540 * @throws org.exolab.castor.xml.ValidationException
\r
541 * if this object is an invalid instance according to the
\r
544 public void marshal(final java.io.Writer out)
\r
545 throws org.exolab.castor.xml.MarshalException,
\r
546 org.exolab.castor.xml.ValidationException
\r
548 Marshaller.marshal(this, out);
\r
555 * @throws java.io.IOException
\r
556 * if an IOException occurs during marshaling
\r
557 * @throws org.exolab.castor.xml.ValidationException
\r
558 * if this object is an invalid instance according to the
\r
560 * @throws org.exolab.castor.xml.MarshalException
\r
561 * if object is null or if any SAXException is thrown during
\r
564 public void marshal(final org.xml.sax.ContentHandler handler)
\r
565 throws java.io.IOException,
\r
566 org.exolab.castor.xml.MarshalException,
\r
567 org.exolab.castor.xml.ValidationException
\r
569 Marshaller.marshal(this, handler);
\r
574 public void removeAllAnnotationElement()
\r
576 this._annotationElementList.clear();
\r
580 * Method removeAnnotationElement.
\r
582 * @param vAnnotationElement
\r
583 * @return true if the object was removed from the collection.
\r
585 public boolean removeAnnotationElement(
\r
586 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
\r
588 boolean removed = _annotationElementList.remove(vAnnotationElement);
\r
593 * Method removeAnnotationElementAt.
\r
596 * @return the element removed from the collection
\r
598 public jalview.schemabinding.version2.AnnotationElement removeAnnotationElementAt(
\r
601 java.lang.Object obj = this._annotationElementList.remove(index);
\r
602 return (jalview.schemabinding.version2.AnnotationElement) obj;
\r
609 * @param vAnnotationElement
\r
610 * @throws java.lang.IndexOutOfBoundsException
\r
611 * if the index given is outside the bounds of the collection
\r
613 public void setAnnotationElement(
\r
615 final jalview.schemabinding.version2.AnnotationElement vAnnotationElement)
\r
616 throws java.lang.IndexOutOfBoundsException
\r
618 // check bounds for index
\r
619 if (index < 0 || index >= this._annotationElementList.size())
\r
621 throw new IndexOutOfBoundsException(
\r
622 "setAnnotationElement: Index value '" + index
\r
623 + "' not in range [0.."
\r
624 + (this._annotationElementList.size() - 1) + "]");
\r
627 this._annotationElementList.set(index, vAnnotationElement);
\r
633 * @param vAnnotationElementArray
\r
635 public void setAnnotationElement(
\r
636 final jalview.schemabinding.version2.AnnotationElement[] vAnnotationElementArray)
\r
639 _annotationElementList.clear();
\r
641 for (int i = 0; i < vAnnotationElementArray.length; i++)
\r
643 this._annotationElementList.add(vAnnotationElementArray[i]);
\r
648 * Sets the value of field 'description'.
\r
650 * @param description
\r
651 * the value of field 'description'.
\r
653 public void setDescription(final java.lang.String description)
\r
655 this._description = description;
\r
659 * Sets the value of field 'graph'.
\r
662 * the value of field 'graph'.
\r
664 public void setGraph(final boolean graph)
\r
666 this._graph = graph;
\r
667 this._has_graph = true;
\r
671 * Sets the value of field 'graphColour'.
\r
673 * @param graphColour
\r
674 * the value of field 'graphColour'.
\r
676 public void setGraphColour(final int graphColour)
\r
678 this._graphColour = graphColour;
\r
679 this._has_graphColour = true;
\r
683 * Sets the value of field 'graphGroup'.
\r
685 * @param graphGroup
\r
686 * the value of field 'graphGroup'.
\r
688 public void setGraphGroup(final int graphGroup)
\r
690 this._graphGroup = graphGroup;
\r
691 this._has_graphGroup = true;
\r
695 * Sets the value of field 'graphType'.
\r
698 * the value of field 'graphType'.
\r
700 public void setGraphType(final int graphType)
\r
702 this._graphType = graphType;
\r
703 this._has_graphType = true;
\r
707 * Sets the value of field 'id'.
\r
710 * the value of field 'id'.
\r
712 public void setId(final java.lang.String id)
\r
718 * Sets the value of field 'label'.
\r
721 * the value of field 'label'.
\r
723 public void setLabel(final java.lang.String label)
\r
725 this._label = label;
\r
729 * Sets the value of field 'score'.
\r
732 * the value of field 'score'.
\r
734 public void setScore(final double score)
\r
736 this._score = score;
\r
737 this._has_score = true;
\r
741 * Sets the value of field 'scoreOnly'.
\r
744 * the value of field 'scoreOnly'.
\r
746 public void setScoreOnly(final boolean scoreOnly)
\r
748 this._scoreOnly = scoreOnly;
\r
749 this._has_scoreOnly = true;
\r
753 * Sets the value of field 'sequenceRef'.
\r
755 * @param sequenceRef
\r
756 * the value of field 'sequenceRef'.
\r
758 public void setSequenceRef(final java.lang.String sequenceRef)
\r
760 this._sequenceRef = sequenceRef;
\r
764 * Sets the value of field 'thresholdLine'.
\r
766 * @param thresholdLine
\r
767 * the value of field 'thresholdLine'.
\r
769 public void setThresholdLine(
\r
770 final jalview.schemabinding.version2.ThresholdLine thresholdLine)
\r
772 this._thresholdLine = thresholdLine;
\r
776 * Sets the value of field 'visible'.
\r
779 * the value of field 'visible'.
\r
781 public void setVisible(final boolean visible)
\r
783 this._visible = visible;
\r
784 this._has_visible = true;
\r
788 * Method unmarshal.
\r
791 * @throws org.exolab.castor.xml.MarshalException
\r
792 * if object is null or if any SAXException is thrown during
\r
794 * @throws org.exolab.castor.xml.ValidationException
\r
795 * if this object is an invalid instance according to the
\r
797 * @return the unmarshaled jalview.schemabinding.version2.Annotation
\r
799 public static jalview.schemabinding.version2.Annotation unmarshal(
\r
800 final java.io.Reader reader)
\r
801 throws org.exolab.castor.xml.MarshalException,
\r
802 org.exolab.castor.xml.ValidationException
\r
804 return (jalview.schemabinding.version2.Annotation) Unmarshaller
\r
805 .unmarshal(jalview.schemabinding.version2.Annotation.class,
\r
812 * @throws org.exolab.castor.xml.ValidationException
\r
813 * if this object is an invalid instance according to the
\r
816 public void validate() throws org.exolab.castor.xml.ValidationException
\r
818 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
819 validator.validate(this);
\r