2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 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
29 * Class JalviewUserColours.
\r
31 * @version $Revision$ $Date$
\r
33 public class JalviewUserColours implements java.io.Serializable {
\r
36 //--------------------------/
\r
37 //- Class/Member Variables -/
\r
38 //--------------------------/
\r
41 * Field _schemeName.
\r
43 private java.lang.String _schemeName;
\r
46 * Field _colourList.
\r
48 private java.util.Vector _colourList;
\r
55 public JalviewUserColours() {
\r
57 this._colourList = new java.util.Vector();
\r
69 * @throws java.lang.IndexOutOfBoundsException if the index
\r
70 * given is outside the bounds of the collection
\r
72 public void addColour(
\r
73 final Colour vColour)
\r
74 throws java.lang.IndexOutOfBoundsException {
\r
75 this._colourList.addElement(vColour);
\r
83 * @throws java.lang.IndexOutOfBoundsException if the index
\r
84 * given is outside the bounds of the collection
\r
86 public void addColour(
\r
88 final Colour vColour)
\r
89 throws java.lang.IndexOutOfBoundsException {
\r
90 this._colourList.add(index, vColour);
\r
94 * Method enumerateColour.
\r
96 * @return an Enumeration over all Colour elements
\r
98 public java.util.Enumeration enumerateColour(
\r
100 return this._colourList.elements();
\r
104 * Method getColour.
\r
107 * @throws java.lang.IndexOutOfBoundsException if the index
\r
108 * given is outside the bounds of the collection
\r
109 * @return the value of the Colour at the given index
\r
111 public Colour getColour(
\r
113 throws java.lang.IndexOutOfBoundsException {
\r
114 // check bounds for index
\r
115 if (index < 0 || index >= this._colourList.size()) {
\r
116 throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
\r
119 return (Colour) _colourList.get(index);
\r
123 * Method getColour.Returns the contents of the collection in
\r
124 * an Array. <p>Note: Just in case the collection contents
\r
125 * are changing in another thread, we pass a 0-length Array of
\r
126 * the correct type into the API call. This way we <i>know</i>
\r
127 * that the Array returned is of exactly the correct length.
\r
129 * @return this collection as an Array
\r
131 public Colour[] getColour(
\r
133 Colour[] array = new Colour[0];
\r
134 return (Colour[]) this._colourList.toArray(array);
\r
138 * Method getColourCount.
\r
140 * @return the size of this collection
\r
142 public int getColourCount(
\r
144 return this._colourList.size();
\r
148 * Returns the value of field 'schemeName'.
\r
150 * @return the value of field 'SchemeName'.
\r
152 public java.lang.String getSchemeName(
\r
154 return this._schemeName;
\r
160 * @return true if this object is valid according to the schema
\r
162 public boolean isValid(
\r
166 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
176 * @throws org.exolab.castor.xml.MarshalException if object is
\r
177 * null or if any SAXException is thrown during marshaling
\r
178 * @throws org.exolab.castor.xml.ValidationException if this
\r
179 * object is an invalid instance according to the schema
\r
181 public void marshal(
\r
182 final java.io.Writer out)
\r
183 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
184 Marshaller.marshal(this, out);
\r
191 * @throws java.io.IOException if an IOException occurs during
\r
193 * @throws org.exolab.castor.xml.ValidationException if this
\r
194 * object is an invalid instance according to the schema
\r
195 * @throws org.exolab.castor.xml.MarshalException if object is
\r
196 * null or if any SAXException is thrown during marshaling
\r
198 public void marshal(
\r
199 final org.xml.sax.ContentHandler handler)
\r
200 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
201 Marshaller.marshal(this, handler);
\r
206 public void removeAllColour(
\r
208 this._colourList.clear();
\r
212 * Method removeColour.
\r
215 * @return true if the object was removed from the collection.
\r
217 public boolean removeColour(
\r
218 final Colour vColour) {
\r
219 boolean removed = _colourList.remove(vColour);
\r
224 * Method removeColourAt.
\r
227 * @return the element removed from the collection
\r
229 public Colour removeColourAt(
\r
231 java.lang.Object obj = this._colourList.remove(index);
\r
232 return (Colour) obj;
\r
240 * @throws java.lang.IndexOutOfBoundsException if the index
\r
241 * given is outside the bounds of the collection
\r
243 public void setColour(
\r
245 final Colour vColour)
\r
246 throws java.lang.IndexOutOfBoundsException {
\r
247 // check bounds for index
\r
248 if (index < 0 || index >= this._colourList.size()) {
\r
249 throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
\r
252 this._colourList.set(index, vColour);
\r
258 * @param vColourArray
\r
260 public void setColour(
\r
261 final Colour[] vColourArray) {
\r
263 _colourList.clear();
\r
265 for (int i = 0; i < vColourArray.length; i++) {
\r
266 this._colourList.add(vColourArray[i]);
\r
271 * Sets the value of field 'schemeName'.
\r
273 * @param schemeName the value of field 'schemeName'.
\r
275 public void setSchemeName(
\r
276 final java.lang.String schemeName) {
\r
277 this._schemeName = schemeName;
\r
281 * Method unmarshal.
\r
284 * @throws org.exolab.castor.xml.MarshalException if object is
\r
285 * null or if any SAXException is thrown during marshaling
\r
286 * @throws org.exolab.castor.xml.ValidationException if this
\r
287 * object is an invalid instance according to the schema
\r
288 * @return the unmarshaled
\r
289 * jalview.schemabinding.version2.JalviewUserColours
\r
291 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
\r
292 final java.io.Reader reader)
\r
293 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
294 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller.unmarshal(jalview.schemabinding.version2.JalviewUserColours.class, reader);
\r
300 * @throws org.exolab.castor.xml.ValidationException if this
\r
301 * object is an invalid instance according to the schema
\r
303 public void validate(
\r
305 throws org.exolab.castor.xml.ValidationException {
\r
306 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
307 validator.validate(this);
\r