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