JAL-2808 add attribute filter(s) to FeatureColour
[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 import jalview.util.matcher.KeyedMatcherI;
25
26 import java.awt.Color;
27
28 public interface FeatureColourI
29 {
30
31   /**
32    * Answers true when the feature colour varies across the score range
33    * 
34    * @return
35    */
36   boolean isGraduatedColour();
37
38   /**
39    * Returns the feature colour (when isGraduatedColour answers false)
40    * 
41    * @return
42    */
43   Color getColour();
44
45   /**
46    * Returns the minimum colour (when isGraduatedColour answers true)
47    * 
48    * @return
49    */
50   Color getMinColour();
51
52   /**
53    * Returns the maximum colour (when isGraduatedColour answers true)
54    * 
55    * @return
56    */
57   Color getMaxColour();
58
59   /**
60    * Answers true if the feature has a single colour, i.e. if isColourByLabel()
61    * and isGraduatedColour() both answer false
62    * 
63    * @return
64    */
65   boolean isSimpleColour();
66
67   /**
68    * Answers true if the feature is coloured by label (description)
69    * 
70    * @return
71    */
72   boolean isColourByLabel();
73
74   void setColourByLabel(boolean b);
75
76   /**
77    * Answers true if the feature is coloured below a threshold value; only
78    * applicable when isGraduatedColour answers true
79    * 
80    * @return
81    */
82   boolean isBelowThreshold();
83
84   void setBelowThreshold(boolean b);
85
86   /**
87    * Answers true if the feature is coloured above a threshold value; only
88    * applicable when isGraduatedColour answers true
89    * 
90    * @return
91    */
92   boolean isAboveThreshold();
93
94   void setAboveThreshold(boolean b);
95
96   /**
97    * Answers true if the threshold is the minimum value (when
98    * isAboveThreshold()) or maximum value (when isBelowThreshold()) of the
99    * colour range; only applicable when isGraduatedColour and either
100    * isAboveThreshold() or isBelowThreshold() answers true
101    * 
102    * @return
103    */
104   boolean isThresholdMinMax();
105
106   void setThresholdMinMax(boolean b);
107
108   /**
109    * Returns the threshold value (if any), else zero
110    * 
111    * @return
112    */
113   float getThreshold();
114
115   void setThreshold(float f);
116
117   /**
118    * Answers true if the colour varies between the actual minimum and maximum
119    * score values of the feature, or false if between absolute minimum and
120    * maximum values (or if not a graduated colour).
121    * 
122    * @return
123    */
124   boolean isAutoScaled();
125
126   void setAutoScaled(boolean b);
127
128   /**
129    * Returns the maximum score of the graduated colour range
130    * 
131    * @return
132    */
133   float getMax();
134
135   /**
136    * Returns the minimum score of the graduated colour range
137    * 
138    * @return
139    */
140   float getMin();
141
142   /**
143    * Answers true if either isAboveThreshold or isBelowThreshold answers true
144    * 
145    * @return
146    */
147   boolean hasThreshold();
148
149   /**
150    * Returns the computed colour for the given sequence feature. Answers null if
151    * the score of this feature instance is outside the range to render (if any),
152    * i.e. lies below or above a configured threshold.
153    * 
154    * @param feature
155    * @return
156    */
157   Color getColor(SequenceFeature feature);
158
159   /**
160    * Update the min-max range for a graduated colour scheme
161    * 
162    * @param min
163    * @param max
164    */
165   void updateBounds(float min, float max);
166
167   /**
168    * Returns the colour in Jalview features file format
169    * 
170    * @return
171    */
172   String toJalviewFormat(String featureType);
173
174   /**
175    * Sets the attribute filter conditions, or removes them if the argument is
176    * null
177    * 
178    * @param filter
179    */
180   public void setAttributeFilters(KeyedMatcherI filter);
181
182   /**
183    * Answers the attribute value filters for the colour scheme, or null if no
184    * filters are set
185    * 
186    * @return
187    */
188   public KeyedMatcherI getAttributeFilters();
189 }