2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
28 * Class JalviewUserColours.
\r
30 * @version $Revision$ $Date$
\r
32 public class JalviewUserColours implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
40 * Field _schemeName.
\r
42 private java.lang.String _schemeName;
\r
45 * Jalview colour scheme document version.
\r
48 private java.lang.String _version;
\r
51 * Field _colourList.
\r
53 private java.util.Vector _colourList;
\r
55 // ----------------/
\r
56 // - Constructors -/
\r
57 // ----------------/
\r
59 public JalviewUserColours()
\r
62 this._colourList = new java.util.Vector();
\r
73 * @throws java.lang.IndexOutOfBoundsException
\r
74 * if the index given is outside the bounds of the collection
\r
76 public void addColour(final Colour vColour)
\r
77 throws java.lang.IndexOutOfBoundsException
\r
79 this._colourList.addElement(vColour);
\r
87 * @throws java.lang.IndexOutOfBoundsException
\r
88 * if the index given is outside the bounds of the collection
\r
90 public void addColour(final int index, final Colour vColour)
\r
91 throws java.lang.IndexOutOfBoundsException
\r
93 this._colourList.add(index, vColour);
\r
97 * Method enumerateColour.
\r
99 * @return an Enumeration over all Colour elements
\r
101 public java.util.Enumeration enumerateColour()
\r
103 return this._colourList.elements();
\r
107 * Method getColour.
\r
110 * @throws java.lang.IndexOutOfBoundsException
\r
111 * if the index given is outside the bounds of the collection
\r
112 * @return the value of the Colour at the given index
\r
114 public Colour getColour(final int index)
\r
115 throws java.lang.IndexOutOfBoundsException
\r
117 // check bounds for index
\r
118 if (index < 0 || index >= this._colourList.size())
\r
120 throw new IndexOutOfBoundsException("getColour: Index value '"
\r
121 + index + "' not in range [0.."
\r
122 + (this._colourList.size() - 1) + "]");
\r
125 return (Colour) _colourList.get(index);
\r
129 * Method getColour.Returns the contents of the collection in an Array.
\r
131 * Note: Just in case the collection contents are changing in another thread,
\r
132 * we pass a 0-length Array of the correct type into the API call. This way we
\r
133 * <i>know</i> 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' has the following
\r
165 * description: Jalview colour scheme document version.
\r
168 * @return the value of field 'Version'.
\r
170 public java.lang.String getVersion()
\r
172 return this._version;
\r
178 * @return true if this object is valid according to the schema
\r
180 public boolean isValid()
\r
185 } catch (org.exolab.castor.xml.ValidationException vex)
\r
196 * @throws org.exolab.castor.xml.MarshalException
\r
197 * if object is null or if any SAXException is thrown during
\r
199 * @throws org.exolab.castor.xml.ValidationException
\r
200 * if this object is an invalid instance according to the schema
\r
202 public void marshal(final java.io.Writer out)
\r
203 throws org.exolab.castor.xml.MarshalException,
\r
204 org.exolab.castor.xml.ValidationException
\r
206 Marshaller.marshal(this, out);
\r
213 * @throws java.io.IOException
\r
214 * if an IOException occurs during marshaling
\r
215 * @throws org.exolab.castor.xml.ValidationException
\r
216 * if this object is an invalid instance according to the schema
\r
217 * @throws org.exolab.castor.xml.MarshalException
\r
218 * if object is null or if any SAXException is thrown during
\r
221 public void marshal(final org.xml.sax.ContentHandler handler)
\r
222 throws java.io.IOException,
\r
223 org.exolab.castor.xml.MarshalException,
\r
224 org.exolab.castor.xml.ValidationException
\r
226 Marshaller.marshal(this, handler);
\r
231 public void removeAllColour()
\r
233 this._colourList.clear();
\r
237 * Method removeColour.
\r
240 * @return true if the object was removed from the collection.
\r
242 public boolean removeColour(final Colour vColour)
\r
244 boolean removed = _colourList.remove(vColour);
\r
249 * Method removeColourAt.
\r
252 * @return the element removed from the collection
\r
254 public Colour removeColourAt(final int index)
\r
256 java.lang.Object obj = this._colourList.remove(index);
\r
257 return (Colour) obj;
\r
265 * @throws java.lang.IndexOutOfBoundsException
\r
266 * if the index given is outside the bounds of the collection
\r
268 public void setColour(final int index, final Colour vColour)
\r
269 throws java.lang.IndexOutOfBoundsException
\r
271 // check bounds for index
\r
272 if (index < 0 || index >= this._colourList.size())
\r
274 throw new IndexOutOfBoundsException("setColour: Index value '"
\r
275 + index + "' not in range [0.."
\r
276 + (this._colourList.size() - 1) + "]");
\r
279 this._colourList.set(index, vColour);
\r
285 * @param vColourArray
\r
287 public void setColour(final Colour[] vColourArray)
\r
290 _colourList.clear();
\r
292 for (int i = 0; i < vColourArray.length; i++)
\r
294 this._colourList.add(vColourArray[i]);
\r
299 * Sets the value of field 'schemeName'.
\r
301 * @param schemeName
\r
302 * the value of field 'schemeName'.
\r
304 public void setSchemeName(final java.lang.String schemeName)
\r
306 this._schemeName = schemeName;
\r
310 * Sets the value of field 'version'. The field 'version' has the following
\r
311 * description: Jalview colour scheme document version.
\r
315 * the value of field 'version'.
\r
317 public void setVersion(final java.lang.String version)
\r
319 this._version = version;
\r
323 * Method unmarshal.
\r
326 * @throws org.exolab.castor.xml.MarshalException
\r
327 * if object is null or if any SAXException is thrown during
\r
329 * @throws org.exolab.castor.xml.ValidationException
\r
330 * if this object is an invalid instance according to the schema
\r
331 * @return the unmarshaled jalview.schemabinding.version2.JalviewUserColours
\r
333 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
\r
334 final java.io.Reader reader)
\r
335 throws org.exolab.castor.xml.MarshalException,
\r
336 org.exolab.castor.xml.ValidationException
\r
338 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller
\r
340 jalview.schemabinding.version2.JalviewUserColours.class,
\r
347 * @throws org.exolab.castor.xml.ValidationException
\r
348 * if this object is an invalid instance according to the schema
\r
350 public void validate() throws org.exolab.castor.xml.ValidationException
\r
352 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
353 validator.validate(this);
\r