2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.binding;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
29 * Class JalviewUserColours.
31 * @version $Revision$ $Date$
33 public class JalviewUserColours implements java.io.Serializable {
36 //--------------------------/
37 //- Class/Member Variables -/
38 //--------------------------/
43 private java.lang.String _schemeName;
48 private java.util.Vector _colourList;
55 public JalviewUserColours() {
57 this._colourList = new java.util.Vector();
69 * @throws java.lang.IndexOutOfBoundsException if the index
70 * given is outside the bounds of the collection
72 public void addColour(
74 throws java.lang.IndexOutOfBoundsException {
75 this._colourList.addElement(vColour);
83 * @throws java.lang.IndexOutOfBoundsException if the index
84 * given is outside the bounds of the collection
86 public void addColour(
89 throws java.lang.IndexOutOfBoundsException {
90 this._colourList.add(index, vColour);
94 * Method enumerateColour.
96 * @return an Enumeration over all Colour elements
98 public java.util.Enumeration enumerateColour(
100 return this._colourList.elements();
107 * @throws java.lang.IndexOutOfBoundsException if the index
108 * given is outside the bounds of the collection
109 * @return the value of the Colour at the given index
111 public Colour getColour(
113 throws java.lang.IndexOutOfBoundsException {
114 // check bounds for index
115 if (index < 0 || index >= this._colourList.size()) {
116 throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
119 return (Colour) _colourList.get(index);
123 * Method getColour.Returns the contents of the collection in
124 * an Array. <p>Note: Just in case the collection contents
125 * are changing in another thread, we pass a 0-length Array of
126 * the correct type into the API call. This way we <i>know</i>
127 * that the Array returned is of exactly the correct length.
129 * @return this collection as an Array
131 public Colour[] getColour(
133 Colour[] array = new Colour[0];
134 return (Colour[]) this._colourList.toArray(array);
138 * Method getColourCount.
140 * @return the size of this collection
142 public int getColourCount(
144 return this._colourList.size();
148 * Returns the value of field 'schemeName'.
150 * @return the value of field 'SchemeName'.
152 public java.lang.String getSchemeName(
154 return this._schemeName;
160 * @return true if this object is valid according to the schema
162 public boolean isValid(
166 } catch (org.exolab.castor.xml.ValidationException vex) {
176 * @throws org.exolab.castor.xml.MarshalException if object is
177 * null or if any SAXException is thrown during marshaling
178 * @throws org.exolab.castor.xml.ValidationException if this
179 * object is an invalid instance according to the schema
182 final java.io.Writer out)
183 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
184 Marshaller.marshal(this, out);
191 * @throws java.io.IOException if an IOException occurs during
193 * @throws org.exolab.castor.xml.ValidationException if this
194 * object is an invalid instance according to the schema
195 * @throws org.exolab.castor.xml.MarshalException if object is
196 * null or if any SAXException is thrown during marshaling
199 final org.xml.sax.ContentHandler handler)
200 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
201 Marshaller.marshal(this, handler);
206 public void removeAllColour(
208 this._colourList.clear();
212 * Method removeColour.
215 * @return true if the object was removed from the collection.
217 public boolean removeColour(
218 final Colour vColour) {
219 boolean removed = _colourList.remove(vColour);
224 * Method removeColourAt.
227 * @return the element removed from the collection
229 public Colour removeColourAt(
231 java.lang.Object obj = this._colourList.remove(index);
240 * @throws java.lang.IndexOutOfBoundsException if the index
241 * given is outside the bounds of the collection
243 public void setColour(
245 final Colour vColour)
246 throws java.lang.IndexOutOfBoundsException {
247 // check bounds for index
248 if (index < 0 || index >= this._colourList.size()) {
249 throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
252 this._colourList.set(index, vColour);
258 * @param vColourArray
260 public void setColour(
261 final Colour[] vColourArray) {
265 for (int i = 0; i < vColourArray.length; i++) {
266 this._colourList.add(vColourArray[i]);
271 * Sets the value of field 'schemeName'.
273 * @param schemeName the value of field 'schemeName'.
275 public void setSchemeName(
276 final java.lang.String schemeName) {
277 this._schemeName = schemeName;
284 * @throws org.exolab.castor.xml.MarshalException if object is
285 * null or if any SAXException is thrown during marshaling
286 * @throws org.exolab.castor.xml.ValidationException if this
287 * object is an invalid instance according to the schema
288 * @return the unmarshaled jalview.binding.JalviewUserColours
290 public static jalview.binding.JalviewUserColours unmarshal(
291 final java.io.Reader reader)
292 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
293 return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader);
299 * @throws org.exolab.castor.xml.ValidationException if this
300 * object is an invalid instance according to the schema
302 public void validate(
304 throws org.exolab.castor.xml.ValidationException {
305 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
306 validator.validate(this);