2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
23 import jalview.datamodel.MappedFeatures;
24 import jalview.datamodel.SequenceFeature;
25 import jalview.datamodel.SequenceI;
26 import jalview.datamodel.features.FeatureMatcherSetI;
28 import java.awt.Color;
29 import java.awt.Graphics;
30 import java.util.List;
34 * Abstract feature renderer interface
39 public interface FeatureRenderer
43 * Computes the feature colour for a given sequence and column position,
44 * taking into account sequence feature locations, feature colour schemes,
45 * render ordering, feature and feature group visibility, and transparency.
47 * The graphics argument should be provided if transparency is applied
48 * (getTransparency() < 1). With feature transparency, visible features are
49 * written to the graphics context and the composite colour may be read off
50 * from it. In this case, the returned feature colour is not the composite
51 * colour but that of the last feature drawn.
53 * If no transparency applies, then the graphics argument may be null, and the
54 * returned colour is the one that would be drawn for the feature.
56 * Returns null if there is no visible feature at the position.
58 * This is provided to support rendering of feature colours other than on the
59 * sequence alignment, including by structure viewers and the overview window.
60 * Note this method takes no account of whether the sequence or column is
65 * aligned column position (1..)
69 Color findFeatureColour(SequenceI sequence, int column, Graphics g);
72 * trigger the feature discovery process for a newly created feature renderer.
79 * @return display style for a feature
81 FeatureColourI getFeatureStyle(String ft);
84 * update the feature style for a particular feature
89 void setColour(String ft, FeatureColourI ggc);
91 AlignViewportI getViewport();
95 * @return container managing list of feature types and their visibility
97 FeaturesDisplayedI getFeaturesDisplayed();
100 * get display style for all features types - visible or invisible
104 Map<String, FeatureColourI> getFeatureColours();
107 * query the alignment view to find all features
109 * @param newMadeVisible
110 * - when true, automatically make newly discovered types visible
112 void findAllFeatures(boolean newMadeVisible);
115 * get display style for all features types currently visible
119 Map<String, FeatureColourI> getDisplayedFeatureCols();
122 * get all registered groups
126 List<String> getFeatureGroups();
129 * get groups that are visible/invisible
134 List<String> getGroups(boolean visible);
137 * Set visibility for a list of groups
142 void setGroupVisibility(List<String> toset, boolean visible);
145 * Set visibility of the given feature group
150 void setGroupVisibility(String group, boolean visible);
153 * Returns visible features at the specified aligned column on the given
154 * sequence. Non-positional features are not included. If the column has a
155 * gap, then enclosing features are included (but not contact features).
159 * aligned column position (1..)
162 List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence,
166 * Returns features at the specified residue positions on the given sequence.
167 * Non-positional features are not included. Features are returned in render
168 * order of their feature type (last is on top). Within feature type, ordering
176 List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
177 int fromResNo, int toResNo);
180 * get current displayed types, in ordering of rendering (on top last)
182 * @return a (possibly empty) list of feature types
185 List<String> getDisplayedFeatureTypes();
188 * Returns a (possibly empty) list of currently visible feature groups
192 List<String> getDisplayedFeatureGroups();
195 * display all features of these types
197 * @param featureTypes
199 void setAllVisible(List<String> featureTypes);
202 * display featureType
206 void setVisible(String featureType);
209 * Sets the transparency value, between 0 (full transparency) and 1 (no
214 void setTransparency(float value);
217 * Returns the transparency value, between 0 (full transparency) and 1 (no
222 float getTransparency();
225 * Answers the filters applied to the given feature type, or null if none is
231 FeatureMatcherSetI getFeatureFilter(String featureType);
234 * Answers the feature filters map
238 public Map<String, FeatureMatcherSetI> getFeatureFilters();
241 * Sets the filters for the feature type, or removes them if a null or empty
247 void setFeatureFilter(String featureType, FeatureMatcherSetI filter);
250 * Replaces all feature filters with the given map
254 void setFeatureFilters(Map<String, FeatureMatcherSetI> filters);
257 * Returns the colour for a particular feature instance. This includes
258 * calculation of 'colour by label', or of a graduated score colour, if
263 * <li>feature group is not visible, or</li>
264 * <li>feature values lie outside any colour threshold, or</li>
265 * <li>feature is excluded by filter conditions</li>
267 * This method does not check feature type visibility.
272 Color getColour(SequenceFeature feature);
275 * Answers true if feature would be shown, else false. A feature is shown if
277 * <li>its feature type is set to visible</li>
278 * <li>its feature group is either null, or set to visible</li>
279 * <li>it is not excluded by a colour threshold on score or other numeric
281 * <li>it is not excluded by a filter condition</li>
287 boolean isVisible(SequenceFeature feature);
290 * Answers a bean containing a mapping, and a list of visible features in this
291 * alignment at a position (or range) which is mappable from the given
292 * sequence residue position in a mapped alignment. Features are returned in
293 * render order of feature type (on top last), with order within feature type
294 * undefined. If no features or mapping are found, answers null.
300 MappedFeatures findComplementFeaturesAtResidue(SequenceI sequence,
304 * Sends a message to let any registered parties know that something about
305 * feature rendering has changed
307 void notifyFeaturesChanged();