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;
269 protected boolean updateFeatures()
271 if (av.getFeaturesDisplayed() == null || renderOrder == null
275 if (av.getFeaturesDisplayed().getVisibleFeatureCount() < 1)
280 // TODO: decide if we should check for the visible feature count first
285 * search the alignment for all new features, give them a colour and display
286 * them. Then fires a PropertyChangeEvent on the changeSupport object.
289 protected void findAllFeatures()
291 synchronized (firing)
293 if (firing.equals(Boolean.FALSE))
295 firing = Boolean.TRUE;
296 findAllFeatures(true); // add all new features as visible
297 changeSupport.firePropertyChange("changeSupport", null, null);
298 firing = Boolean.FALSE;
304 public List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column)
307 * include features at the position provided their feature type is
308 * displayed, and feature group is null or marked for display
310 List<SequenceFeature> result = new ArrayList<>();
311 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
316 Set<String> visibleFeatures = getFeaturesDisplayed()
317 .getVisibleFeatures();
318 String[] visibleTypes = visibleFeatures
319 .toArray(new String[visibleFeatures.size()]);
320 List<SequenceFeature> features = sequence.findFeatures(column, column,
324 * include features unless their feature group is not displayed, or
325 * they are hidden (have no colour) based on a filter or colour threshold
327 for (SequenceFeature sf : features)
329 if (!featureGroupNotShown(sf) && getColour(sf) != null)
338 * Searches alignment for all features and updates colours
340 * @param newMadeVisible
341 * if true newly added feature types will be rendered immediately
342 * TODO: check to see if this method should actually be proxied so
343 * repaint events can be propagated by the renderer code
346 public synchronized void findAllFeatures(boolean newMadeVisible)
348 newFeatureAdded = false;
352 newFeatureAdded = true;
356 findingFeatures = true;
357 if (av.getFeaturesDisplayed() == null)
359 av.setFeaturesDisplayed(new FeaturesDisplayed());
361 FeaturesDisplayedI featuresDisplayed = av.getFeaturesDisplayed();
363 Set<String> oldfeatures = new HashSet<>();
364 if (renderOrder != null)
366 for (int i = 0; i < renderOrder.length; i++)
368 if (renderOrder[i] != null)
370 oldfeatures.add(renderOrder[i]);
375 AlignmentI alignment = av.getAlignment();
376 List<String> allfeatures = new ArrayList<>();
378 for (int i = 0; i < alignment.getHeight(); i++)
380 SequenceI asq = alignment.getSequenceAt(i);
381 for (String group : asq.getFeatures().getFeatureGroups(true))
383 boolean groupDisplayed = true;
386 if (featureGroups.containsKey(group))
388 groupDisplayed = featureGroups.get(group);
392 groupDisplayed = newMadeVisible;
393 featureGroups.put(group, groupDisplayed);
398 Set<String> types = asq.getFeatures().getFeatureTypesForGroups(
400 for (String type : types)
402 if (!allfeatures.contains(type)) // or use HashSet and no test?
404 allfeatures.add(type);
406 updateMinMax(asq, type, true); // todo: for all features?
412 // uncomment to add new features in alphebetical order (but JAL-2575)
413 // Collections.sort(allfeatures, String.CASE_INSENSITIVE_ORDER);
416 for (String type : allfeatures)
418 if (!oldfeatures.contains(type))
420 featuresDisplayed.setVisible(type);
426 updateRenderOrder(allfeatures);
427 findingFeatures = false;
431 * Updates the global (alignment) min and max values for a feature type from
432 * the score for a sequence, if the score is not NaN. Values are stored
433 * separately for positional and non-positional features.
439 protected void updateMinMax(SequenceI seq, String featureType,
442 float min = seq.getFeatures().getMinimumScore(featureType, positional);
443 if (Float.isNaN(min))
448 float max = seq.getFeatures().getMaximumScore(featureType, positional);
452 * { {positionalMin, positionalMax}, {nonPositionalMin, nonPositionalMax} }
456 minmax = new Hashtable<>();
458 synchronized (minmax)
460 float[][] mm = minmax.get(featureType);
461 int index = positional ? 0 : 1;
464 mm = new float[][] { null, null };
465 minmax.put(featureType, mm);
467 if (mm[index] == null)
469 mm[index] = new float[] { min, max };
473 mm[index][0] = Math.min(mm[index][0], min);
474 mm[index][1] = Math.max(mm[index][1], max);
478 protected Boolean firing = Boolean.FALSE;
481 * replaces the current renderOrder with the unordered features in
482 * allfeatures. The ordering of any types in both renderOrder and allfeatures
483 * is preserved, and all new feature types are rendered on top of the existing
484 * types, in the order given by getOrder or the order given in allFeatures.
485 * Note. this operates directly on the featureOrder hash for efficiency. TODO:
486 * eliminate the float storage for computing/recalling the persistent ordering
487 * New Cability: updates min/max for colourscheme range if its dynamic
491 private void updateRenderOrder(List<String> allFeatures)
493 List<String> allfeatures = new ArrayList<>(allFeatures);
494 String[] oldRender = renderOrder;
495 renderOrder = new String[allfeatures.size()];
496 boolean initOrders = (featureOrder == null);
498 if (oldRender != null && oldRender.length > 0)
500 for (int j = 0; j < oldRender.length; j++)
502 if (oldRender[j] != null)
506 setOrder(oldRender[j],
507 (1 - (1 + (float) j) / oldRender.length));
509 if (allfeatures.contains(oldRender[j]))
511 renderOrder[opos++] = oldRender[j]; // existing features always
512 // appear below new features
513 allfeatures.remove(oldRender[j]);
516 float[][] mmrange = minmax.get(oldRender[j]);
519 FeatureColourI fc = featureColours.get(oldRender[j]);
520 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
521 && !fc.isColourByAttribute())
523 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
531 if (allfeatures.size() == 0)
533 // no new features - leave order unchanged.
536 int i = allfeatures.size() - 1;
538 boolean sort = false;
539 String[] newf = new String[allfeatures.size()];
540 float[] sortOrder = new float[allfeatures.size()];
541 for (String newfeat : allfeatures)
546 // update from new features minmax if necessary
547 float[][] mmrange = minmax.get(newf[i]);
550 FeatureColourI fc = featureColours.get(newf[i]);
551 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
552 && !fc.isColourByAttribute())
554 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
558 if (initOrders || !featureOrder.containsKey(newf[i]))
560 int denom = initOrders ? allfeatures.size() : featureOrder.size();
561 // new unordered feature - compute persistent ordering at head of
562 // existing features.
563 setOrder(newf[i], i / (float) denom);
565 // set order from newly found feature from persisted ordering.
566 sortOrder[i] = 2 - featureOrder.get(newf[i]).floatValue();
569 // only sort if we need to
570 sort = sort || sortOrder[i] > sortOrder[i + 1];
574 if (iSize > 1 && sort)
576 jalview.util.QuickSort.sort(sortOrder, newf);
579 System.arraycopy(newf, 0, renderOrder, opos, newf.length);
583 * get a feature style object for the given type string. Creates a
584 * java.awt.Color for a featureType with no existing colourscheme.
590 public FeatureColourI getFeatureStyle(String featureType)
592 FeatureColourI fc = featureColours.get(featureType);
595 Color col = ColorUtils.createColourFromName(featureType);
596 fc = new FeatureColour(col);
597 featureColours.put(featureType, fc);
603 public Color getColour(SequenceFeature feature)
605 FeatureColourI fc = getFeatureStyle(feature.getType());
606 return getColor(feature, fc);
610 * Answers true if the feature type is currently selected to be displayed,
616 public boolean showFeatureOfType(String type)
618 return type == null ? false : (av.getFeaturesDisplayed() == null ? true
619 : av.getFeaturesDisplayed().isVisible(type));
623 public void setColour(String featureType, FeatureColourI col)
625 featureColours.put(featureType, col);
629 public void setTransparency(float value)
631 transparency = value;
635 public float getTransparency()
641 * analogous to colour - store a normalized ordering for all feature types in
642 * this rendering context.
645 * Feature type string
647 * normalized priority - 0 means always appears on top, 1 means
650 public float setOrder(String type, float position)
652 if (featureOrder == null)
654 featureOrder = new Hashtable<>();
656 featureOrder.put(type, new Float(position));
661 * get the global priority (0 (top) to 1 (bottom))
664 * @return [0,1] or -1 for a type without a priority
666 public float getOrder(String type)
668 if (featureOrder != null)
670 if (featureOrder.containsKey(type))
672 return featureOrder.get(type).floatValue();
679 public Map<String, FeatureColourI> getFeatureColours()
681 return featureColours;
685 * Replace current ordering with new ordering
688 * an array of { Type, Colour, Filter, Boolean }
689 * @return true if any visible features have been reordered, else false
691 public boolean setFeaturePriority(FeatureSettingsBean[] data)
693 return setFeaturePriority(data, true);
697 * Sets the priority order for features, with the highest priority (displayed on
698 * top) at the start of the data array
701 * an array of { Type, Colour, Filter, Boolean }
703 * when true current featureDisplay list will be cleared
704 * @return true if any visible features have been reordered or recoloured, else
705 * false (i.e. no need to repaint)
707 public boolean setFeaturePriority(FeatureSettingsBean[] data,
711 * note visible feature ordering and colours before update
713 List<String> visibleFeatures = getDisplayedFeatureTypes();
714 Map<String, FeatureColourI> visibleColours = new HashMap<>(
715 getFeatureColours());
717 FeaturesDisplayedI av_featuresdisplayed = null;
720 if ((av_featuresdisplayed = av.getFeaturesDisplayed()) != null)
722 av.getFeaturesDisplayed().clear();
726 av.setFeaturesDisplayed(
727 av_featuresdisplayed = new FeaturesDisplayed());
732 av_featuresdisplayed = av.getFeaturesDisplayed();
738 // The feature table will display high priority
739 // features at the top, but these are the ones
740 // we need to render last, so invert the data
741 renderOrder = new String[data.length];
745 for (int i = 0; i < data.length; i++)
747 String type = data[i].featureType;
748 setColour(type, data[i].featureColour);
751 av_featuresdisplayed.setVisible(type);
754 renderOrder[data.length - i - 1] = type;
759 * get the new visible ordering and return true if it has changed
760 * order or any colour has changed
762 List<String> reorderedVisibleFeatures = getDisplayedFeatureTypes();
763 if (!visibleFeatures.equals(reorderedVisibleFeatures))
766 * the list of ordered visible features has changed
772 * return true if any feature colour has changed
774 for (String feature : visibleFeatures)
776 if (visibleColours.get(feature) != getFeatureStyle(feature))
786 * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
788 public void addPropertyChangeListener(PropertyChangeListener listener)
790 changeSupport.addPropertyChangeListener(listener);
795 * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
797 public void removePropertyChangeListener(PropertyChangeListener listener)
799 changeSupport.removePropertyChangeListener(listener);
802 public Set<String> getAllFeatureColours()
804 return featureColours.keySet();
807 public void clearRenderOrder()
812 public boolean hasRenderOrder()
814 return renderOrder != null;
818 * Returns feature types in ordering of rendering, where last means on top
820 public List<String> getRenderOrder()
822 if (renderOrder == null)
824 return Arrays.asList(new String[] {});
826 return Arrays.asList(renderOrder);
829 public int getFeatureGroupsSize()
831 return featureGroups != null ? 0 : featureGroups.size();
835 public List<String> getFeatureGroups()
837 // conflict between applet and desktop - featureGroups returns the map in
838 // the desktop featureRenderer
839 return (featureGroups == null) ? Arrays.asList(new String[0])
840 : Arrays.asList(featureGroups.keySet().toArray(new String[0]));
843 public boolean checkGroupVisibility(String group,
844 boolean newGroupsVisible)
846 if (featureGroups == null)
848 // then an exception happens next..
850 if (featureGroups.containsKey(group))
852 return featureGroups.get(group).booleanValue();
854 if (newGroupsVisible)
856 featureGroups.put(group, new Boolean(true));
863 * get visible or invisible groups
866 * true to return visible groups, false to return hidden ones.
867 * @return list of groups
870 public List<String> getGroups(boolean visible)
872 if (featureGroups != null)
874 List<String> gp = new ArrayList<>();
876 for (String grp : featureGroups.keySet())
878 Boolean state = featureGroups.get(grp);
879 if (state.booleanValue() == visible)
890 public void setGroupVisibility(String group, boolean visible)
892 featureGroups.put(group, new Boolean(visible));
896 public void setGroupVisibility(List<String> toset, boolean visible)
898 if (toset != null && toset.size() > 0 && featureGroups != null)
900 boolean rdrw = false;
901 for (String gst : toset)
903 Boolean st = featureGroups.get(gst);
904 featureGroups.put(gst, new Boolean(visible));
907 rdrw = rdrw || (visible != st.booleanValue());
912 // set local flag indicating redraw needed ?
918 public Map<String, FeatureColourI> getDisplayedFeatureCols()
920 Map<String, FeatureColourI> fcols = new Hashtable<>();
921 if (getViewport().getFeaturesDisplayed() == null)
925 Set<String> features = getViewport().getFeaturesDisplayed()
926 .getVisibleFeatures();
927 for (String feature : features)
929 fcols.put(feature, getFeatureStyle(feature));
935 public FeaturesDisplayedI getFeaturesDisplayed()
937 return av.getFeaturesDisplayed();
941 * Returns a (possibly empty) list of visible feature types, in render order
945 public List<String> getDisplayedFeatureTypes()
947 List<String> typ = getRenderOrder();
948 List<String> displayed = new ArrayList<>();
949 FeaturesDisplayedI feature_disp = av.getFeaturesDisplayed();
950 if (feature_disp != null)
952 synchronized (feature_disp)
954 for (String type : typ)
956 if (feature_disp.isVisible(type))
967 public List<String> getDisplayedFeatureGroups()
969 List<String> _gps = new ArrayList<>();
970 for (String gp : getFeatureGroups())
972 if (checkGroupVisibility(gp, false))
981 * Answers true if the feature belongs to a feature group which is not
982 * currently displayed, else false
984 * @param sequenceFeature
987 protected boolean featureGroupNotShown(final SequenceFeature sequenceFeature)
990 return featureGroups != null
991 && sequenceFeature.featureGroup != null
992 && sequenceFeature.featureGroup.length() > 0
993 && (b = featureGroups.get(sequenceFeature.featureGroup)) != null
994 && !b.booleanValue();
1001 public List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
1004 List<SequenceFeature> result = new ArrayList<>();
1005 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
1011 * include features at the position provided their feature type is
1012 * displayed, and feature group is null or the empty string
1013 * or marked for display
1015 Set<String> visibleFeatures = getFeaturesDisplayed()
1016 .getVisibleFeatures();
1017 String[] visibleTypes = visibleFeatures
1018 .toArray(new String[visibleFeatures.size()]);
1019 List<SequenceFeature> features = sequence.getFeatures().findFeatures(
1020 resNo, resNo, visibleTypes);
1022 for (SequenceFeature sf : features)
1024 if (!featureGroupNotShown(sf) && getColour(sf) != null)
1033 * Removes from the list of features any whose group is not shown, or that are
1034 * visible and duplicate the location of a visible feature of the same type.
1035 * Should be used only for features of the same, simple, feature colour (which
1036 * normally implies the same feature type). No filtering is done if
1037 * transparency, or any feature filters, are in force.
1041 public void filterFeaturesForDisplay(List<SequenceFeature> features)
1044 * don't remove 'redundant' features if
1045 * - transparency is applied (feature count affects depth of feature colour)
1046 * - filters are applied (not all features may be displayable)
1048 if (features.isEmpty() || transparency != 1f
1049 || !featureFilters.isEmpty())
1054 SequenceFeatures.sortFeatures(features, true);
1055 SequenceFeature lastFeature = null;
1057 Iterator<SequenceFeature> it = features.iterator();
1058 while (it.hasNext())
1060 SequenceFeature sf = it.next();
1061 if (featureGroupNotShown(sf))
1068 * a feature is redundant for rendering purposes if it has the
1069 * same extent as another (so would just redraw the same colour);
1070 * (checking type and isContactFeature as a fail-safe here, although
1071 * currently they are guaranteed to match in this context)
1073 if (lastFeature != null
1074 && sf.getBegin() == lastFeature.getBegin()
1075 && sf.getEnd() == lastFeature.getEnd()
1076 && sf.isContactFeature() == lastFeature.isContactFeature()
1077 && sf.getType().equals(lastFeature.getType()))
1086 public Map<String, FeatureMatcherSetI> getFeatureFilters()
1088 return featureFilters;
1092 public void setFeatureFilters(Map<String, FeatureMatcherSetI> filters)
1094 featureFilters = filters;
1098 public FeatureMatcherSetI getFeatureFilter(String featureType)
1100 return featureFilters.get(featureType);
1104 public void setFeatureFilter(String featureType, FeatureMatcherSetI filter)
1106 if (filter == null || filter.isEmpty())
1108 featureFilters.remove(featureType);
1112 featureFilters.put(featureType, filter);
1117 * Answers the colour for the feature, or null if the feature is excluded by
1118 * feature group visibility, by filters, or by colour threshold settings. This
1119 * method does not take feature visibility into account.
1125 public Color getColor(SequenceFeature sf, FeatureColourI fc)
1128 * is the feature group displayed?
1130 if (featureGroupNotShown(sf))
1136 * does the feature pass filters?
1138 if (!featureMatchesFilters(sf))
1143 return fc.getColor(sf);
1147 * Answers true if there no are filters defined for the feature type, or this
1148 * feature matches the filters. Answers false if the feature fails to match
1154 protected boolean featureMatchesFilters(SequenceFeature sf)
1156 FeatureMatcherSetI filter = featureFilters.get(sf.getType());
1157 return filter == null ? true : filter.matches(sf);
1161 * Answers true unless the specified group is set to hidden. Defaults to true
1162 * if group visibility is not set.
1167 public boolean isGroupVisible(String group)
1169 if (!featureGroups.containsKey(group))
1173 return featureGroups.get(group);
1177 * Orders features in render precedence (last in order is last to render, so
1178 * displayed on top of other features)
1182 public void orderFeatures(Comparator<String> order)
1184 Arrays.sort(renderOrder, order);
1188 public boolean isVisible(SequenceFeature feature)
1190 if (feature == null)
1194 if (getFeaturesDisplayed() == null
1195 || !getFeaturesDisplayed().isVisible(feature.getType()))
1199 if (featureGroupNotShown(feature))
1203 FeatureColourI fc = featureColours.get(feature.getType());
1204 if (fc != null && fc.isOutwithThreshold(feature))
1208 if (!featureMatchesFilters(feature))