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