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 java.awt.Color;
24 import java.awt.Graphics;
25 import java.beans.PropertyChangeListener;
26 import java.util.List;
29 import jalview.datamodel.MappedFeatures;
30 import jalview.datamodel.SequenceFeature;
31 import jalview.datamodel.SequenceI;
32 import jalview.datamodel.features.FeatureMatcherSetI;
35 * Abstract feature renderer interface
40 public interface FeatureRenderer
44 * Computes the feature colour for a given sequence and column position,
45 * taking into account sequence feature locations, feature colour schemes,
46 * render ordering, feature and feature group visibility, and transparency.
48 * The graphics argument should be provided if transparency is applied
49 * (getTransparency() < 1). With feature transparency, visible features are
50 * written to the graphics context and the composite colour may be read off
51 * from it. In this case, the returned feature colour is not the composite
52 * colour but that of the last feature drawn.
54 * If no transparency applies, then the graphics argument may be null, and the
55 * returned colour is the one that would be drawn for the feature.
57 * Returns null if there is no visible feature at the position.
59 * This is provided to support rendering of feature colours other than on the
60 * sequence alignment, including by structure viewers and the overview window.
61 * Note this method takes no account of whether the sequence or column is
66 * aligned column position (1..)
70 Color findFeatureColour(SequenceI sequence, int column, Graphics g);
73 * trigger the feature discovery process for a newly created feature renderer.
80 * @return display style for a feature
82 FeatureColourI getFeatureStyle(String ft);
85 * update the feature style for a particular feature
90 void setColour(String ft, FeatureColourI ggc);
92 AlignViewportI getViewport();
96 * @return container managing list of feature types and their visibility
98 FeaturesDisplayedI getFeaturesDisplayed();
101 * get display style for all features types - visible or invisible
105 Map<String, FeatureColourI> getFeatureColours();
108 * query the alignment view to find all features
110 * @param newMadeVisible
111 * - when true, automatically make newly discovered types visible
113 void findAllFeatures(boolean newMadeVisible);
116 * get display style for all features types currently visible
120 Map<String, FeatureColourI> getDisplayedFeatureCols();
123 * get all registered groups
127 List<String> getFeatureGroups();
130 * get groups that are visible/invisible
135 List<String> getGroups(boolean visible);
138 * Set visibility for a list of groups
143 void setGroupVisibility(List<String> toset, boolean visible);
146 * Set visibility of the given feature group
151 void setGroupVisibility(String group, boolean visible);
154 * Returns visible features at the specified aligned column on the given
155 * sequence. Non-positional features are not included. If the column has a
156 * gap, then enclosing features are included (but not contact features).
160 * aligned column position (1..)
163 List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence,
167 * Returns features at the specified residue positions on the given sequence.
168 * Non-positional features are not included. Features are returned in render
169 * order of their feature type (last is on top). Within feature type, ordering
177 List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
178 int fromResNo, int toResNo);
181 * get current displayed types, in ordering of rendering (on top last)
183 * @return a (possibly empty) list of feature types
186 List<String> getDisplayedFeatureTypes();
189 * Returns a (possibly empty) list of currently visible feature groups
193 List<String> getDisplayedFeatureGroups();
196 * display all features of these types
198 * @param featureTypes
200 void setAllVisible(List<String> featureTypes);
203 * display featureType
207 void setVisible(String featureType);
210 * Sets the transparency value, between 0 (full transparency) and 1 (no
215 void setTransparency(float value);
218 * Returns the transparency value, between 0 (full transparency) and 1 (no
223 float getTransparency();
226 * Answers the filters applied to the given feature type, or null if none is
232 FeatureMatcherSetI getFeatureFilter(String featureType);
235 * Answers the feature filters map
239 public Map<String, FeatureMatcherSetI> getFeatureFilters();
242 * Sets the filters for the feature type, or removes them if a null or empty
248 void setFeatureFilter(String featureType, FeatureMatcherSetI filter);
251 * Replaces all feature filters with the given map
255 void setFeatureFilters(Map<String, FeatureMatcherSetI> filters);
258 * Returns the colour for a particular feature instance. This includes
259 * calculation of 'colour by label', or of a graduated score colour, if
264 * <li>feature group is not visible, or</li>
265 * <li>feature values lie outside any colour threshold, or</li>
266 * <li>feature is excluded by filter conditions</li>
268 * This method does not check feature type visibility.
273 Color getColour(SequenceFeature feature);
276 * Answers true if feature would be shown, else false. A feature is shown if
278 * <li>its feature type is set to visible</li>
279 * <li>its feature group is either null, or set to visible</li>
280 * <li>it is not excluded by a colour threshold on score or other numeric
282 * <li>it is not excluded by a filter condition</li>
288 boolean isVisible(SequenceFeature feature);
291 * Answers a bean containing a mapping, and a list of visible features in this
292 * alignment at a position (or range) which is mappable from the given
293 * sequence residue position in a mapped alignment. Features are returned in
294 * render order of feature type (on top last), with order within feature type
295 * undefined. If no features or mapping are found, answers null.
301 MappedFeatures findComplementFeaturesAtResidue(SequenceI sequence,
305 * Sends a message to let any registered parties know that something about
306 * feature rendering has changed
308 void notifyFeaturesChanged();
311 * register as a listener for notifyFeaturesChanged events
315 void addPropertyChangeListener(PropertyChangeListener ourListener);
318 * remove a listener for notifyFeaturesChanged events
322 void removePropertyChangeListener(PropertyChangeListener ourListener);
326 * @return associated alignment panel for this feature renderer (may return
329 AlignmentViewPanel getAlignPanel();