JAL-2016 first draft of pre-set feature colour scheme
[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 FeatureColourAdapter()
42         {
43           @Override
44           public boolean isColourByLabel()
45           {
46             return true;
47           }
48         };
49       }
50       if (SEQUENCE_VARIANT.equals(type))
51       {
52         return new FeatureColourAdapter()
53         {
54
55           @Override
56           public Color getColour()
57           {
58             return Color.RED;
59           }
60         };
61       }
62       return null;
63     }
64
65     @Override
66     public float getTransparency()
67     {
68       return 1f;
69     }
70
71     /**
72      * Order sequence_variant above exon above the rest
73      */
74     @Override
75     public int compareTo(String feature1, String feature2)
76     {
77       if (SEQUENCE_VARIANT.equals(feature1))
78       {
79         return -1;
80       }
81       if (SEQUENCE_VARIANT.equals(feature2))
82       {
83         return +1;
84       }
85       if (EXON.equals(feature1))
86       {
87         return -1;
88       }
89       if (EXON.equals(feature2))
90       {
91         return +1;
92       }
93       return 0;
94     }
95
96     @Override
97     public boolean optimiseOrder()
98     {
99       return false;
100     };
101
102   };
103
104   // SequenceOntologyI.SEQUENCE_VARIANT
105   private static final String SEQUENCE_VARIANT = "sequence_variant";
106
107   // SequenceOntologyI.EXON
108   private static final String EXON = "exon";
109 }