spike branch updated from latest features/JAL-2446
[jalview.git] / src / jalview / api / FeatureColourI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.api;
22
23 import jalview.datamodel.SequenceFeature;
24
25 import java.awt.Color;
26
27 public interface FeatureColourI
28 {
29
30   /**
31    * Answers true when the feature colour varies across the score range
32    * 
33    * @return
34    */
35   boolean isGraduatedColour();
36
37   /**
38    * Returns the feature colour (when isGraduatedColour answers false)
39    * 
40    * @return
41    */
42   Color getColour();
43
44   /**
45    * Returns the minimum colour (when isGraduatedColour answers true)
46    * 
47    * @return
48    */
49   Color getMinColour();
50
51   /**
52    * Returns the maximum colour (when isGraduatedColour answers true)
53    * 
54    * @return
55    */
56   Color getMaxColour();
57
58   /**
59    * Answers true if the feature has a single colour, i.e. if isColourByLabel()
60    * and isGraduatedColour() both answer false
61    * 
62    * @return
63    */
64   boolean isSimpleColour();
65
66   /**
67    * Answers true if the feature is coloured by label (description)
68    * 
69    * @return
70    */
71   boolean isColourByLabel();
72
73   void setColourByLabel(boolean b);
74
75   /**
76    * Answers true if the feature is coloured below a threshold value; only
77    * applicable when isGraduatedColour answers true
78    * 
79    * @return
80    */
81   boolean isBelowThreshold();
82
83   void setBelowThreshold(boolean b);
84
85   /**
86    * Answers true if the feature is coloured above a threshold value; only
87    * applicable when isGraduatedColour answers true
88    * 
89    * @return
90    */
91   boolean isAboveThreshold();
92
93   void setAboveThreshold(boolean b);
94
95   /**
96    * Answers true if the threshold is the minimum value (when
97    * isAboveThreshold()) or maximum value (when isBelowThreshold()) of the
98    * colour range; only applicable when isGraduatedColour and either
99    * isAboveThreshold() or isBelowThreshold() answers true
100    * 
101    * @return
102    */
103   boolean isThresholdMinMax();
104
105   void setThresholdMinMax(boolean b);
106
107   /**
108    * Returns the threshold value (if any), else zero
109    * 
110    * @return
111    */
112   float getThreshold();
113
114   void setThreshold(float f);
115
116   /**
117    * Answers true if the colour varies between the actual minimum and maximum
118    * score values of the feature, or false if between absolute minimum and
119    * maximum values (or if not a graduated colour).
120    * 
121    * @return
122    */
123   boolean isAutoScaled();
124
125   void setAutoScaled(boolean b);
126
127   /**
128    * Returns the maximum score of the graduated colour range
129    * 
130    * @return
131    */
132   float getMax();
133
134   /**
135    * Returns the minimum score of the graduated colour range
136    * 
137    * @return
138    */
139   float getMin();
140
141   /**
142    * Answers true if either isAboveThreshold or isBelowThreshold answers true
143    * 
144    * @return
145    */
146   boolean hasThreshold();
147
148   /**
149    * Returns the computed colour for the given sequence feature. Answers null if
150    * the score of this feature instance is outside the range to render (if any),
151    * i.e. lies below or above a configured threshold.
152    * 
153    * @param feature
154    * @return
155    */
156   Color getColor(SequenceFeature feature);
157
158   /**
159    * Update the min-max range for a graduated colour scheme
160    * 
161    * @param min
162    * @param max
163    */
164   void updateBounds(float min, float max);
165
166   /**
167    * Returns the colour in Jalview features file format
168    * 
169    * @return
170    */
171   String toJalviewFormat(String featureType);
172 }