1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************/
19 * This class was automatically generated with
20 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
25 package jalview.schemabinding.version2;
27 //---------------------------------/
28 //- Imported classes and packages -/
29 //---------------------------------/
31 import org.exolab.castor.xml.Marshaller;
32 import org.exolab.castor.xml.Unmarshaller;
35 * Class JalviewUserColours.
37 * @version $Revision$ $Date$
39 public class JalviewUserColours implements java.io.Serializable {
42 //--------------------------/
43 //- Class/Member Variables -/
44 //--------------------------/
49 private java.lang.String _schemeName;
52 * Jalview colour scheme document version.
55 private java.lang.String _version;
60 private java.util.Vector _colourList;
67 public JalviewUserColours() {
69 this._colourList = new java.util.Vector();
81 * @throws java.lang.IndexOutOfBoundsException if the index
82 * given is outside the bounds of the collection
84 public void addColour(
86 throws java.lang.IndexOutOfBoundsException {
87 this._colourList.addElement(vColour);
95 * @throws java.lang.IndexOutOfBoundsException if the index
96 * given is outside the bounds of the collection
98 public void addColour(
100 final Colour vColour)
101 throws java.lang.IndexOutOfBoundsException {
102 this._colourList.add(index, vColour);
106 * Method enumerateColour.
108 * @return an Enumeration over all Colour elements
110 public java.util.Enumeration enumerateColour(
112 return this._colourList.elements();
119 * @throws java.lang.IndexOutOfBoundsException if the index
120 * given is outside the bounds of the collection
121 * @return the value of the Colour at the given index
123 public Colour getColour(
125 throws java.lang.IndexOutOfBoundsException {
126 // check bounds for index
127 if (index < 0 || index >= this._colourList.size()) {
128 throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
131 return (Colour) _colourList.get(index);
135 * Method getColour.Returns the contents of the collection in
136 * an Array. <p>Note: Just in case the collection contents
137 * are changing in another thread, we pass a 0-length Array of
138 * the correct type into the API call. This way we <i>know</i>
139 * that the Array returned is of exactly the correct length.
141 * @return this collection as an Array
143 public Colour[] getColour(
145 Colour[] array = new Colour[0];
146 return (Colour[]) this._colourList.toArray(array);
150 * Method getColourCount.
152 * @return the size of this collection
154 public int getColourCount(
156 return this._colourList.size();
160 * Returns the value of field 'schemeName'.
162 * @return the value of field 'SchemeName'.
164 public java.lang.String getSchemeName(
166 return this._schemeName;
170 * Returns the value of field 'version'. The field 'version'
171 * has the following description: Jalview colour scheme
175 * @return the value of field 'Version'.
177 public java.lang.String getVersion(
179 return this._version;
185 * @return true if this object is valid according to the schema
187 public boolean isValid(
191 } catch (org.exolab.castor.xml.ValidationException vex) {
201 * @throws org.exolab.castor.xml.MarshalException if object is
202 * null or if any SAXException is thrown during marshaling
203 * @throws org.exolab.castor.xml.ValidationException if this
204 * object is an invalid instance according to the schema
207 final java.io.Writer out)
208 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
209 Marshaller.marshal(this, out);
216 * @throws java.io.IOException if an IOException occurs during
218 * @throws org.exolab.castor.xml.ValidationException if this
219 * object is an invalid instance according to the schema
220 * @throws org.exolab.castor.xml.MarshalException if object is
221 * null or if any SAXException is thrown during marshaling
224 final org.xml.sax.ContentHandler handler)
225 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
226 Marshaller.marshal(this, handler);
231 public void removeAllColour(
233 this._colourList.clear();
237 * Method removeColour.
240 * @return true if the object was removed from the collection.
242 public boolean removeColour(
243 final Colour vColour) {
244 boolean removed = _colourList.remove(vColour);
249 * Method removeColourAt.
252 * @return the element removed from the collection
254 public Colour removeColourAt(
256 java.lang.Object obj = this._colourList.remove(index);
265 * @throws java.lang.IndexOutOfBoundsException if the index
266 * given is outside the bounds of the collection
268 public void setColour(
270 final Colour vColour)
271 throws java.lang.IndexOutOfBoundsException {
272 // check bounds for index
273 if (index < 0 || index >= this._colourList.size()) {
274 throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
277 this._colourList.set(index, vColour);
283 * @param vColourArray
285 public void setColour(
286 final Colour[] vColourArray) {
290 for (int i = 0; i < vColourArray.length; i++) {
291 this._colourList.add(vColourArray[i]);
296 * Sets the value of field 'schemeName'.
298 * @param schemeName the value of field 'schemeName'.
300 public void setSchemeName(
301 final java.lang.String schemeName) {
302 this._schemeName = schemeName;
306 * Sets the value of field 'version'. The field 'version' has
307 * the following description: Jalview colour scheme document
311 * @param version the value of field 'version'.
313 public void setVersion(
314 final java.lang.String version) {
315 this._version = version;
322 * @throws org.exolab.castor.xml.MarshalException if object is
323 * null or if any SAXException is thrown during marshaling
324 * @throws org.exolab.castor.xml.ValidationException if this
325 * object is an invalid instance according to the schema
326 * @return the unmarshaled
327 * jalview.schemabinding.version2.JalviewUserColours
329 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
330 final java.io.Reader reader)
331 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
332 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller.unmarshal(jalview.schemabinding.version2.JalviewUserColours.class, reader);
338 * @throws org.exolab.castor.xml.ValidationException if this
339 * object is an invalid instance according to the schema
341 public void validate(
343 throws org.exolab.castor.xml.ValidationException {
344 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
345 validator.validate(this);