93773ccb283fb31bf16c5650ee8df139ef2cde2e
[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    * Returns the 'no value' colour (used when a feature lacks score, or the
60    * attribute, being used for colouring)
61    * 
62    * @return
63    */
64   Color getNoColour();
65
66   /**
67    * Answers true if the feature has a single colour, i.e. if isColourByLabel()
68    * and isGraduatedColour() both answer false
69    * 
70    * @return
71    */
72   boolean isSimpleColour();
73
74   /**
75    * Answers true if the feature is coloured by label (description)
76    * 
77    * @return
78    */
79   boolean isColourByLabel();
80
81   void setColourByLabel(boolean b);
82
83   /**
84    * Answers true if the feature is coloured below a threshold value; only
85    * applicable when isGraduatedColour answers true
86    * 
87    * @return
88    */
89   boolean isBelowThreshold();
90
91   void setBelowThreshold(boolean b);
92
93   /**
94    * Answers true if the feature is coloured above a threshold value; only
95    * applicable when isGraduatedColour answers true
96    * 
97    * @return
98    */
99   boolean isAboveThreshold();
100
101   void setAboveThreshold(boolean b);
102
103   /**
104    * Answers true if the threshold is the minimum value (when
105    * isAboveThreshold()) or maximum value (when isBelowThreshold()) of the
106    * colour range; only applicable when isGraduatedColour and either
107    * isAboveThreshold() or isBelowThreshold() answers true
108    * 
109    * @return
110    */
111   boolean isThresholdMinMax();
112
113   void setThresholdMinMax(boolean b);
114
115   /**
116    * Returns the threshold value (if any), else zero
117    * 
118    * @return
119    */
120   float getThreshold();
121
122   void setThreshold(float f);
123
124   /**
125    * Answers true if the colour varies between the actual minimum and maximum
126    * score values of the feature, or false if between absolute minimum and
127    * maximum values (or if not a graduated colour).
128    * 
129    * @return
130    */
131   boolean isAutoScaled();
132
133   void setAutoScaled(boolean b);
134
135   /**
136    * Returns the maximum score of the graduated colour range
137    * 
138    * @return
139    */
140   float getMax();
141
142   /**
143    * Returns the minimum score of the graduated colour range
144    * 
145    * @return
146    */
147   float getMin();
148
149   /**
150    * Answers true if either isAboveThreshold or isBelowThreshold answers true
151    * 
152    * @return
153    */
154   boolean hasThreshold();
155
156   /**
157    * Returns the computed colour for the given sequence feature. Answers null if
158    * the score of this feature instance is outside the range to render (if any),
159    * i.e. lies below or above a configured threshold.
160    * 
161    * @param feature
162    * @return
163    */
164   Color getColor(SequenceFeature feature);
165
166   /**
167    * Update the min-max range for a graduated colour scheme. Note that the
168    * colour scheme may be configured to colour by feature score, or a
169    * (numeric-valued) attribute - the caller should ensure that the correct
170    * range is being set.
171    * 
172    * @param min
173    * @param max
174    */
175   void updateBounds(float min, float max);
176
177   /**
178    * Returns the colour in Jalview features file format
179    * 
180    * @return
181    */
182   String toJalviewFormat(String featureType);
183
184   /**
185    * Answers true if colour is by attribute text or numerical value
186    * 
187    * @return
188    */
189   boolean isColourByAttribute();
190
191   /**
192    * Answers the name of the attribute (and optional sub-attribute...) used for
193    * colouring if any, or null
194    * 
195    * @return
196    */
197   String[] getAttributeName();
198
199   /**
200    * Sets the name of the attribute (and optional sub-attribute...) used for
201    * colouring if any, or null to remove this property
202    * 
203    * @return
204    */
205   void setAttributeName(String... name);
206 }