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