JAL-2438 corrected handling of default colour
[jalview.git] / src / jalview / api / FeatureRenderer.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.datamodel.SequenceI;
25
26 import java.awt.Color;
27 import java.awt.Graphics;
28 import java.util.List;
29 import java.util.Map;
30
31 /**
32  * Abstract feature renderer interface
33  * 
34  * @author JimP
35  * 
36  */
37 public interface FeatureRenderer
38 {
39
40   /**
41    * compute the perceived colour for a given column position in sequenceI,
42    * taking transparency and feature visibility into account.
43    * 
44    * @param sequenceI
45    *          - sequence providing features
46    * @param r
47    *          - column position
48    * @param g
49    * @return
50    */
51   Color findFeatureColour(SequenceI sequenceI, int r, Graphics g);
52
53   /**
54    * trigger the feature discovery process for a newly created feature renderer.
55    */
56   void featuresAdded();
57
58   /**
59    * 
60    * @param ft
61    * @return display style for a feature
62    */
63   FeatureColourI getFeatureStyle(String ft);
64
65   /**
66    * update the feature style for a particular feature
67    * 
68    * @param ft
69    * @param ggc
70    */
71   void setColour(String ft, FeatureColourI ggc);
72
73   AlignViewportI getViewport();
74
75   /**
76    * 
77    * @return container managing list of feature types and their visibility
78    */
79   FeaturesDisplayedI getFeaturesDisplayed();
80
81   /**
82    * get display style for all features types - visible or invisible
83    * 
84    * @return
85    */
86   Map<String, FeatureColourI> getFeatureColours();
87
88   /**
89    * query the alignment view to find all features
90    * 
91    * @param newMadeVisible
92    *          - when true, automatically make newly discovered types visible
93    */
94   void findAllFeatures(boolean newMadeVisible);
95
96   /**
97    * get display style for all features types currently visible
98    * 
99    * @return
100    */
101   Map<String, FeatureColourI> getDisplayedFeatureCols();
102
103   /**
104    * get all registered groups
105    * 
106    * @return
107    */
108   List<String> getFeatureGroups();
109
110   /**
111    * get groups that are visible/invisible
112    * 
113    * @param visible
114    * @return
115    */
116   List<String> getGroups(boolean visible);
117
118   /**
119    * change visibility for a range of groups
120    * 
121    * @param toset
122    * @param visible
123    */
124   void setGroupVisibility(List<String> toset, boolean visible);
125
126   /**
127    * change visibiilty of given group
128    * 
129    * @param group
130    * @param visible
131    */
132   void setGroupVisibility(String group, boolean visible);
133
134   /**
135    * Returns features at the specified position on the given sequence.
136    * Non-positional features are not included.
137    * 
138    * @param sequence
139    * @param res
140    * @return
141    */
142   List<SequenceFeature> findFeaturesAtRes(SequenceI sequence, int res);
143
144   /**
145    * get current displayed types, in ordering of rendering (on top last)
146    * 
147    * @return a (possibly empty) list of feature types
148    */
149
150   List<String> getDisplayedFeatureTypes();
151
152   /**
153    * get current displayed groups
154    * 
155    * @return a (possibly empty) list of feature groups
156    */
157   List<String> getDisplayedFeatureGroups();
158
159   /**
160    * display all features of these types
161    * 
162    * @param featureTypes
163    */
164   void setAllVisible(List<String> featureTypes);
165
166   /**
167    * display featureType
168    * 
169    * @param featureType
170    */
171   void setVisible(String featureType);
172
173   /**
174    * Sets the transparency value, between 0 (full transparency) and 1 (no
175    * transparency)
176    * 
177    * @param value
178    */
179   void setTransparency(float value);
180
181   /**
182    * Returns the transparency value, between 0 (full transparency) and 1 (no
183    * transparency)
184    * 
185    * @return
186    */
187   float getTransparency();
188 }