839119ddeff232ff3a0e85383e9389d32b834742
[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    * Returns the combined feature colour for a given sequence and column
42    * position, taking into account feature colour schemes, ordering, feature and
43    * feature group visibility, and transparency. Returns null if there is no
44    * visible feature at the position.
45    * <p>
46    * The Graphics argument is optional and may be null if no transparency is
47    * applied. With feature transparency, visible features are written to the
48    * graphics context and the composite colour can be read off.
49    * <p>
50    * This is provided for use by Structure Viewers and the Overview Window to
51    * get the feature colour of the rendered sequence.
52    * 
53    * @param sequence
54    * @param column
55    * @param g
56    * @return
57    */
58   Color findFeatureColour(SequenceI sequence, int column, Graphics g);
59
60   /**
61    * trigger the feature discovery process for a newly created feature renderer.
62    */
63   void featuresAdded();
64
65   /**
66    * 
67    * @param ft
68    * @return display style for a feature
69    */
70   FeatureColourI getFeatureStyle(String ft);
71
72   /**
73    * update the feature style for a particular feature
74    * 
75    * @param ft
76    * @param ggc
77    */
78   void setColour(String ft, FeatureColourI ggc);
79
80   AlignViewportI getViewport();
81
82   /**
83    * 
84    * @return container managing list of feature types and their visibility
85    */
86   FeaturesDisplayedI getFeaturesDisplayed();
87
88   /**
89    * get display style for all features types - visible or invisible
90    * 
91    * @return
92    */
93   Map<String, FeatureColourI> getFeatureColours();
94
95   /**
96    * query the alignment view to find all features
97    * 
98    * @param newMadeVisible
99    *          - when true, automatically make newly discovered types visible
100    */
101   void findAllFeatures(boolean newMadeVisible);
102
103   /**
104    * get display style for all features types currently visible
105    * 
106    * @return
107    */
108   Map<String, FeatureColourI> getDisplayedFeatureCols();
109
110   /**
111    * get all registered groups
112    * 
113    * @return
114    */
115   List<String> getFeatureGroups();
116
117   /**
118    * get groups that are visible/invisible
119    * 
120    * @param visible
121    * @return
122    */
123   List<String> getGroups(boolean visible);
124
125   /**
126    * change visibility for a range of groups
127    * 
128    * @param toset
129    * @param visible
130    */
131   void setGroupVisibility(List<String> toset, boolean visible);
132
133   /**
134    * change visibiilty of given group
135    * 
136    * @param group
137    * @param visible
138    */
139   void setGroupVisibility(String group, boolean visible);
140
141   /**
142    * Returns features at the specified position on the given sequence.
143    * Non-positional features are not included.
144    * 
145    * @param sequence
146    * @param res
147    * @return
148    */
149   List<SequenceFeature> findFeaturesAtRes(SequenceI sequence, int res);
150
151   /**
152    * get current displayed types, in ordering of rendering (on top last)
153    * 
154    * @return a (possibly empty) list of feature types
155    */
156
157   List<String> getDisplayedFeatureTypes();
158
159   /**
160    * get current displayed groups
161    * 
162    * @return a (possibly empty) list of feature groups
163    */
164   List<String> getDisplayedFeatureGroups();
165
166   /**
167    * display all features of these types
168    * 
169    * @param featureTypes
170    */
171   void setAllVisible(List<String> featureTypes);
172
173   /**
174    * display featureType
175    * 
176    * @param featureType
177    */
178   void setVisible(String featureType);
179
180   /**
181    * Sets the transparency value, between 0 (full transparency) and 1 (no
182    * transparency)
183    * 
184    * @param value
185    */
186   void setTransparency(float value);
187
188   /**
189    * Returns the transparency value, between 0 (full transparency) and 1 (no
190    * transparency)
191    * 
192    * @return
193    */
194   float getTransparency();
195 }