JAL-3181 refactor: extracted buildLinkMenu() for testability
[jalview.git] / src / jalview / binding / Colour.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package jalview.binding;
9
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
13
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
16
17 /**
18  * Class Colour.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class Colour implements java.io.Serializable
23 {
24
25   // --------------------------/
26   // - Class/Member Variables -/
27   // --------------------------/
28
29   /**
30    * Single letter residue code for an alignment colour scheme, or feature type
31    * for a feature colour scheme
32    */
33   private java.lang.String _name;
34
35   /**
36    * Field _RGB.
37    */
38   private java.lang.String _RGB;
39
40   /**
41    * Field _minRGB.
42    */
43   private java.lang.String _minRGB;
44
45   /**
46    * Field _noValueColour.
47    */
48   private jalview.binding.types.NoValueColour _noValueColour = jalview.binding.types.NoValueColour
49           .valueOf("Min");
50
51   /**
52    * Field _threshType.
53    */
54   private jalview.binding.types.ColourThreshTypeType _threshType;
55
56   /**
57    * Field _threshold.
58    */
59   private float _threshold;
60
61   /**
62    * keeps track of state for field: _threshold
63    */
64   private boolean _has_threshold;
65
66   /**
67    * Field _max.
68    */
69   private float _max;
70
71   /**
72    * keeps track of state for field: _max
73    */
74   private boolean _has_max;
75
76   /**
77    * Field _min.
78    */
79   private float _min;
80
81   /**
82    * keeps track of state for field: _min
83    */
84   private boolean _has_min;
85
86   /**
87    * Field _colourByLabel.
88    */
89   private boolean _colourByLabel;
90
91   /**
92    * keeps track of state for field: _colourByLabel
93    */
94   private boolean _has_colourByLabel;
95
96   /**
97    * Field _autoScale.
98    */
99   private boolean _autoScale;
100
101   /**
102    * keeps track of state for field: _autoScale
103    */
104   private boolean _has_autoScale;
105
106   /**
107    * name of feature attribute to colour by, or attribute and sub-attribute
108    */
109   private java.util.Vector _attributeNameList;
110
111   // ----------------/
112   // - Constructors -/
113   // ----------------/
114
115   public Colour()
116   {
117     super();
118     setNoValueColour(jalview.binding.types.NoValueColour.valueOf("Min"));
119     this._attributeNameList = new java.util.Vector();
120   }
121
122   // -----------/
123   // - Methods -/
124   // -----------/
125
126   /**
127    * 
128    * 
129    * @param vAttributeName
130    * @throws java.lang.IndexOutOfBoundsException
131    *           if the index given is outside the bounds of the collection
132    */
133   public void addAttributeName(final java.lang.String vAttributeName)
134           throws java.lang.IndexOutOfBoundsException
135   {
136     // check for the maximum size
137     if (this._attributeNameList.size() >= 2)
138     {
139       throw new IndexOutOfBoundsException(
140               "addAttributeName has a maximum of 2");
141     }
142
143     this._attributeNameList.addElement(vAttributeName);
144   }
145
146   /**
147    * 
148    * 
149    * @param index
150    * @param vAttributeName
151    * @throws java.lang.IndexOutOfBoundsException
152    *           if the index given is outside the bounds of the collection
153    */
154   public void addAttributeName(final int index,
155           final java.lang.String vAttributeName)
156           throws java.lang.IndexOutOfBoundsException
157   {
158     // check for the maximum size
159     if (this._attributeNameList.size() >= 2)
160     {
161       throw new IndexOutOfBoundsException(
162               "addAttributeName has a maximum of 2");
163     }
164
165     this._attributeNameList.add(index, vAttributeName);
166   }
167
168   /**
169    */
170   public void deleteAutoScale()
171   {
172     this._has_autoScale = false;
173   }
174
175   /**
176    */
177   public void deleteColourByLabel()
178   {
179     this._has_colourByLabel = false;
180   }
181
182   /**
183    */
184   public void deleteMax()
185   {
186     this._has_max = false;
187   }
188
189   /**
190    */
191   public void deleteMin()
192   {
193     this._has_min = false;
194   }
195
196   /**
197    */
198   public void deleteThreshold()
199   {
200     this._has_threshold = false;
201   }
202
203   /**
204    * Method enumerateAttributeName.
205    * 
206    * @return an Enumeration over all java.lang.String elements
207    */
208   public java.util.Enumeration enumerateAttributeName()
209   {
210     return this._attributeNameList.elements();
211   }
212
213   /**
214    * Method getAttributeName.
215    * 
216    * @param index
217    * @throws java.lang.IndexOutOfBoundsException
218    *           if the index given is outside the bounds of the collection
219    * @return the value of the java.lang.String at the given index
220    */
221   public java.lang.String getAttributeName(final int index)
222           throws java.lang.IndexOutOfBoundsException
223   {
224     // check bounds for index
225     if (index < 0 || index >= this._attributeNameList.size())
226     {
227       throw new IndexOutOfBoundsException("getAttributeName: Index value '"
228               + index + "' not in range [0.."
229               + (this._attributeNameList.size() - 1) + "]");
230     }
231
232     return (java.lang.String) _attributeNameList.get(index);
233   }
234
235   /**
236    * Method getAttributeName.Returns the contents of the collection in an Array.
237    * <p>
238    * Note: Just in case the collection contents are changing in another thread,
239    * we pass a 0-length Array of the correct type into the API call. This way we
240    * <i>know</i> that the Array returned is of exactly the correct length.
241    * 
242    * @return this collection as an Array
243    */
244   public java.lang.String[] getAttributeName()
245   {
246     java.lang.String[] array = new java.lang.String[0];
247     return (java.lang.String[]) this._attributeNameList.toArray(array);
248   }
249
250   /**
251    * Method getAttributeNameCount.
252    * 
253    * @return the size of this collection
254    */
255   public int getAttributeNameCount()
256   {
257     return this._attributeNameList.size();
258   }
259
260   /**
261    * Returns the value of field 'autoScale'.
262    * 
263    * @return the value of field 'AutoScale'.
264    */
265   public boolean getAutoScale()
266   {
267     return this._autoScale;
268   }
269
270   /**
271    * Returns the value of field 'colourByLabel'.
272    * 
273    * @return the value of field 'ColourByLabel'.
274    */
275   public boolean getColourByLabel()
276   {
277     return this._colourByLabel;
278   }
279
280   /**
281    * Returns the value of field 'max'.
282    * 
283    * @return the value of field 'Max'.
284    */
285   public float getMax()
286   {
287     return this._max;
288   }
289
290   /**
291    * Returns the value of field 'min'.
292    * 
293    * @return the value of field 'Min'.
294    */
295   public float getMin()
296   {
297     return this._min;
298   }
299
300   /**
301    * Returns the value of field 'minRGB'.
302    * 
303    * @return the value of field 'MinRGB'.
304    */
305   public java.lang.String getMinRGB()
306   {
307     return this._minRGB;
308   }
309
310   /**
311    * Returns the value of field 'name'. The field 'name' has the following
312    * description: Single letter residue code for an alignment colour scheme, or
313    * feature type for a feature colour scheme
314    * 
315    * @return the value of field 'Name'.
316    */
317   public java.lang.String getName()
318   {
319     return this._name;
320   }
321
322   /**
323    * Returns the value of field 'noValueColour'.
324    * 
325    * @return the value of field 'NoValueColour'.
326    */
327   public jalview.binding.types.NoValueColour getNoValueColour()
328   {
329     return this._noValueColour;
330   }
331
332   /**
333    * Returns the value of field 'RGB'.
334    * 
335    * @return the value of field 'RGB'.
336    */
337   public java.lang.String getRGB()
338   {
339     return this._RGB;
340   }
341
342   /**
343    * Returns the value of field 'threshType'.
344    * 
345    * @return the value of field 'ThreshType'.
346    */
347   public jalview.binding.types.ColourThreshTypeType getThreshType()
348   {
349     return this._threshType;
350   }
351
352   /**
353    * Returns the value of field 'threshold'.
354    * 
355    * @return the value of field 'Threshold'.
356    */
357   public float getThreshold()
358   {
359     return this._threshold;
360   }
361
362   /**
363    * Method hasAutoScale.
364    * 
365    * @return true if at least one AutoScale has been added
366    */
367   public boolean hasAutoScale()
368   {
369     return this._has_autoScale;
370   }
371
372   /**
373    * Method hasColourByLabel.
374    * 
375    * @return true if at least one ColourByLabel has been added
376    */
377   public boolean hasColourByLabel()
378   {
379     return this._has_colourByLabel;
380   }
381
382   /**
383    * Method hasMax.
384    * 
385    * @return true if at least one Max has been added
386    */
387   public boolean hasMax()
388   {
389     return this._has_max;
390   }
391
392   /**
393    * Method hasMin.
394    * 
395    * @return true if at least one Min has been added
396    */
397   public boolean hasMin()
398   {
399     return this._has_min;
400   }
401
402   /**
403    * Method hasThreshold.
404    * 
405    * @return true if at least one Threshold has been added
406    */
407   public boolean hasThreshold()
408   {
409     return this._has_threshold;
410   }
411
412   /**
413    * Returns the value of field 'autoScale'.
414    * 
415    * @return the value of field 'AutoScale'.
416    */
417   public boolean isAutoScale()
418   {
419     return this._autoScale;
420   }
421
422   /**
423    * Returns the value of field 'colourByLabel'.
424    * 
425    * @return the value of field 'ColourByLabel'.
426    */
427   public boolean isColourByLabel()
428   {
429     return this._colourByLabel;
430   }
431
432   /**
433    * Method isValid.
434    * 
435    * @return true if this object is valid according to the schema
436    */
437   public boolean isValid()
438   {
439     try
440     {
441       validate();
442     } catch (org.exolab.castor.xml.ValidationException vex)
443     {
444       return false;
445     }
446     return true;
447   }
448
449   /**
450    * 
451    * 
452    * @param out
453    * @throws org.exolab.castor.xml.MarshalException
454    *           if object is null or if any SAXException is thrown during
455    *           marshaling
456    * @throws org.exolab.castor.xml.ValidationException
457    *           if this object is an invalid instance according to the schema
458    */
459   public void marshal(final java.io.Writer out)
460           throws org.exolab.castor.xml.MarshalException,
461           org.exolab.castor.xml.ValidationException
462   {
463     Marshaller.marshal(this, out);
464   }
465
466   /**
467    * 
468    * 
469    * @param handler
470    * @throws java.io.IOException
471    *           if an IOException occurs during marshaling
472    * @throws org.exolab.castor.xml.ValidationException
473    *           if this object is an invalid instance according to the schema
474    * @throws org.exolab.castor.xml.MarshalException
475    *           if object is null or if any SAXException is thrown during
476    *           marshaling
477    */
478   public void marshal(final org.xml.sax.ContentHandler handler)
479           throws java.io.IOException,
480           org.exolab.castor.xml.MarshalException,
481           org.exolab.castor.xml.ValidationException
482   {
483     Marshaller.marshal(this, handler);
484   }
485
486   /**
487    */
488   public void removeAllAttributeName()
489   {
490     this._attributeNameList.clear();
491   }
492
493   /**
494    * Method removeAttributeName.
495    * 
496    * @param vAttributeName
497    * @return true if the object was removed from the collection.
498    */
499   public boolean removeAttributeName(final java.lang.String vAttributeName)
500   {
501     boolean removed = _attributeNameList.remove(vAttributeName);
502     return removed;
503   }
504
505   /**
506    * Method removeAttributeNameAt.
507    * 
508    * @param index
509    * @return the element removed from the collection
510    */
511   public java.lang.String removeAttributeNameAt(final int index)
512   {
513     java.lang.Object obj = this._attributeNameList.remove(index);
514     return (java.lang.String) obj;
515   }
516
517   /**
518    * 
519    * 
520    * @param index
521    * @param vAttributeName
522    * @throws java.lang.IndexOutOfBoundsException
523    *           if the index given is outside the bounds of the collection
524    */
525   public void setAttributeName(final int index,
526           final java.lang.String vAttributeName)
527           throws java.lang.IndexOutOfBoundsException
528   {
529     // check bounds for index
530     if (index < 0 || index >= this._attributeNameList.size())
531     {
532       throw new IndexOutOfBoundsException("setAttributeName: Index value '"
533               + index + "' not in range [0.."
534               + (this._attributeNameList.size() - 1) + "]");
535     }
536
537     this._attributeNameList.set(index, vAttributeName);
538   }
539
540   /**
541    * 
542    * 
543    * @param vAttributeNameArray
544    */
545   public void setAttributeName(final java.lang.String[] vAttributeNameArray)
546   {
547     // -- copy array
548     _attributeNameList.clear();
549
550     for (int i = 0; i < vAttributeNameArray.length; i++)
551     {
552       this._attributeNameList.add(vAttributeNameArray[i]);
553     }
554   }
555
556   /**
557    * Sets the value of field 'autoScale'.
558    * 
559    * @param autoScale
560    *          the value of field 'autoScale'.
561    */
562   public void setAutoScale(final boolean autoScale)
563   {
564     this._autoScale = autoScale;
565     this._has_autoScale = true;
566   }
567
568   /**
569    * Sets the value of field 'colourByLabel'.
570    * 
571    * @param colourByLabel
572    *          the value of field 'colourByLabel'.
573    */
574   public void setColourByLabel(final boolean colourByLabel)
575   {
576     this._colourByLabel = colourByLabel;
577     this._has_colourByLabel = true;
578   }
579
580   /**
581    * Sets the value of field 'max'.
582    * 
583    * @param max
584    *          the value of field 'max'.
585    */
586   public void setMax(final float max)
587   {
588     this._max = max;
589     this._has_max = true;
590   }
591
592   /**
593    * Sets the value of field 'min'.
594    * 
595    * @param min
596    *          the value of field 'min'.
597    */
598   public void setMin(final float min)
599   {
600     this._min = min;
601     this._has_min = true;
602   }
603
604   /**
605    * Sets the value of field 'minRGB'.
606    * 
607    * @param minRGB
608    *          the value of field 'minRGB'.
609    */
610   public void setMinRGB(final java.lang.String minRGB)
611   {
612     this._minRGB = minRGB;
613   }
614
615   /**
616    * Sets the value of field 'name'. The field 'name' has the following
617    * description: Single letter residue code for an alignment colour scheme, or
618    * feature type for a feature colour scheme
619    * 
620    * @param name
621    *          the value of field 'name'.
622    */
623   public void setName(final java.lang.String name)
624   {
625     this._name = name;
626   }
627
628   /**
629    * Sets the value of field 'noValueColour'.
630    * 
631    * @param noValueColour
632    *          the value of field 'noValueColour'.
633    */
634   public void setNoValueColour(
635           final jalview.binding.types.NoValueColour noValueColour)
636   {
637     this._noValueColour = noValueColour;
638   }
639
640   /**
641    * Sets the value of field 'RGB'.
642    * 
643    * @param RGB
644    *          the value of field 'RGB'.
645    */
646   public void setRGB(final java.lang.String RGB)
647   {
648     this._RGB = RGB;
649   }
650
651   /**
652    * Sets the value of field 'threshType'.
653    * 
654    * @param threshType
655    *          the value of field 'threshType'.
656    */
657   public void setThreshType(
658           final jalview.binding.types.ColourThreshTypeType threshType)
659   {
660     this._threshType = threshType;
661   }
662
663   /**
664    * Sets the value of field 'threshold'.
665    * 
666    * @param threshold
667    *          the value of field 'threshold'.
668    */
669   public void setThreshold(final float threshold)
670   {
671     this._threshold = threshold;
672     this._has_threshold = true;
673   }
674
675   /**
676    * Method unmarshal.
677    * 
678    * @param reader
679    * @throws org.exolab.castor.xml.MarshalException
680    *           if object is null or if any SAXException is thrown during
681    *           marshaling
682    * @throws org.exolab.castor.xml.ValidationException
683    *           if this object is an invalid instance according to the schema
684    * @return the unmarshaled jalview.binding.Colour
685    */
686   public static jalview.binding.Colour unmarshal(
687           final java.io.Reader reader)
688           throws org.exolab.castor.xml.MarshalException,
689           org.exolab.castor.xml.ValidationException
690   {
691     return (jalview.binding.Colour) Unmarshaller
692             .unmarshal(jalview.binding.Colour.class, reader);
693   }
694
695   /**
696    * 
697    * 
698    * @throws org.exolab.castor.xml.ValidationException
699    *           if this object is an invalid instance according to the schema
700    */
701   public void validate() throws org.exolab.castor.xml.ValidationException
702   {
703     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
704     validator.validate(this);
705   }
706
707 }