JAL-2015 JAL-1956 rollout of FeatureColourI in place of
[jalview.git] / src / jalview / schemes / FeatureColourScheme.java
1 package jalview.schemes;
2
3 import jalview.api.FeatureColourI;
4 import jalview.api.FeatureSettingsI;
5
6 import java.awt.Color;
7
8 /**
9  * Pre-set configurations for feature settings
10  * 
11  * @author gmcarstairs
12  *
13  */
14 public enum FeatureColourScheme implements FeatureSettingsI
15 {
16   /**
17    * Show sequence variants in red, on top of exons coloured by label
18    */
19   EnsemblVariants
20   {
21
22     @Override
23     public boolean isFeatureDisplayed(String type)
24     {
25       // TODO accept SO sub-types of these features
26       // if (SequenceOntologyFactory.getInstance().isA(SequenceOntologyI.EXON...
27       return (EXON.equals(type) || SEQUENCE_VARIANT.equals(type));
28     }
29
30     @Override
31     public boolean isGroupDisplayed(String group)
32     {
33       return true;
34     }
35
36     @Override
37     public FeatureColourI getFeatureColour(String type)
38     {
39       if (EXON.equals(type))
40       {
41         return new FeatureColour()
42         {
43           @Override
44           public boolean isColourByLabel()
45           {
46             return true;
47           }
48         };
49       }
50       if (SEQUENCE_VARIANT.equals(type))
51       {
52         return new FeatureColour(Color.RED);
53       }
54       return null;
55     }
56
57     @Override
58     public float getTransparency()
59     {
60       return 1f;
61     }
62
63     /**
64      * Order sequence_variant above exon above the rest
65      */
66     @Override
67     public int compareTo(String feature1, String feature2)
68     {
69       if (SEQUENCE_VARIANT.equals(feature1))
70       {
71         return -1;
72       }
73       if (SEQUENCE_VARIANT.equals(feature2))
74       {
75         return +1;
76       }
77       if (EXON.equals(feature1))
78       {
79         return -1;
80       }
81       if (EXON.equals(feature2))
82       {
83         return +1;
84       }
85       return 0;
86     }
87
88     @Override
89     public boolean optimiseOrder()
90     {
91       return false;
92     };
93
94   };
95
96   // SequenceOntologyI.SEQUENCE_VARIANT
97   private static final String SEQUENCE_VARIANT = "sequence_variant";
98
99   // SequenceOntologyI.EXON
100   private static final String EXON = "exon";
101 }