}
/**
- * Removes from the list of features any that duplicate the location of a
- * feature of the same type. Should be used only for features of the same,
- * simple, feature colour (which normally implies the same feature type). Does
- * not check visibility settings for feature type or feature group. No
- * filtering is done if transparency, or any feature filters, are in force.
+ * Removes from the list of features any whose group is not shown, or that are
+ * visible and duplicate the location of a visible feature of the same type.
+ * Should be used only for features of the same, simple, feature colour (which
+ * normally implies the same feature type). No filtering is done if
+ * transparency, or any feature filters, are in force.
*
* @param features
*/
while (it.hasNext())
{
SequenceFeature sf = it.next();
+ if (featureGroupNotShown(sf))
+ {
+ it.remove();
+ continue;
+ }
/*
* a feature is redundant for rendering purposes if it has the
* (checking type and isContactFeature as a fail-safe here, although
* currently they are guaranteed to match in this context)
*/
- if (lastFeature != null && sf.getBegin() == lastFeature.getBegin()
+ if (lastFeature != null
+ && sf.getBegin() == lastFeature.getBegin()
&& sf.getEnd() == lastFeature.getEnd()
&& sf.isContactFeature() == lastFeature.isContactFeature()
&& sf.getType().equals(lastFeature.getType()))
SequenceI seq = av.getAlignment().getSequenceAt(0);
SequenceFeature sf1 = new SequenceFeature("Cath", "", 6, 8, Float.NaN,
"group1");
- seq.addSequenceFeature(sf1);
SequenceFeature sf2 = new SequenceFeature("Cath", "", 5, 11, 2f,
"group2");
- seq.addSequenceFeature(sf2);
SequenceFeature sf3 = new SequenceFeature("Cath", "", 5, 11, 3f,
"group3");
- seq.addSequenceFeature(sf3);
SequenceFeature sf4 = new SequenceFeature("Cath", "", 6, 8, 4f,
"group4");
- seq.addSequenceFeature(sf4);
SequenceFeature sf5 = new SequenceFeature("Cath", "", 6, 9, 5f,
"group4");
+ seq.addSequenceFeature(sf1);
+ seq.addSequenceFeature(sf2);
+ seq.addSequenceFeature(sf3);
+ seq.addSequenceFeature(sf4);
seq.addSequenceFeature(sf5);
fr.findAllFeatures(true);
assertTrue(features.contains(sf5));
/*
- * hide groups 2 and 3 makes no difference to this method
+ * features in hidden groups are removed
*/
fr.setGroupVisibility("group2", false);
fr.setGroupVisibility("group3", false);
features = seq.getSequenceFeatures();
fr.filterFeaturesForDisplay(features);
- assertEquals(features.size(), 3);
+ assertEquals(features.size(), 2);
assertTrue(features.contains(sf1) || features.contains(sf4));
assertFalse(features.contains(sf1) && features.contains(sf4));
- assertTrue(features.contains(sf2) || features.contains(sf3));
- assertFalse(features.contains(sf2) && features.contains(sf3));
+ assertFalse(features.contains(sf2));
+ assertFalse(features.contains(sf3));
assertTrue(features.contains(sf5));
/*