354dc2f36d832f478df9ff7da84d5aff57f231bd
[jalview.git] / src / jalview / binding / JalviewUserColours.java
1 /*\r
2  * This class was automatically generated with\r
3  * <a href="http://www.castor.org">Castor 0.9.6</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 \r
8 /*\r
9 * Jalview - A Sequence Alignment Editor and Viewer\r
10 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
11 *\r
12 * This program is free software; you can redistribute it and/or\r
13 * modify it under the terms of the GNU General Public License\r
14 * as published by the Free Software Foundation; either version 2\r
15 * of the License, or (at your option) any later version.\r
16 *\r
17 * This program is distributed in the hope that it will be useful,\r
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
20 * GNU General Public License for more details.\r
21 *\r
22 * You should have received a copy of the GNU General Public License\r
23 * along with this program; if not, write to the Free Software\r
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
25 */\r
26 \r
27 package jalview.binding;\r
28 \r
29   //---------------------------------/\r
30  //- Imported classes and packages -/\r
31 //---------------------------------/\r
32 \r
33 import java.io.IOException;\r
34 import java.io.Reader;\r
35 import java.io.Serializable;\r
36 import java.io.Writer;\r
37 import java.util.Enumeration;\r
38 import java.util.Vector;\r
39 import org.exolab.castor.xml.MarshalException;\r
40 import org.exolab.castor.xml.Marshaller;\r
41 import org.exolab.castor.xml.Unmarshaller;\r
42 import org.exolab.castor.xml.ValidationException;\r
43 import org.xml.sax.ContentHandler;\r
44 \r
45 /**\r
46  * Class JalviewUserColours.\r
47  *\r
48  * @version $Revision$ $Date$\r
49  */\r
50 public class JalviewUserColours implements java.io.Serializable {\r
51 \r
52 \r
53       //--------------------------/\r
54      //- Class/Member Variables -/\r
55     //--------------------------/\r
56 \r
57     /**\r
58      * Field _colourList\r
59      */\r
60     private java.util.Vector _colourList;\r
61 \r
62 \r
63       //----------------/\r
64      //- Constructors -/\r
65     //----------------/\r
66 \r
67     public JalviewUserColours() {\r
68         super();\r
69         _colourList = new Vector();\r
70     } //-- jalview.binding.JalviewUserColours()\r
71 \r
72 \r
73       //-----------/\r
74      //- Methods -/\r
75     //-----------/\r
76 \r
77     /**\r
78      * Method addColour\r
79      *\r
80      *\r
81      *\r
82      * @param vColour\r
83      */\r
84     public void addColour(jalview.binding.Colour vColour)\r
85         throws java.lang.IndexOutOfBoundsException\r
86     {\r
87         _colourList.addElement(vColour);\r
88     } //-- void addColour(jalview.binding.Colour)\r
89 \r
90     /**\r
91      * Method addColour\r
92      *\r
93      *\r
94      *\r
95      * @param index\r
96      * @param vColour\r
97      */\r
98     public void addColour(int index, jalview.binding.Colour vColour)\r
99         throws java.lang.IndexOutOfBoundsException\r
100     {\r
101         _colourList.insertElementAt(vColour, index);\r
102     } //-- void addColour(int, jalview.binding.Colour)\r
103 \r
104     /**\r
105      * Method enumerateColour\r
106      *\r
107      *\r
108      *\r
109      * @return Enumeration\r
110      */\r
111     public java.util.Enumeration enumerateColour()\r
112     {\r
113         return _colourList.elements();\r
114     } //-- java.util.Enumeration enumerateColour()\r
115 \r
116     /**\r
117      * Method getColour\r
118      *\r
119      *\r
120      *\r
121      * @param index\r
122      * @return Colour\r
123      */\r
124     public jalview.binding.Colour getColour(int index)\r
125         throws java.lang.IndexOutOfBoundsException\r
126     {\r
127         //-- check bounds for index\r
128         if ((index < 0) || (index > _colourList.size())) {\r
129             throw new IndexOutOfBoundsException();\r
130         }\r
131 \r
132         return (jalview.binding.Colour) _colourList.elementAt(index);\r
133     } //-- jalview.binding.Colour getColour(int)\r
134 \r
135     /**\r
136      * Method getColour\r
137      *\r
138      *\r
139      *\r
140      * @return Colour\r
141      */\r
142     public jalview.binding.Colour[] getColour()\r
143     {\r
144         int size = _colourList.size();\r
145         jalview.binding.Colour[] mArray = new jalview.binding.Colour[size];\r
146         for (int index = 0; index < size; index++) {\r
147             mArray[index] = (jalview.binding.Colour) _colourList.elementAt(index);\r
148         }\r
149         return mArray;\r
150     } //-- jalview.binding.Colour[] getColour()\r
151 \r
152     /**\r
153      * Method getColourCount\r
154      *\r
155      *\r
156      *\r
157      * @return int\r
158      */\r
159     public int getColourCount()\r
160     {\r
161         return _colourList.size();\r
162     } //-- int getColourCount()\r
163 \r
164     /**\r
165      * Method isValid\r
166      *\r
167      *\r
168      *\r
169      * @return boolean\r
170      */\r
171     public boolean isValid()\r
172     {\r
173         try {\r
174             validate();\r
175         }\r
176         catch (org.exolab.castor.xml.ValidationException vex) {\r
177             return false;\r
178         }\r
179         return true;\r
180     } //-- boolean isValid()\r
181 \r
182     /**\r
183      * Method marshal\r
184      *\r
185      *\r
186      *\r
187      * @param out\r
188      */\r
189     public void marshal(java.io.Writer out)\r
190         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException\r
191     {\r
192 \r
193         Marshaller.marshal(this, out);\r
194     } //-- void marshal(java.io.Writer)\r
195 \r
196     /**\r
197      * Method marshal\r
198      *\r
199      *\r
200      *\r
201      * @param handler\r
202      */\r
203     public void marshal(org.xml.sax.ContentHandler handler)\r
204         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException\r
205     {\r
206 \r
207         Marshaller.marshal(this, handler);\r
208     } //-- void marshal(org.xml.sax.ContentHandler)\r
209 \r
210     /**\r
211      * Method removeAllColour\r
212      *\r
213      */\r
214     public void removeAllColour()\r
215     {\r
216         _colourList.removeAllElements();\r
217     } //-- void removeAllColour()\r
218 \r
219     /**\r
220      * Method removeColour\r
221      *\r
222      *\r
223      *\r
224      * @param index\r
225      * @return Colour\r
226      */\r
227     public jalview.binding.Colour removeColour(int index)\r
228     {\r
229         java.lang.Object obj = _colourList.elementAt(index);\r
230         _colourList.removeElementAt(index);\r
231         return (jalview.binding.Colour) obj;\r
232     } //-- jalview.binding.Colour removeColour(int)\r
233 \r
234     /**\r
235      * Method setColour\r
236      *\r
237      *\r
238      *\r
239      * @param index\r
240      * @param vColour\r
241      */\r
242     public void setColour(int index, jalview.binding.Colour vColour)\r
243         throws java.lang.IndexOutOfBoundsException\r
244     {\r
245         //-- check bounds for index\r
246         if ((index < 0) || (index > _colourList.size())) {\r
247             throw new IndexOutOfBoundsException();\r
248         }\r
249         _colourList.setElementAt(vColour, index);\r
250     } //-- void setColour(int, jalview.binding.Colour)\r
251 \r
252     /**\r
253      * Method setColour\r
254      *\r
255      *\r
256      *\r
257      * @param colourArray\r
258      */\r
259     public void setColour(jalview.binding.Colour[] colourArray)\r
260     {\r
261         //-- copy array\r
262         _colourList.removeAllElements();\r
263         for (int i = 0; i < colourArray.length; i++) {\r
264             _colourList.addElement(colourArray[i]);\r
265         }\r
266     } //-- void setColour(jalview.binding.Colour)\r
267 \r
268     /**\r
269      * Method unmarshal\r
270      *\r
271      *\r
272      *\r
273      * @param reader\r
274      * @return Object\r
275      */\r
276     public static java.lang.Object unmarshal(java.io.Reader reader)\r
277         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException\r
278     {\r
279         return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader);\r
280     } //-- java.lang.Object unmarshal(java.io.Reader)\r
281 \r
282     /**\r
283      * Method validate\r
284      *\r
285      */\r
286     public void validate()\r
287         throws org.exolab.castor.xml.ValidationException\r
288     {\r
289         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
290         validator.validate(this);\r
291     } //-- void validate()\r
292 \r
293 }\r