2 * Jalview - A Sequence Alignment Editor and Viewer (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 * Jalview colour scheme document version.
\r
49 private java.lang.String _version;
\r
52 * Field _colourList.
\r
54 private java.util.Vector _colourList;
\r
61 public JalviewUserColours() {
\r
63 this._colourList = new java.util.Vector();
\r
75 * @throws java.lang.IndexOutOfBoundsException if the index
\r
76 * given is outside the bounds of the collection
\r
78 public void addColour(
\r
79 final Colour vColour)
\r
80 throws java.lang.IndexOutOfBoundsException {
\r
81 this._colourList.addElement(vColour);
\r
89 * @throws java.lang.IndexOutOfBoundsException if the index
\r
90 * given is outside the bounds of the collection
\r
92 public void addColour(
\r
94 final Colour vColour)
\r
95 throws java.lang.IndexOutOfBoundsException {
\r
96 this._colourList.add(index, vColour);
\r
100 * Method enumerateColour.
\r
102 * @return an Enumeration over all Colour elements
\r
104 public java.util.Enumeration enumerateColour(
\r
106 return this._colourList.elements();
\r
110 * Method getColour.
\r
113 * @throws java.lang.IndexOutOfBoundsException if the index
\r
114 * given is outside the bounds of the collection
\r
115 * @return the value of the Colour at the given index
\r
117 public Colour getColour(
\r
119 throws java.lang.IndexOutOfBoundsException {
\r
120 // check bounds for index
\r
121 if (index < 0 || index >= this._colourList.size()) {
\r
122 throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
\r
125 return (Colour) _colourList.get(index);
\r
129 * Method getColour.Returns the contents of the collection in
\r
130 * an Array. <p>Note: Just in case the collection contents
\r
131 * are changing in another thread, we pass a 0-length Array of
\r
132 * the correct type into the API call. This way we <i>know</i>
\r
133 * that the Array returned is of exactly the correct length.
\r
135 * @return this collection as an Array
\r
137 public Colour[] getColour(
\r
139 Colour[] array = new Colour[0];
\r
140 return (Colour[]) this._colourList.toArray(array);
\r
144 * Method getColourCount.
\r
146 * @return the size of this collection
\r
148 public int getColourCount(
\r
150 return this._colourList.size();
\r
154 * Returns the value of field 'schemeName'.
\r
156 * @return the value of field 'SchemeName'.
\r
158 public java.lang.String getSchemeName(
\r
160 return this._schemeName;
\r
164 * Returns the value of field 'version'. The field 'version'
\r
165 * has the following description: Jalview colour scheme
\r
166 * document version.
\r
169 * @return the value of field 'Version'.
\r
171 public java.lang.String getVersion(
\r
173 return this._version;
\r
179 * @return true if this object is valid according to the schema
\r
181 public boolean isValid(
\r
185 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
195 * @throws org.exolab.castor.xml.MarshalException if object is
\r
196 * null or if any SAXException is thrown during marshaling
\r
197 * @throws org.exolab.castor.xml.ValidationException if this
\r
198 * object is an invalid instance according to the schema
\r
200 public void marshal(
\r
201 final java.io.Writer out)
\r
202 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
203 Marshaller.marshal(this, out);
\r
210 * @throws java.io.IOException if an IOException occurs during
\r
212 * @throws org.exolab.castor.xml.ValidationException if this
\r
213 * object is an invalid instance according to the schema
\r
214 * @throws org.exolab.castor.xml.MarshalException if object is
\r
215 * null or if any SAXException is thrown during marshaling
\r
217 public void marshal(
\r
218 final org.xml.sax.ContentHandler handler)
\r
219 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
220 Marshaller.marshal(this, handler);
\r
225 public void removeAllColour(
\r
227 this._colourList.clear();
\r
231 * Method removeColour.
\r
234 * @return true if the object was removed from the collection.
\r
236 public boolean removeColour(
\r
237 final Colour vColour) {
\r
238 boolean removed = _colourList.remove(vColour);
\r
243 * Method removeColourAt.
\r
246 * @return the element removed from the collection
\r
248 public Colour removeColourAt(
\r
250 java.lang.Object obj = this._colourList.remove(index);
\r
251 return (Colour) obj;
\r
259 * @throws java.lang.IndexOutOfBoundsException if the index
\r
260 * given is outside the bounds of the collection
\r
262 public void setColour(
\r
264 final Colour vColour)
\r
265 throws java.lang.IndexOutOfBoundsException {
\r
266 // check bounds for index
\r
267 if (index < 0 || index >= this._colourList.size()) {
\r
268 throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
\r
271 this._colourList.set(index, vColour);
\r
277 * @param vColourArray
\r
279 public void setColour(
\r
280 final Colour[] vColourArray) {
\r
282 _colourList.clear();
\r
284 for (int i = 0; i < vColourArray.length; i++) {
\r
285 this._colourList.add(vColourArray[i]);
\r
290 * Sets the value of field 'schemeName'.
\r
292 * @param schemeName the value of field 'schemeName'.
\r
294 public void setSchemeName(
\r
295 final java.lang.String schemeName) {
\r
296 this._schemeName = schemeName;
\r
300 * Sets the value of field 'version'. The field 'version' has
\r
301 * the following description: Jalview colour scheme document
\r
305 * @param version the value of field 'version'.
\r
307 public void setVersion(
\r
308 final java.lang.String version) {
\r
309 this._version = version;
\r
313 * Method unmarshal.
\r
316 * @throws org.exolab.castor.xml.MarshalException if object is
\r
317 * null or if any SAXException is thrown during marshaling
\r
318 * @throws org.exolab.castor.xml.ValidationException if this
\r
319 * object is an invalid instance according to the schema
\r
320 * @return the unmarshaled
\r
321 * jalview.schemabinding.version2.JalviewUserColours
\r
323 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
\r
324 final java.io.Reader reader)
\r
325 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
326 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller.unmarshal(jalview.schemabinding.version2.JalviewUserColours.class, reader);
\r
332 * @throws org.exolab.castor.xml.ValidationException if this
\r
333 * object is an invalid instance according to the schema
\r
335 public void validate(
\r
337 throws org.exolab.castor.xml.ValidationException {
\r
338 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
339 validator.validate(this);
\r