JAL-2069 spike updated with latest (FeatureTypeSettings)
[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    * Returns the threshold value (if any), else zero
105    * 
106    * @return
107    */
108   float getThreshold();
109
110   void setThreshold(float f);
111
112   /**
113    * Answers true if the colour varies between the actual minimum and maximum
114    * score values of the feature, or false if between absolute minimum and
115    * maximum values (or if not a graduated colour).
116    * 
117    * @return
118    */
119   boolean isAutoScaled();
120
121   void setAutoScaled(boolean b);
122
123   /**
124    * Returns the maximum score of the graduated colour range
125    * 
126    * @return
127    */
128   float getMax();
129
130   /**
131    * Returns the minimum score of the graduated colour range
132    * 
133    * @return
134    */
135   float getMin();
136
137   /**
138    * Answers true if either isAboveThreshold or isBelowThreshold answers true
139    * 
140    * @return
141    */
142   boolean hasThreshold();
143
144   /**
145    * Returns the computed colour for the given sequence feature. Answers null if
146    * the score of this feature instance is outside the range to render (if any),
147    * i.e. lies below or above a configured threshold.
148    * 
149    * @param feature
150    * @return
151    */
152   Color getColor(SequenceFeature feature);
153
154   /**
155    * Update the min-max range for a graduated colour scheme. Note that the
156    * colour scheme may be configured to colour by feature score, or a
157    * (numeric-valued) attribute - the caller should ensure that the correct
158    * range is being set.
159    * 
160    * @param min
161    * @param max
162    */
163   void updateBounds(float min, float max);
164
165   /**
166    * Returns the colour in Jalview features file format
167    * 
168    * @return
169    */
170   String toJalviewFormat(String featureType);
171
172   /**
173    * Answers true if colour is by attribute text or numerical value
174    * 
175    * @return
176    */
177   boolean isColourByAttribute();
178
179   /**
180    * Answers the name of the attribute (and optional sub-attribute...) used for
181    * colouring if any, or null
182    * 
183    * @return
184    */
185   String[] getAttributeName();
186
187   /**
188    * Sets the name of the attribute (and optional sub-attribute...) used for
189    * colouring if any, or null to remove this property
190    * 
191    * @return
192    */
193   void setAttributeName(String... name);
194 }