2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
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 org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class Annotation implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private boolean _graph;
48 * keeps track of state for field: _graph
50 private boolean _has_graph;
55 private int _graphType;
58 * keeps track of state for field: _graphType
60 private boolean _has_graphType;
63 * Field _annotationElementList.
65 private java.util.Vector _annotationElementList;
70 private java.lang.String _label;
75 private java.lang.String _description;
84 this._annotationElementList = new java.util.Vector();
94 * @param vAnnotationElement
95 * @throws java.lang.IndexOutOfBoundsException
96 * if the index given is outside the bounds of the collection
98 public void addAnnotationElement(
99 final jalview.binding.AnnotationElement vAnnotationElement)
100 throws java.lang.IndexOutOfBoundsException
102 this._annotationElementList.addElement(vAnnotationElement);
109 * @param vAnnotationElement
110 * @throws java.lang.IndexOutOfBoundsException
111 * if the index given is outside the bounds of the collection
113 public void addAnnotationElement(final int index,
114 final jalview.binding.AnnotationElement vAnnotationElement)
115 throws java.lang.IndexOutOfBoundsException
117 this._annotationElementList.add(index, vAnnotationElement);
122 public void deleteGraph()
124 this._has_graph = false;
129 public void deleteGraphType()
131 this._has_graphType = false;
135 * Method enumerateAnnotationElement.
137 * @return an Enumeration over all jalview.binding.AnnotationElement elements
139 public java.util.Enumeration enumerateAnnotationElement()
141 return this._annotationElementList.elements();
145 * Method getAnnotationElement.
148 * @throws java.lang.IndexOutOfBoundsException
149 * if the index given is outside the bounds of the collection
150 * @return the value of the jalview.binding.AnnotationElement at the given
153 public jalview.binding.AnnotationElement getAnnotationElement(
154 final int index) throws java.lang.IndexOutOfBoundsException
156 // check bounds for index
157 if (index < 0 || index >= this._annotationElementList.size())
159 throw new IndexOutOfBoundsException(
160 "getAnnotationElement: Index value '" + index
161 + "' not in range [0.."
162 + (this._annotationElementList.size() - 1) + "]");
165 return (jalview.binding.AnnotationElement) _annotationElementList
170 * Method getAnnotationElement.Returns the contents of the collection in an
173 * Note: Just in case the collection contents are changing in another thread,
174 * we pass a 0-length Array of the correct type into the API call. This way we
175 * <i>know</i> that the Array returned is of exactly the correct length.
177 * @return this collection as an Array
179 public jalview.binding.AnnotationElement[] getAnnotationElement()
181 jalview.binding.AnnotationElement[] array = new jalview.binding.AnnotationElement[0];
182 return (jalview.binding.AnnotationElement[]) this._annotationElementList
187 * Method getAnnotationElementCount.
189 * @return the size of this collection
191 public int getAnnotationElementCount()
193 return this._annotationElementList.size();
197 * Returns the value of field 'description'.
199 * @return the value of field 'Description'.
201 public java.lang.String getDescription()
203 return this._description;
207 * Returns the value of field 'graph'.
209 * @return the value of field 'Graph'.
211 public boolean getGraph()
217 * Returns the value of field 'graphType'.
219 * @return the value of field 'GraphType'.
221 public int getGraphType()
223 return this._graphType;
227 * Returns the value of field 'label'.
229 * @return the value of field 'Label'.
231 public java.lang.String getLabel()
239 * @return true if at least one Graph has been added
241 public boolean hasGraph()
243 return this._has_graph;
247 * Method hasGraphType.
249 * @return true if at least one GraphType has been added
251 public boolean hasGraphType()
253 return this._has_graphType;
257 * Returns the value of field 'graph'.
259 * @return the value of field 'Graph'.
261 public boolean isGraph()
269 * @return true if this object is valid according to the schema
271 public boolean isValid()
276 } catch (org.exolab.castor.xml.ValidationException vex)
287 * @throws org.exolab.castor.xml.MarshalException
288 * if object is null or if any SAXException is thrown during
290 * @throws org.exolab.castor.xml.ValidationException
291 * if this object is an invalid instance according to the schema
293 public void marshal(final java.io.Writer out)
294 throws org.exolab.castor.xml.MarshalException,
295 org.exolab.castor.xml.ValidationException
297 Marshaller.marshal(this, out);
304 * @throws java.io.IOException
305 * if an IOException occurs during marshaling
306 * @throws org.exolab.castor.xml.ValidationException
307 * if this object is an invalid instance according to the schema
308 * @throws org.exolab.castor.xml.MarshalException
309 * if object is null or if any SAXException is thrown during
312 public void marshal(final org.xml.sax.ContentHandler handler)
313 throws java.io.IOException,
314 org.exolab.castor.xml.MarshalException,
315 org.exolab.castor.xml.ValidationException
317 Marshaller.marshal(this, handler);
322 public void removeAllAnnotationElement()
324 this._annotationElementList.clear();
328 * Method removeAnnotationElement.
330 * @param vAnnotationElement
331 * @return true if the object was removed from the collection.
333 public boolean removeAnnotationElement(
334 final jalview.binding.AnnotationElement vAnnotationElement)
336 boolean removed = _annotationElementList.remove(vAnnotationElement);
341 * Method removeAnnotationElementAt.
344 * @return the element removed from the collection
346 public jalview.binding.AnnotationElement removeAnnotationElementAt(
349 java.lang.Object obj = this._annotationElementList.remove(index);
350 return (jalview.binding.AnnotationElement) obj;
357 * @param vAnnotationElement
358 * @throws java.lang.IndexOutOfBoundsException
359 * if the index given is outside the bounds of the collection
361 public void setAnnotationElement(final int index,
362 final jalview.binding.AnnotationElement vAnnotationElement)
363 throws java.lang.IndexOutOfBoundsException
365 // check bounds for index
366 if (index < 0 || index >= this._annotationElementList.size())
368 throw new IndexOutOfBoundsException(
369 "setAnnotationElement: Index value '" + index
370 + "' not in range [0.."
371 + (this._annotationElementList.size() - 1) + "]");
374 this._annotationElementList.set(index, vAnnotationElement);
380 * @param vAnnotationElementArray
382 public void setAnnotationElement(
383 final jalview.binding.AnnotationElement[] vAnnotationElementArray)
386 _annotationElementList.clear();
388 for (int i = 0; i < vAnnotationElementArray.length; i++)
390 this._annotationElementList.add(vAnnotationElementArray[i]);
395 * Sets the value of field 'description'.
398 * the value of field 'description'.
400 public void setDescription(final java.lang.String description)
402 this._description = description;
406 * Sets the value of field 'graph'.
409 * the value of field 'graph'.
411 public void setGraph(final boolean graph)
414 this._has_graph = true;
418 * Sets the value of field 'graphType'.
421 * the value of field 'graphType'.
423 public void setGraphType(final int graphType)
425 this._graphType = graphType;
426 this._has_graphType = true;
430 * Sets the value of field 'label'.
433 * the value of field 'label'.
435 public void setLabel(final java.lang.String label)
444 * @throws org.exolab.castor.xml.MarshalException
445 * if object is null or if any SAXException is thrown during
447 * @throws org.exolab.castor.xml.ValidationException
448 * if this object is an invalid instance according to the schema
449 * @return the unmarshaled jalview.binding.Annotation
451 public static jalview.binding.Annotation unmarshal(
452 final java.io.Reader reader)
453 throws org.exolab.castor.xml.MarshalException,
454 org.exolab.castor.xml.ValidationException
456 return (jalview.binding.Annotation) Unmarshaller.unmarshal(
457 jalview.binding.Annotation.class, reader);
463 * @throws org.exolab.castor.xml.ValidationException
464 * if this object is an invalid instance according to the schema
466 public void validate() throws org.exolab.castor.xml.ValidationException
468 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
469 validator.validate(this);