X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FAnnotationColourGradientTest.java;h=c56da593d97236e67b67a2d1b9191e10732356ef;hb=refs%2Fheads%2Fbug%2FJAL-3744_read_gzip_file_in_jalviewjs;hp=0b0eb24a39e5c336b3fe7774796a2b1e09cea988;hpb=4265a395749b667cf7d558b8bad40ee2a57b6972;p=jalview.git diff --git a/test/jalview/schemes/AnnotationColourGradientTest.java b/test/jalview/schemes/AnnotationColourGradientTest.java index 0b0eb24..c56da59 100644 --- a/test/jalview/schemes/AnnotationColourGradientTest.java +++ b/test/jalview/schemes/AnnotationColourGradientTest.java @@ -124,6 +124,18 @@ public class AnnotationColourGradientTest Color result = testee.shadeCalculation(ann, col); assertEquals(result, expected, "for column " + col); } + + /* + * test for boundary case threshold == graphMax (JAL-3206) + */ + float thresh = ann.threshold.value; + ann.threshold.value = ann.graphMax; + Color result = testee.shadeCalculation(ann, WIDTH - 1); + assertEquals(result, maxColour); + testee.setThresholdIsMinMax(false); + result = testee.shadeCalculation(ann, WIDTH - 1); + assertEquals(result, maxColour); + ann.threshold.value = thresh; // reset } /** @@ -174,6 +186,18 @@ public class AnnotationColourGradientTest Color result = testee.shadeCalculation(ann, col); assertEquals(result, expected, "for column " + col); } + + /* + * test for boundary case threshold == graphMin (JAL-3206) + */ + float thresh = ann.threshold.value; + ann.threshold.value = ann.graphMin; + Color result = testee.shadeCalculation(ann, 0); + assertEquals(result, minColour); + testee.setThresholdIsMinMax(false); + result = testee.shadeCalculation(ann, 0); + assertEquals(result, minColour); + ann.threshold.value = thresh; // reset } /** @@ -190,9 +214,10 @@ public class AnnotationColourGradientTest { Color result = testee.findColour('a', col, seq); /* - * expect white below threshold of 5 + * expect white at or below threshold of 5 */ - Color expected = col < 5 ? Color.white : new Color(50 + 10 * col, + Color expected = col <= 5 ? Color.white + : new Color(50 + 10 * col, 200 - 10 * col, 150 + 10 * col); assertEquals(result, expected, "for column " + col); @@ -206,11 +231,12 @@ public class AnnotationColourGradientTest for (int col = 0; col < WIDTH; col++) { /* - * colours for values >= threshold are graduated + * colours for values > threshold are graduated * range is 6-10 so steps of 100/5 = 20 */ int factor = col - THRESHOLD_FIVE; - Color expected = col < 5 ? Color.white : new Color(50 + 20 * factor, + Color expected = col <= 5 ? Color.white + : new Color(50 + 20 * factor, 200 - 20 * factor, 150 + 20 * factor); Color result = testee.findColour('a', col, seq); @@ -231,7 +257,8 @@ public class AnnotationColourGradientTest for (int col = 0; col < WIDTH; col++) { Color result = testee.findColour('a', col, seq); - Color expected = col > 5 ? Color.white : new Color(50 + 10 * col, + Color expected = col >= 5 ? Color.white + : new Color(50 + 10 * col, 200 - 10 * col, 150 + 10 * col); assertEquals(result, expected, "for column " + col); } @@ -244,10 +271,11 @@ public class AnnotationColourGradientTest for (int col = 0; col < WIDTH; col++) { /* - * colours for values <= threshold are graduated + * colours for values < threshold are graduated * range is 0-5 so steps of 100/5 = 20 */ - Color expected = col > 5 ? Color.white : new Color(50 + 20 * col, + Color expected = col >= 5 ? Color.white + : new Color(50 + 20 * col, 200 - 20 * col, 150 + 20 * col); Color result = testee.findColour('a', col, seq); assertEquals(result, expected, "for column " + col);