1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $(date) 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.
20 *******************************************************************************/
22 * This class was automatically generated with
23 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
28 package jalview.schemabinding.version2;
30 //---------------------------------/
31 //- Imported classes and packages -/
32 //---------------------------------/
34 import org.exolab.castor.xml.Marshaller;
35 import org.exolab.castor.xml.Unmarshaller;
38 * Class JalviewUserColours.
40 * @version $Revision$ $Date$
42 public class JalviewUserColours implements java.io.Serializable
45 // --------------------------/
46 // - Class/Member Variables -/
47 // --------------------------/
52 private java.lang.String _schemeName;
55 * Jalview colour scheme document version.
58 private java.lang.String _version;
63 private java.util.Vector _colourList;
69 public JalviewUserColours()
72 this._colourList = new java.util.Vector();
83 * @throws java.lang.IndexOutOfBoundsException
84 * if the index given is outside the bounds of the collection
86 public void addColour(final Colour vColour)
87 throws java.lang.IndexOutOfBoundsException
89 this._colourList.addElement(vColour);
97 * @throws java.lang.IndexOutOfBoundsException
98 * if the index given is outside the bounds of the collection
100 public void addColour(final int index, final Colour vColour)
101 throws java.lang.IndexOutOfBoundsException
103 this._colourList.add(index, vColour);
107 * Method enumerateColour.
109 * @return an Enumeration over all Colour elements
111 public java.util.Enumeration enumerateColour()
113 return this._colourList.elements();
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
122 * @return the value of the Colour at the given index
124 public Colour getColour(final int index)
125 throws java.lang.IndexOutOfBoundsException
127 // check bounds for index
128 if (index < 0 || index >= this._colourList.size())
130 throw new IndexOutOfBoundsException("getColour: Index value '"
131 + index + "' not in range [0.."
132 + (this._colourList.size() - 1) + "]");
135 return (Colour) _colourList.get(index);
139 * Method getColour.Returns the contents of the collection in an Array.
141 * Note: Just in case the collection contents are changing in another thread,
142 * we pass a 0-length Array of the correct type into the API call. This way we
143 * <i>know</i> that the Array returned is of exactly the correct length.
145 * @return this collection as an Array
147 public Colour[] getColour()
149 Colour[] array = new Colour[0];
150 return (Colour[]) this._colourList.toArray(array);
154 * Method getColourCount.
156 * @return the size of this collection
158 public int getColourCount()
160 return this._colourList.size();
164 * Returns the value of field 'schemeName'.
166 * @return the value of field 'SchemeName'.
168 public java.lang.String getSchemeName()
170 return this._schemeName;
174 * Returns the value of field 'version'. The field 'version' has the following
175 * description: Jalview colour scheme document version.
178 * @return the value of field 'Version'.
180 public java.lang.String getVersion()
182 return this._version;
188 * @return true if this object is valid according to the schema
190 public boolean isValid()
195 } catch (org.exolab.castor.xml.ValidationException vex)
206 * @throws org.exolab.castor.xml.MarshalException
207 * if object is null or if any SAXException is thrown during
209 * @throws org.exolab.castor.xml.ValidationException
210 * if this object is an invalid instance according to the schema
212 public void marshal(final java.io.Writer out)
213 throws org.exolab.castor.xml.MarshalException,
214 org.exolab.castor.xml.ValidationException
216 Marshaller.marshal(this, out);
223 * @throws java.io.IOException
224 * if an IOException occurs during marshaling
225 * @throws org.exolab.castor.xml.ValidationException
226 * if this object is an invalid instance according to the schema
227 * @throws org.exolab.castor.xml.MarshalException
228 * if object is null or if any SAXException is thrown during
231 public void marshal(final org.xml.sax.ContentHandler handler)
232 throws java.io.IOException,
233 org.exolab.castor.xml.MarshalException,
234 org.exolab.castor.xml.ValidationException
236 Marshaller.marshal(this, handler);
241 public void removeAllColour()
243 this._colourList.clear();
247 * Method removeColour.
250 * @return true if the object was removed from the collection.
252 public boolean removeColour(final Colour vColour)
254 boolean removed = _colourList.remove(vColour);
259 * Method removeColourAt.
262 * @return the element removed from the collection
264 public Colour removeColourAt(final int index)
266 java.lang.Object obj = this._colourList.remove(index);
275 * @throws java.lang.IndexOutOfBoundsException
276 * if the index given is outside the bounds of the collection
278 public void setColour(final int index, final Colour vColour)
279 throws java.lang.IndexOutOfBoundsException
281 // check bounds for index
282 if (index < 0 || index >= this._colourList.size())
284 throw new IndexOutOfBoundsException("setColour: Index value '"
285 + index + "' not in range [0.."
286 + (this._colourList.size() - 1) + "]");
289 this._colourList.set(index, vColour);
295 * @param vColourArray
297 public void setColour(final Colour[] vColourArray)
302 for (int i = 0; i < vColourArray.length; i++)
304 this._colourList.add(vColourArray[i]);
309 * Sets the value of field 'schemeName'.
312 * the value of field 'schemeName'.
314 public void setSchemeName(final java.lang.String schemeName)
316 this._schemeName = schemeName;
320 * Sets the value of field 'version'. The field 'version' has the following
321 * description: Jalview colour scheme document version.
325 * the value of field 'version'.
327 public void setVersion(final java.lang.String version)
329 this._version = version;
336 * @throws org.exolab.castor.xml.MarshalException
337 * if object is null or if any SAXException is thrown during
339 * @throws org.exolab.castor.xml.ValidationException
340 * if this object is an invalid instance according to the schema
341 * @return the unmarshaled jalview.schemabinding.version2.JalviewUserColours
343 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
344 final java.io.Reader reader)
345 throws org.exolab.castor.xml.MarshalException,
346 org.exolab.castor.xml.ValidationException
348 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller
350 jalview.schemabinding.version2.JalviewUserColours.class,
357 * @throws org.exolab.castor.xml.ValidationException
358 * if this object is an invalid instance according to the schema
360 public void validate() throws org.exolab.castor.xml.ValidationException
362 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
363 validator.validate(this);