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.
21 package jalview.viewmodel.seqfeatures;
23 import jalview.api.AlignViewportI;
24 import jalview.api.FeatureColourI;
25 import jalview.api.FeaturesDisplayedI;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.SequenceFeature;
28 import jalview.datamodel.SequenceI;
29 import jalview.datamodel.features.FeatureMatcherSetI;
30 import jalview.datamodel.features.SequenceFeatures;
31 import jalview.renderer.seqfeatures.FeatureRenderer;
32 import jalview.schemes.FeatureColour;
33 import jalview.util.ColorUtils;
35 import java.awt.Color;
36 import java.beans.PropertyChangeListener;
37 import java.beans.PropertyChangeSupport;
38 import java.util.ArrayList;
39 import java.util.Arrays;
40 import java.util.Comparator;
41 import java.util.HashMap;
42 import java.util.HashSet;
43 import java.util.Hashtable;
44 import java.util.Iterator;
45 import java.util.List;
48 import java.util.concurrent.ConcurrentHashMap;
50 public abstract class FeatureRendererModel
51 implements jalview.api.FeatureRenderer
54 * a data bean to hold one row of feature settings from the gui
56 public static class FeatureSettingsBean
58 public final String featureType;
60 public final FeatureColourI featureColour;
62 public final FeatureMatcherSetI filter;
64 public final Boolean show;
66 public FeatureSettingsBean(String type, FeatureColourI colour,
67 FeatureMatcherSetI theFilter, Boolean isShown)
70 featureColour = colour;
77 * global transparency for feature
79 protected float transparency = 1.0f;
82 * colour scheme for each feature type
84 protected Map<String, FeatureColourI> featureColours = new ConcurrentHashMap<>();
87 * visibility flag for each feature group
89 protected Map<String, Boolean> featureGroups = new ConcurrentHashMap<>();
92 * filters for each feature type
94 protected Map<String, FeatureMatcherSetI> featureFilters = new HashMap<>();
96 protected String[] renderOrder;
98 Map<String, Float> featureOrder = null;
100 protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
103 protected AlignViewportI av;
106 public AlignViewportI getViewport()
111 public FeatureRendererSettings getSettings()
113 return new FeatureRendererSettings(this);
116 public void transferSettings(FeatureRendererSettings fr)
118 this.renderOrder = fr.renderOrder;
119 this.featureGroups = fr.featureGroups;
120 this.featureColours = fr.featureColours;
121 this.transparency = fr.transparency;
122 this.featureOrder = fr.featureOrder;
126 * update from another feature renderer
131 public void transferSettings(jalview.api.FeatureRenderer _fr)
133 FeatureRenderer fr = (FeatureRenderer) _fr;
134 FeatureRendererSettings frs = new FeatureRendererSettings(fr);
135 this.renderOrder = frs.renderOrder;
136 this.featureGroups = frs.featureGroups;
137 this.featureColours = frs.featureColours;
138 this.featureFilters = frs.featureFilters;
139 this.transparency = frs.transparency;
140 this.featureOrder = frs.featureOrder;
141 if (av != null && av != fr.getViewport())
143 // copy over the displayed feature settings
144 if (_fr.getFeaturesDisplayed() != null)
146 FeaturesDisplayedI fd = getFeaturesDisplayed();
149 setFeaturesDisplayedFrom(_fr.getFeaturesDisplayed());
156 for (String type : _fr.getFeaturesDisplayed()
157 .getVisibleFeatures())
167 public void setFeaturesDisplayedFrom(FeaturesDisplayedI featuresDisplayed)
169 av.setFeaturesDisplayed(new FeaturesDisplayed(featuresDisplayed));
173 public void setVisible(String featureType)
175 FeaturesDisplayedI fdi = av.getFeaturesDisplayed();
178 av.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
180 if (!fdi.isRegistered(featureType))
182 pushFeatureType(Arrays.asList(new String[] { featureType }));
184 fdi.setVisible(featureType);
188 public void setAllVisible(List<String> featureTypes)
190 FeaturesDisplayedI fdi = av.getFeaturesDisplayed();
193 av.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
195 List<String> nft = new ArrayList<>();
196 for (String featureType : featureTypes)
198 if (!fdi.isRegistered(featureType))
200 nft.add(featureType);
205 pushFeatureType(nft);
207 fdi.setAllVisible(featureTypes);
211 * push a set of new types onto the render order stack. Note - this is a
212 * direct mechanism rather than the one employed in updateRenderOrder
216 private void pushFeatureType(List<String> types)
219 int ts = types.size();
220 String neworder[] = new String[(renderOrder == null ? 0
221 : renderOrder.length) + ts];
222 types.toArray(neworder);
223 if (renderOrder != null)
225 System.arraycopy(neworder, 0, neworder, renderOrder.length, ts);
226 System.arraycopy(renderOrder, 0, neworder, 0, renderOrder.length);
228 renderOrder = neworder;
231 protected Map<String, float[][]> minmax = new Hashtable<>();
233 public Map<String, float[][]> getMinMax()
239 * normalise a score against the max/min bounds for the feature type.
241 * @param sequenceFeature
242 * @return byte[] { signed, normalised signed (-127 to 127) or unsigned
245 protected final byte[] normaliseScore(SequenceFeature sequenceFeature)
247 float[] mm = minmax.get(sequenceFeature.type)[0];
248 final byte[] r = new byte[] { 0, (byte) 255 };
251 if (r[0] != 0 || mm[0] < 0.0)
254 r[1] = (byte) ((int) 128.0
255 + 127.0 * (sequenceFeature.score / mm[1]));
259 r[1] = (byte) ((int) 255.0 * (sequenceFeature.score / mm[1]));
265 boolean newFeatureAdded = false;
267 boolean findingFeatures = false;
271 protected boolean updateFeatures()
273 if (av.getFeaturesDisplayed() == null || renderOrder == null
276 System.out.println("updateFeatures " + ++nup);
278 if (av.getFeaturesDisplayed().getVisibleFeatureCount() < 1)
283 // TODO: decide if we should check for the visible feature count first
288 * search the alignment for all new features, give them a colour and display
289 * them. Then fires a PropertyChangeEvent on the changeSupport object.
292 protected void findAllFeatures()
294 synchronized (firing)
296 if (firing.equals(Boolean.FALSE))
298 firing = Boolean.TRUE;
299 findAllFeatures(true); // add all new features as visible
300 changeSupport.firePropertyChange("changeSupport", null, null);
301 firing = Boolean.FALSE;
307 public List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column)
310 * include features at the position provided their feature type is
311 * displayed, and feature group is null or marked for display
313 List<SequenceFeature> result = new ArrayList<>();
314 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
319 Set<String> visibleFeatures = getFeaturesDisplayed()
320 .getVisibleFeatures();
321 String[] visibleTypes = visibleFeatures
322 .toArray(new String[visibleFeatures.size()]);
323 List<SequenceFeature> features = sequence.findFeatures(column, column,
327 * include features unless their feature group is not displayed, or
328 * they are hidden (have no colour) based on a filter or colour threshold
330 for (SequenceFeature sf : features)
332 if (!featureGroupNotShown(sf) && getColour(sf) != null)
341 * Searches alignment for all features and updates colours
343 * @param newMadeVisible
344 * if true newly added feature types will be rendered immediately
345 * TODO: check to see if this method should actually be proxied so
346 * repaint events can be propagated by the renderer code
349 public synchronized void findAllFeatures(boolean newMadeVisible)
351 newFeatureAdded = false;
355 newFeatureAdded = true;
359 findingFeatures = true;
360 if (av.getFeaturesDisplayed() == null)
362 av.setFeaturesDisplayed(new FeaturesDisplayed());
364 FeaturesDisplayedI featuresDisplayed = av.getFeaturesDisplayed();
366 Set<String> oldfeatures = new HashSet<>();
367 if (renderOrder != null)
369 for (int i = 0; i < renderOrder.length; i++)
371 if (renderOrder[i] != null)
373 oldfeatures.add(renderOrder[i]);
378 AlignmentI alignment = av.getAlignment();
379 List<String> allfeatures = new ArrayList<>();
381 for (int i = 0; i < alignment.getHeight(); i++)
383 SequenceI asq = alignment.getSequenceAt(i);
384 for (String group : asq.getFeatures().getFeatureGroups(true))
386 boolean groupDisplayed = true;
389 if (featureGroups.containsKey(group))
391 groupDisplayed = featureGroups.get(group);
395 groupDisplayed = newMadeVisible;
396 featureGroups.put(group, groupDisplayed);
401 Set<String> types = asq.getFeatures().getFeatureTypesForGroups(
403 for (String type : types)
405 if (!allfeatures.contains(type)) // or use HashSet and no test?
407 allfeatures.add(type);
409 updateMinMax(asq, type, true); // todo: for all features?
415 // uncomment to add new features in alphebetical order (but JAL-2575)
416 // Collections.sort(allfeatures, String.CASE_INSENSITIVE_ORDER);
419 for (String type : allfeatures)
421 if (!oldfeatures.contains(type))
423 featuresDisplayed.setVisible(type);
429 updateRenderOrder(allfeatures);
430 findingFeatures = false;
434 * Updates the global (alignment) min and max values for a feature type from
435 * the score for a sequence, if the score is not NaN. Values are stored
436 * separately for positional and non-positional features.
442 protected void updateMinMax(SequenceI seq, String featureType,
445 float min = seq.getFeatures().getMinimumScore(featureType, positional);
446 if (Float.isNaN(min))
451 float max = seq.getFeatures().getMaximumScore(featureType, positional);
455 * { {positionalMin, positionalMax}, {nonPositionalMin, nonPositionalMax} }
459 minmax = new Hashtable<>();
461 synchronized (minmax)
463 float[][] mm = minmax.get(featureType);
464 int index = positional ? 0 : 1;
467 mm = new float[][] { null, null };
468 minmax.put(featureType, mm);
470 if (mm[index] == null)
472 mm[index] = new float[] { min, max };
476 mm[index][0] = Math.min(mm[index][0], min);
477 mm[index][1] = Math.max(mm[index][1], max);
481 protected Boolean firing = Boolean.FALSE;
484 * replaces the current renderOrder with the unordered features in
485 * allfeatures. The ordering of any types in both renderOrder and allfeatures
486 * is preserved, and all new feature types are rendered on top of the existing
487 * types, in the order given by getOrder or the order given in allFeatures.
488 * Note. this operates directly on the featureOrder hash for efficiency. TODO:
489 * eliminate the float storage for computing/recalling the persistent ordering
490 * New Cability: updates min/max for colourscheme range if its dynamic
494 private void updateRenderOrder(List<String> allFeatures)
496 List<String> allfeatures = new ArrayList<>(allFeatures);
497 String[] oldRender = renderOrder;
498 renderOrder = new String[allfeatures.size()];
499 boolean initOrders = (featureOrder == null);
501 if (oldRender != null && oldRender.length > 0)
503 for (int j = 0; j < oldRender.length; j++)
505 if (oldRender[j] != null)
509 setOrder(oldRender[j],
510 (1 - (1 + (float) j) / oldRender.length));
512 if (allfeatures.contains(oldRender[j]))
514 renderOrder[opos++] = oldRender[j]; // existing features always
515 // appear below new features
516 allfeatures.remove(oldRender[j]);
519 float[][] mmrange = minmax.get(oldRender[j]);
522 FeatureColourI fc = featureColours.get(oldRender[j]);
523 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
524 && !fc.isColourByAttribute())
526 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
534 if (allfeatures.size() == 0)
536 // no new features - leave order unchanged.
539 int i = allfeatures.size() - 1;
541 boolean sort = false;
542 String[] newf = new String[allfeatures.size()];
543 float[] sortOrder = new float[allfeatures.size()];
544 for (String newfeat : allfeatures)
549 // update from new features minmax if necessary
550 float[][] mmrange = minmax.get(newf[i]);
553 FeatureColourI fc = featureColours.get(newf[i]);
554 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
555 && !fc.isColourByAttribute())
557 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
561 if (initOrders || !featureOrder.containsKey(newf[i]))
563 int denom = initOrders ? allfeatures.size() : featureOrder.size();
564 // new unordered feature - compute persistent ordering at head of
565 // existing features.
566 setOrder(newf[i], i / (float) denom);
568 // set order from newly found feature from persisted ordering.
569 sortOrder[i] = 2 - featureOrder.get(newf[i]).floatValue();
572 // only sort if we need to
573 sort = sort || sortOrder[i] > sortOrder[i + 1];
577 if (iSize > 1 && sort)
579 jalview.util.QuickSort.sort(sortOrder, newf);
582 System.arraycopy(newf, 0, renderOrder, opos, newf.length);
586 * get a feature style object for the given type string. Creates a
587 * java.awt.Color for a featureType with no existing colourscheme.
593 public FeatureColourI getFeatureStyle(String featureType)
595 FeatureColourI fc = featureColours.get(featureType);
598 Color col = ColorUtils.createColourFromName(featureType);
599 fc = new FeatureColour(col);
600 featureColours.put(featureType, fc);
606 public Color getColour(SequenceFeature feature)
608 FeatureColourI fc = getFeatureStyle(feature.getType());
609 return getColor(feature, fc);
613 * Answers true if the feature type is currently selected to be displayed,
619 public boolean showFeatureOfType(String type)
621 return type == null ? false : (av.getFeaturesDisplayed() == null ? true
622 : av.getFeaturesDisplayed().isVisible(type));
626 public void setColour(String featureType, FeatureColourI col)
628 featureColours.put(featureType, col);
632 public void setTransparency(float value)
634 transparency = value;
638 public float getTransparency()
644 * analogous to colour - store a normalized ordering for all feature types in
645 * this rendering context.
648 * Feature type string
650 * normalized priority - 0 means always appears on top, 1 means
653 public float setOrder(String type, float position)
655 if (featureOrder == null)
657 featureOrder = new Hashtable<>();
659 featureOrder.put(type, new Float(position));
664 * get the global priority (0 (top) to 1 (bottom))
667 * @return [0,1] or -1 for a type without a priority
669 public float getOrder(String type)
671 if (featureOrder != null)
673 if (featureOrder.containsKey(type))
675 return featureOrder.get(type).floatValue();
682 public Map<String, FeatureColourI> getFeatureColours()
684 return featureColours;
688 * Replace current ordering with new ordering
691 * an array of { Type, Colour, Filter, Boolean }
692 * @return true if any visible features have been reordered, else false
694 public boolean setFeaturePriority(FeatureSettingsBean[] data)
696 return setFeaturePriority(data, true);
700 * Sets the priority order for features, with the highest priority (displayed on
701 * top) at the start of the data array
704 * an array of { Type, Colour, Filter, Boolean }
706 * when true current featureDisplay list will be cleared
707 * @return true if any visible features have been reordered or recoloured, else
708 * false (i.e. no need to repaint)
710 public boolean setFeaturePriority(FeatureSettingsBean[] data,
714 * note visible feature ordering and colours before update
716 List<String> visibleFeatures = getDisplayedFeatureTypes();
717 Map<String, FeatureColourI> visibleColours = new HashMap<>(
718 getFeatureColours());
720 FeaturesDisplayedI av_featuresdisplayed = null;
723 if ((av_featuresdisplayed = av.getFeaturesDisplayed()) != null)
725 av.getFeaturesDisplayed().clear();
729 av.setFeaturesDisplayed(
730 av_featuresdisplayed = new FeaturesDisplayed());
735 av_featuresdisplayed = av.getFeaturesDisplayed();
741 // The feature table will display high priority
742 // features at the top, but these are the ones
743 // we need to render last, so invert the data
744 renderOrder = new String[data.length];
748 for (int i = 0; i < data.length; i++)
750 String type = data[i].featureType;
751 setColour(type, data[i].featureColour);
754 av_featuresdisplayed.setVisible(type);
757 renderOrder[data.length - i - 1] = type;
762 * get the new visible ordering and return true if it has changed
763 * order or any colour has changed
765 List<String> reorderedVisibleFeatures = getDisplayedFeatureTypes();
766 if (!visibleFeatures.equals(reorderedVisibleFeatures))
769 * the list of ordered visible features has changed
775 * return true if any feature colour has changed
777 for (String feature : visibleFeatures)
779 if (visibleColours.get(feature) != getFeatureStyle(feature))
789 * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
791 public void addPropertyChangeListener(PropertyChangeListener listener)
793 changeSupport.addPropertyChangeListener(listener);
798 * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
800 public void removePropertyChangeListener(PropertyChangeListener listener)
802 changeSupport.removePropertyChangeListener(listener);
805 public Set<String> getAllFeatureColours()
807 return featureColours.keySet();
810 public void clearRenderOrder()
815 public boolean hasRenderOrder()
817 return renderOrder != null;
821 * Returns feature types in ordering of rendering, where last means on top
823 public List<String> getRenderOrder()
825 if (renderOrder == null)
827 return Arrays.asList(new String[] {});
829 return Arrays.asList(renderOrder);
832 public int getFeatureGroupsSize()
834 return featureGroups != null ? 0 : featureGroups.size();
838 public List<String> getFeatureGroups()
840 // conflict between applet and desktop - featureGroups returns the map in
841 // the desktop featureRenderer
842 return (featureGroups == null) ? Arrays.asList(new String[0])
843 : Arrays.asList(featureGroups.keySet().toArray(new String[0]));
846 public boolean checkGroupVisibility(String group,
847 boolean newGroupsVisible)
849 if (featureGroups == null)
851 // then an exception happens next..
853 if (featureGroups.containsKey(group))
855 return featureGroups.get(group).booleanValue();
857 if (newGroupsVisible)
859 featureGroups.put(group, new Boolean(true));
866 * get visible or invisible groups
869 * true to return visible groups, false to return hidden ones.
870 * @return list of groups
873 public List<String> getGroups(boolean visible)
875 if (featureGroups != null)
877 List<String> gp = new ArrayList<>();
879 for (String grp : featureGroups.keySet())
881 Boolean state = featureGroups.get(grp);
882 if (state.booleanValue() == visible)
893 public void setGroupVisibility(String group, boolean visible)
895 featureGroups.put(group, new Boolean(visible));
899 public void setGroupVisibility(List<String> toset, boolean visible)
901 if (toset != null && toset.size() > 0 && featureGroups != null)
903 boolean rdrw = false;
904 for (String gst : toset)
906 Boolean st = featureGroups.get(gst);
907 featureGroups.put(gst, new Boolean(visible));
910 rdrw = rdrw || (visible != st.booleanValue());
915 // set local flag indicating redraw needed ?
921 public Map<String, FeatureColourI> getDisplayedFeatureCols()
923 Map<String, FeatureColourI> fcols = new Hashtable<>();
924 if (getViewport().getFeaturesDisplayed() == null)
928 Set<String> features = getViewport().getFeaturesDisplayed()
929 .getVisibleFeatures();
930 for (String feature : features)
932 fcols.put(feature, getFeatureStyle(feature));
938 public FeaturesDisplayedI getFeaturesDisplayed()
940 return av.getFeaturesDisplayed();
944 * Returns a (possibly empty) list of visible feature types, in render order
948 public List<String> getDisplayedFeatureTypes()
950 List<String> typ = getRenderOrder();
951 List<String> displayed = new ArrayList<>();
952 FeaturesDisplayedI feature_disp = av.getFeaturesDisplayed();
953 if (feature_disp != null)
955 synchronized (feature_disp)
957 for (String type : typ)
959 if (feature_disp.isVisible(type))
970 public List<String> getDisplayedFeatureGroups()
972 List<String> _gps = new ArrayList<>();
973 for (String gp : getFeatureGroups())
975 if (checkGroupVisibility(gp, false))
984 * Answers true if the feature belongs to a feature group which is not
985 * currently displayed, else false
987 * @param sequenceFeature
990 protected boolean featureGroupNotShown(final SequenceFeature sequenceFeature)
992 return featureGroups != null
993 && sequenceFeature.featureGroup != null
994 && sequenceFeature.featureGroup.length() != 0
995 && featureGroups.containsKey(sequenceFeature.featureGroup)
996 && !featureGroups.get(sequenceFeature.featureGroup)
1004 public List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
1007 List<SequenceFeature> result = new ArrayList<>();
1008 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
1014 * include features at the position provided their feature type is
1015 * displayed, and feature group is null or the empty string
1016 * or marked for display
1018 Set<String> visibleFeatures = getFeaturesDisplayed()
1019 .getVisibleFeatures();
1020 String[] visibleTypes = visibleFeatures
1021 .toArray(new String[visibleFeatures.size()]);
1022 List<SequenceFeature> features = sequence.getFeatures().findFeatures(
1023 resNo, resNo, visibleTypes);
1025 for (SequenceFeature sf : features)
1027 if (!featureGroupNotShown(sf) && getColour(sf) != null)
1036 * Removes from the list of features any whose group is not shown, or that are
1037 * visible and duplicate the location of a visible feature of the same type.
1038 * Should be used only for features of the same, simple, feature colour (which
1039 * normally implies the same feature type). No filtering is done if
1040 * transparency, or any feature filters, are in force.
1044 public void filterFeaturesForDisplay(List<SequenceFeature> features)
1047 * don't remove 'redundant' features if
1048 * - transparency is applied (feature count affects depth of feature colour)
1049 * - filters are applied (not all features may be displayable)
1051 if (features.isEmpty() || transparency != 1f
1052 || !featureFilters.isEmpty())
1057 SequenceFeatures.sortFeatures(features, true);
1058 SequenceFeature lastFeature = null;
1060 Iterator<SequenceFeature> it = features.iterator();
1061 while (it.hasNext())
1063 SequenceFeature sf = it.next();
1064 if (featureGroupNotShown(sf))
1071 * a feature is redundant for rendering purposes if it has the
1072 * same extent as another (so would just redraw the same colour);
1073 * (checking type and isContactFeature as a fail-safe here, although
1074 * currently they are guaranteed to match in this context)
1076 if (lastFeature != null
1077 && sf.getBegin() == lastFeature.getBegin()
1078 && sf.getEnd() == lastFeature.getEnd()
1079 && sf.isContactFeature() == lastFeature.isContactFeature()
1080 && sf.getType().equals(lastFeature.getType()))
1089 public Map<String, FeatureMatcherSetI> getFeatureFilters()
1091 return featureFilters;
1095 public void setFeatureFilters(Map<String, FeatureMatcherSetI> filters)
1097 featureFilters = filters;
1101 public FeatureMatcherSetI getFeatureFilter(String featureType)
1103 return featureFilters.get(featureType);
1107 public void setFeatureFilter(String featureType, FeatureMatcherSetI filter)
1109 if (filter == null || filter.isEmpty())
1111 featureFilters.remove(featureType);
1115 featureFilters.put(featureType, filter);
1120 * Answers the colour for the feature, or null if the feature is excluded by
1121 * feature group visibility, by filters, or by colour threshold settings. This
1122 * method does not take feature visibility into account.
1128 public Color getColor(SequenceFeature sf, FeatureColourI fc)
1131 * is the feature group displayed?
1133 if (featureGroupNotShown(sf))
1139 * does the feature pass filters?
1141 if (!featureMatchesFilters(sf))
1146 return fc.getColor(sf);
1150 * Answers true if there no are filters defined for the feature type, or this
1151 * feature matches the filters. Answers false if the feature fails to match
1157 protected boolean featureMatchesFilters(SequenceFeature sf)
1159 FeatureMatcherSetI filter = featureFilters.get(sf.getType());
1160 return filter == null ? true : filter.matches(sf);
1164 * Answers true unless the specified group is set to hidden. Defaults to true
1165 * if group visibility is not set.
1170 public boolean isGroupVisible(String group)
1172 if (!featureGroups.containsKey(group))
1176 return featureGroups.get(group);
1180 * Orders features in render precedence (last in order is last to render, so
1181 * displayed on top of other features)
1185 public void orderFeatures(Comparator<String> order)
1187 Arrays.sort(renderOrder, order);
1191 public boolean isVisible(SequenceFeature feature)
1193 if (feature == null)
1197 if (getFeaturesDisplayed() == null
1198 || !getFeaturesDisplayed().isVisible(feature.getType()))
1202 if (featureGroupNotShown(feature))
1206 FeatureColourI fc = featureColours.get(feature.getType());
1207 if (fc != null && fc.isOutwithThreshold(feature))
1211 if (!featureMatchesFilters(feature))