extended Colour element with additional optional attributes for graduated colour
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / ThresholdLineDescriptor.java
1 /*\r
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
4  * \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
9  * \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
14  * \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
18  */\r
19 package jalview.schemabinding.version2.descriptors;\r
20 \r
21   //---------------------------------/\r
22  //- Imported classes and packages -/\r
23 //---------------------------------/\r
24 \r
25 import jalview.schemabinding.version2.ThresholdLine;\r
26 \r
27 /**\r
28  * Class ThresholdLineDescriptor.\r
29  * \r
30  * @version $Revision$ $Date$\r
31  */\r
32 public class ThresholdLineDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl {\r
33 \r
34 \r
35       //--------------------------/\r
36      //- Class/Member Variables -/\r
37     //--------------------------/\r
38 \r
39     /**\r
40      * Field _elementDefinition.\r
41      */\r
42     private boolean _elementDefinition;\r
43 \r
44     /**\r
45      * Field _nsPrefix.\r
46      */\r
47     private java.lang.String _nsPrefix;\r
48 \r
49     /**\r
50      * Field _nsURI.\r
51      */\r
52     private java.lang.String _nsURI;\r
53 \r
54     /**\r
55      * Field _xmlName.\r
56      */\r
57     private java.lang.String _xmlName;\r
58 \r
59 \r
60       //----------------/\r
61      //- Constructors -/\r
62     //----------------/\r
63 \r
64     public ThresholdLineDescriptor() {\r
65         super();\r
66         _nsURI = "www.vamsas.ac.uk/jalview/version2";\r
67         _xmlName = "thresholdLine";\r
68         _elementDefinition = true;\r
69         org.exolab.castor.xml.util.XMLFieldDescriptorImpl  desc           = null;\r
70         org.exolab.castor.mapping.FieldHandler             handler        = null;\r
71         org.exolab.castor.xml.FieldValidator               fieldValidator = null;\r
72         //-- initialize attribute descriptors\r
73         \r
74         //-- _label\r
75         desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_label", "label", org.exolab.castor.xml.NodeType.Attribute);\r
76         desc.setImmutable(true);\r
77         handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
78             public java.lang.Object getValue( java.lang.Object object ) \r
79                 throws IllegalStateException\r
80             {\r
81                 ThresholdLine target = (ThresholdLine) object;\r
82                 return target.getLabel();\r
83             }\r
84             public void setValue( java.lang.Object object, java.lang.Object value) \r
85                 throws IllegalStateException, IllegalArgumentException\r
86             {\r
87                 try {\r
88                     ThresholdLine target = (ThresholdLine) object;\r
89                     target.setLabel( (java.lang.String) value);\r
90                 } catch (java.lang.Exception ex) {\r
91                     throw new IllegalStateException(ex.toString());\r
92                 }\r
93             }\r
94             public java.lang.Object newInstance(java.lang.Object parent) {\r
95                 return null;\r
96             }\r
97         };\r
98         desc.setHandler(handler);\r
99         desc.setMultivalued(false);\r
100         addFieldDescriptor(desc);\r
101         \r
102         //-- validation code for: _label\r
103         fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
104         { //-- local scope\r
105             org.exolab.castor.xml.validators.StringValidator typeValidator;\r
106             typeValidator = new org.exolab.castor.xml.validators.StringValidator();\r
107             fieldValidator.setValidator(typeValidator);\r
108             typeValidator.setWhiteSpace("preserve");\r
109         }\r
110         desc.setValidator(fieldValidator);\r
111         //-- _value\r
112         desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Float.TYPE, "_value", "value", org.exolab.castor.xml.NodeType.Attribute);\r
113         handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
114             public java.lang.Object getValue( java.lang.Object object ) \r
115                 throws IllegalStateException\r
116             {\r
117                 ThresholdLine target = (ThresholdLine) object;\r
118                 if (!target.hasValue()) { return null; }\r
119                 return new java.lang.Float(target.getValue());\r
120             }\r
121             public void setValue( java.lang.Object object, java.lang.Object value) \r
122                 throws IllegalStateException, IllegalArgumentException\r
123             {\r
124                 try {\r
125                     ThresholdLine target = (ThresholdLine) object;\r
126                     // if null, use delete method for optional primitives \r
127                     if (value == null) {\r
128                         target.deleteValue();\r
129                         return;\r
130                     }\r
131                     target.setValue( ((java.lang.Float) value).floatValue());\r
132                 } catch (java.lang.Exception ex) {\r
133                     throw new IllegalStateException(ex.toString());\r
134                 }\r
135             }\r
136             public java.lang.Object newInstance(java.lang.Object parent) {\r
137                 return null;\r
138             }\r
139         };\r
140         desc.setHandler(handler);\r
141         desc.setMultivalued(false);\r
142         addFieldDescriptor(desc);\r
143         \r
144         //-- validation code for: _value\r
145         fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
146         { //-- local scope\r
147             org.exolab.castor.xml.validators.FloatValidator typeValidator;\r
148             typeValidator = new org.exolab.castor.xml.validators.FloatValidator();\r
149             fieldValidator.setValidator(typeValidator);\r
150             typeValidator.setMinInclusive((float) -3.4028235E38);\r
151             typeValidator.setMaxInclusive((float) 3.4028235E38);\r
152         }\r
153         desc.setValidator(fieldValidator);\r
154         //-- _colour\r
155         desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_colour", "colour", org.exolab.castor.xml.NodeType.Attribute);\r
156         handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
157             public java.lang.Object getValue( java.lang.Object object ) \r
158                 throws IllegalStateException\r
159             {\r
160                 ThresholdLine target = (ThresholdLine) object;\r
161                 if (!target.hasColour()) { return null; }\r
162                 return new java.lang.Integer(target.getColour());\r
163             }\r
164             public void setValue( java.lang.Object object, java.lang.Object value) \r
165                 throws IllegalStateException, IllegalArgumentException\r
166             {\r
167                 try {\r
168                     ThresholdLine target = (ThresholdLine) object;\r
169                     // if null, use delete method for optional primitives \r
170                     if (value == null) {\r
171                         target.deleteColour();\r
172                         return;\r
173                     }\r
174                     target.setColour( ((java.lang.Integer) value).intValue());\r
175                 } catch (java.lang.Exception ex) {\r
176                     throw new IllegalStateException(ex.toString());\r
177                 }\r
178             }\r
179             public java.lang.Object newInstance(java.lang.Object parent) {\r
180                 return null;\r
181             }\r
182         };\r
183         desc.setHandler(handler);\r
184         desc.setMultivalued(false);\r
185         addFieldDescriptor(desc);\r
186         \r
187         //-- validation code for: _colour\r
188         fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
189         { //-- local scope\r
190             org.exolab.castor.xml.validators.IntValidator typeValidator;\r
191             typeValidator = new org.exolab.castor.xml.validators.IntValidator();\r
192             fieldValidator.setValidator(typeValidator);\r
193             typeValidator.setMinInclusive(-2147483648);\r
194             typeValidator.setMaxInclusive(2147483647);\r
195         }\r
196         desc.setValidator(fieldValidator);\r
197         //-- initialize element descriptors\r
198         \r
199     }\r
200 \r
201 \r
202       //-----------/\r
203      //- Methods -/\r
204     //-----------/\r
205 \r
206     /**\r
207      * Method getAccessMode.\r
208      * \r
209      * @return the access mode specified for this class.\r
210      */\r
211     public org.exolab.castor.mapping.AccessMode getAccessMode(\r
212     ) {\r
213         return null;\r
214     }\r
215 \r
216     /**\r
217      * Method getIdentity.\r
218      * \r
219      * @return the identity field, null if this class has no\r
220      * identity.\r
221      */\r
222     public org.exolab.castor.mapping.FieldDescriptor getIdentity(\r
223     ) {\r
224         return super.getIdentity();\r
225     }\r
226 \r
227     /**\r
228      * Method getJavaClass.\r
229      * \r
230      * @return the Java class represented by this descriptor.\r
231      */\r
232     public java.lang.Class getJavaClass(\r
233     ) {\r
234         return jalview.schemabinding.version2.ThresholdLine.class;\r
235     }\r
236 \r
237     /**\r
238      * Method getNameSpacePrefix.\r
239      * \r
240      * @return the namespace prefix to use when marshaling as XML.\r
241      */\r
242     public java.lang.String getNameSpacePrefix(\r
243     ) {\r
244         return _nsPrefix;\r
245     }\r
246 \r
247     /**\r
248      * Method getNameSpaceURI.\r
249      * \r
250      * @return the namespace URI used when marshaling and\r
251      * unmarshaling as XML.\r
252      */\r
253     public java.lang.String getNameSpaceURI(\r
254     ) {\r
255         return _nsURI;\r
256     }\r
257 \r
258     /**\r
259      * Method getValidator.\r
260      * \r
261      * @return a specific validator for the class described by this\r
262      * ClassDescriptor.\r
263      */\r
264     public org.exolab.castor.xml.TypeValidator getValidator(\r
265     ) {\r
266         return this;\r
267     }\r
268 \r
269     /**\r
270      * Method getXMLName.\r
271      * \r
272      * @return the XML Name for the Class being described.\r
273      */\r
274     public java.lang.String getXMLName(\r
275     ) {\r
276         return _xmlName;\r
277     }\r
278 \r
279     /**\r
280      * Method isElementDefinition.\r
281      * \r
282      * @return true if XML schema definition of this Class is that\r
283      * of a global\r
284      * element or element with anonymous type definition.\r
285      */\r
286     public boolean isElementDefinition(\r
287     ) {\r
288         return _elementDefinition;\r
289     }\r
290 \r
291 }\r