2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 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
50 // ----------------/
\r
51 // - Constructors -/
\r
52 // ----------------/
\r
54 public JalviewUserColours()
\r
57 this._colourList = new java.util.Vector();
\r
68 * @throws java.lang.IndexOutOfBoundsException
\r
69 * if the index given is outside the bounds of the collection
\r
71 public void addColour(final Colour vColour)
\r
72 throws java.lang.IndexOutOfBoundsException
\r
74 this._colourList.addElement(vColour);
\r
82 * @throws java.lang.IndexOutOfBoundsException
\r
83 * if the index given is outside the bounds of the collection
\r
85 public void addColour(final int index, final Colour vColour)
\r
86 throws java.lang.IndexOutOfBoundsException
\r
88 this._colourList.add(index, vColour);
\r
92 * Method enumerateColour.
\r
94 * @return an Enumeration over all Colour elements
\r
96 public java.util.Enumeration enumerateColour()
\r
98 return this._colourList.elements();
\r
102 * Method getColour.
\r
105 * @throws java.lang.IndexOutOfBoundsException
\r
106 * if the index given is outside the bounds of the collection
\r
107 * @return the value of the Colour at the given index
\r
109 public Colour getColour(final int index)
\r
110 throws java.lang.IndexOutOfBoundsException
\r
112 // check bounds for index
\r
113 if (index < 0 || index >= this._colourList.size())
\r
115 throw new IndexOutOfBoundsException("getColour: Index value '"
\r
116 + index + "' not in range [0.."
\r
117 + (this._colourList.size() - 1) + "]");
\r
120 return (Colour) _colourList.get(index);
\r
124 * Method getColour.Returns the contents of the collection in an Array.
\r
126 * Note: Just in case the collection contents are changing in another thread,
\r
127 * we pass a 0-length Array of the correct type into the API call. This way we
\r
128 * <i>know</i> that the Array returned is of exactly the correct length.
\r
130 * @return this collection as an Array
\r
132 public Colour[] getColour()
\r
134 Colour[] array = new Colour[0];
\r
135 return (Colour[]) this._colourList.toArray(array);
\r
139 * Method getColourCount.
\r
141 * @return the size of this collection
\r
143 public int getColourCount()
\r
145 return this._colourList.size();
\r
149 * Returns the value of field 'schemeName'.
\r
151 * @return the value of field 'SchemeName'.
\r
153 public java.lang.String getSchemeName()
\r
155 return this._schemeName;
\r
161 * @return true if this object is valid according to the schema
\r
163 public boolean isValid()
\r
168 } catch (org.exolab.castor.xml.ValidationException vex)
\r
179 * @throws org.exolab.castor.xml.MarshalException
\r
180 * if object is null or if any SAXException is thrown during
\r
182 * @throws org.exolab.castor.xml.ValidationException
\r
183 * if this object is an invalid instance according to the
\r
186 public void marshal(final java.io.Writer out)
\r
187 throws org.exolab.castor.xml.MarshalException,
\r
188 org.exolab.castor.xml.ValidationException
\r
190 Marshaller.marshal(this, out);
\r
197 * @throws java.io.IOException
\r
198 * if an IOException occurs during marshaling
\r
199 * @throws org.exolab.castor.xml.ValidationException
\r
200 * if this object is an invalid instance according to the
\r
202 * @throws org.exolab.castor.xml.MarshalException
\r
203 * if object is null or if any SAXException is thrown during
\r
206 public void marshal(final org.xml.sax.ContentHandler handler)
\r
207 throws java.io.IOException,
\r
208 org.exolab.castor.xml.MarshalException,
\r
209 org.exolab.castor.xml.ValidationException
\r
211 Marshaller.marshal(this, handler);
\r
216 public void removeAllColour()
\r
218 this._colourList.clear();
\r
222 * Method removeColour.
\r
225 * @return true if the object was removed from the collection.
\r
227 public boolean removeColour(final Colour vColour)
\r
229 boolean removed = _colourList.remove(vColour);
\r
234 * Method removeColourAt.
\r
237 * @return the element removed from the collection
\r
239 public Colour removeColourAt(final int index)
\r
241 java.lang.Object obj = this._colourList.remove(index);
\r
242 return (Colour) obj;
\r
250 * @throws java.lang.IndexOutOfBoundsException
\r
251 * if the index given is outside the bounds of the collection
\r
253 public void setColour(final int index, final Colour vColour)
\r
254 throws java.lang.IndexOutOfBoundsException
\r
256 // check bounds for index
\r
257 if (index < 0 || index >= this._colourList.size())
\r
259 throw new IndexOutOfBoundsException("setColour: Index value '"
\r
260 + index + "' not in range [0.."
\r
261 + (this._colourList.size() - 1) + "]");
\r
264 this._colourList.set(index, vColour);
\r
270 * @param vColourArray
\r
272 public void setColour(final Colour[] vColourArray)
\r
275 _colourList.clear();
\r
277 for (int i = 0; i < vColourArray.length; i++)
\r
279 this._colourList.add(vColourArray[i]);
\r
284 * Sets the value of field 'schemeName'.
\r
286 * @param schemeName
\r
287 * the value of field 'schemeName'.
\r
289 public void setSchemeName(final java.lang.String schemeName)
\r
291 this._schemeName = schemeName;
\r
295 * Method unmarshal.
\r
298 * @throws org.exolab.castor.xml.MarshalException
\r
299 * if object is null or if any SAXException is thrown during
\r
301 * @throws org.exolab.castor.xml.ValidationException
\r
302 * if this object is an invalid instance according to the
\r
304 * @return the unmarshaled jalview.schemabinding.version2.JalviewUserColours
\r
306 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
\r
307 final java.io.Reader reader)
\r
308 throws org.exolab.castor.xml.MarshalException,
\r
309 org.exolab.castor.xml.ValidationException
\r
311 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller
\r
313 jalview.schemabinding.version2.JalviewUserColours.class,
\r
320 * @throws org.exolab.castor.xml.ValidationException
\r
321 * if this object is an invalid instance according to the
\r
324 public void validate() throws org.exolab.castor.xml.ValidationException
\r
326 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
327 validator.validate(this);
\r