From: gmungoc Date: Mon, 24 Jul 2017 08:24:48 +0000 (+0100) Subject: JAL-2624 additional tests for FeatureColour.getColour(), X-Git-Tag: Release_2_10_3b1~171 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2066caec85bf0b332d924472fcfdbdaa07f56f1e;p=jalview.git JAL-2624 additional tests for FeatureColour.getColour(), filterFeaturesForDisplay --- diff --git a/src/jalview/schemes/FeatureColour.java b/src/jalview/schemes/FeatureColour.java index ed3e02d..b748d9e 100644 --- a/src/jalview/schemes/FeatureColour.java +++ b/src/jalview/schemes/FeatureColour.java @@ -553,9 +553,13 @@ public class FeatureColour implements FeatureColourI /* * graduated colour case, optionally with threshold - * (treating Float.NaN as within visible range here) + * Float.NaN is assigned minimum visible score colour */ float scr = feature.getScore(); + if (Float.isNaN(scr)) + { + return getMinColour(); + } if (isAboveThreshold() && scr <= threshold) { return null; @@ -568,10 +572,6 @@ public class FeatureColour implements FeatureColourI { return getMaxColour(); } - if (Float.isNaN(scr)) - { - return getMinColour(); - } float scl = (scr - base) / range; if (isHighToLow) { diff --git a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java index 3e27aba..dc86605 100644 --- a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java +++ b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java @@ -267,15 +267,20 @@ public class FeatureRendererTest fr.filterFeaturesForDisplay(features, null); // empty list, does nothing SequenceI seq = av.getAlignment().getSequenceAt(0); - SequenceFeature sf1 = new SequenceFeature("Cath", "", 6, 8, "group1"); + SequenceFeature sf1 = new SequenceFeature("Cath", "", 6, 8, Float.NaN, + "group1"); seq.addSequenceFeature(sf1); - SequenceFeature sf2 = new SequenceFeature("Cath", "", 5, 11, "group2"); + SequenceFeature sf2 = new SequenceFeature("Cath", "", 5, 11, 2f, + "group2"); seq.addSequenceFeature(sf2); - SequenceFeature sf3 = new SequenceFeature("Cath", "", 5, 11, "group3"); + SequenceFeature sf3 = new SequenceFeature("Cath", "", 5, 11, 3f, + "group3"); seq.addSequenceFeature(sf3); - SequenceFeature sf4 = new SequenceFeature("Cath", "", 6, 8, "group4"); + SequenceFeature sf4 = new SequenceFeature("Cath", "", 6, 8, 4f, + "group4"); seq.addSequenceFeature(sf4); - SequenceFeature sf5 = new SequenceFeature("Cath", "", 6, 9, "group4"); + SequenceFeature sf5 = new SequenceFeature("Cath", "", 6, 9, 5f, + "group4"); seq.addSequenceFeature(sf5); fr.findAllFeatures(true); @@ -329,6 +334,7 @@ public class FeatureRendererTest /* * no filtering of co-located features with graduated colour scheme + * filterFeaturesForDisplay does _not_ check colour threshold * sf2 is removed as its group is hidden */ features = seq.getSequenceFeatures(); diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 03f7efa..7a72c15 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -128,17 +128,28 @@ public class FeatureColourTest 150f); SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 70f, null); + + /* + * feature with score of Float.NaN is always assigned minimum colour + */ + SequenceFeature sf2 = new SequenceFeature("type", "desc", 0, 20, + Float.NaN, null); + fc.setThreshold(100f); // ignore for now assertEquals(new Color(204, 204, 204), fc.getColor(sf)); + assertEquals(Color.white, fc.getColor(sf2)); fc.setAboveThreshold(true); // feature lies below threshold assertNull(fc.getColor(sf)); + assertEquals(Color.white, fc.getColor(sf2)); fc.setBelowThreshold(true); fc.setThreshold(70f); assertNull(fc.getColor(sf)); // feature score == threshold - hidden + assertEquals(Color.white, fc.getColor(sf2)); fc.setThreshold(69f); assertNull(fc.getColor(sf)); // feature score > threshold - hidden + assertEquals(Color.white, fc.getColor(sf2)); } /**