0d0adaa333c678b460c0761259a07dfe652846ca
[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.util.List;
28 import java.util.Map;
29
30 /**
31  * Abstract feature renderer interface
32  * 
33  * @author JimP
34  * 
35  */
36 public interface FeatureRenderer
37 {
38
39   /**
40    * compute the perceived colour for a given column position in sequenceI,
41    * taking transparency and feature visibility into account.
42    * 
43    * @param col
44    *          - background colour (due to alignment/group shading schemes, etc).
45    * @param sequenceI
46    *          - sequence providing features
47    * @param r
48    *          - column position
49    * @return
50    */
51   Color findFeatureColour(Color col, SequenceI sequenceI, int r);
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   Object getFeatureStyle(String ft);
64
65   /**
66    * update the feature style for a particular feature
67    * 
68    * @param ft
69    * @param ggc
70    *          - currently allows java.awt.Color and
71    *          jalview.schemes.GraduatedColor
72    */
73   void setColour(String ft, Object ggc);
74
75   AlignViewportI getViewport();
76
77   /**
78    * 
79    * @return container managing list of feature types and their visibility
80    */
81   FeaturesDisplayedI getFeaturesDisplayed();
82
83   /**
84    * get display style for all features types - visible or invisible
85    * 
86    * @return
87    */
88   Map<String, Object> getFeatureColours();
89
90   /**
91    * query the alignment view to find all features
92    * 
93    * @param newMadeVisible
94    *          - when true, automatically make newly discovered types visible
95    */
96   void findAllFeatures(boolean newMadeVisible);
97
98   /**
99    * get display style for all features types currently visible
100    * 
101    * @return
102    */
103   Map<String, Object> getDisplayedFeatureCols();
104
105   /**
106    * get all registered groups
107    * 
108    * @return
109    */
110   List<String> getFeatureGroups();
111
112   /**
113    * get groups that are visible/invisible
114    * 
115    * @param visible
116    * @return
117    */
118   List<String> getGroups(boolean visible);
119
120   /**
121    * change visibility for a range of groups
122    * 
123    * @param toset
124    * @param visible
125    */
126   void setGroupVisibility(List<String> toset, boolean visible);
127
128   /**
129    * change visibiilty of given group
130    * 
131    * @param group
132    * @param visible
133    */
134   void setGroupVisibility(String group, boolean visible);
135
136   /**
137    * locate features at a particular position on the given sequence
138    * 
139    * @param sequence
140    * @param res
141    * @return
142    */
143   List<SequenceFeature> findFeaturesAtRes(SequenceI sequence, int res);
144
145   /**
146    * 
147    * @return true if the rendering platform supports transparency
148    */
149   boolean isTransparencyAvailable();
150
151   /**
152    * get current displayed types
153    * 
154    * @return
155    */
156
157   String[] getDisplayedFeatureTypes();
158
159   /**
160    * get current displayed groups
161    * 
162    * @return
163    */
164   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 }