From cb1244956d07a8233e6ff4e4f2e1db992f84f554 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 22 Apr 2016 16:12:28 +0100 Subject: [PATCH] JAL-2068 code and test for case of minValue == maxValue --- src/jalview/util/ColorUtils.java | 4 ++++ test/jalview/util/ColorUtilsTest.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/jalview/util/ColorUtils.java b/src/jalview/util/ColorUtils.java index 042654d..31d1ded 100644 --- a/src/jalview/util/ColorUtils.java +++ b/src/jalview/util/ColorUtils.java @@ -117,6 +117,10 @@ public class ColorUtils public static Color getGraduatedColour(float value, float minValue, Color minColour, float maxValue, Color maxColour) { + if (minValue == maxValue) + { + return minColour; + } if (value < minValue) { value = minValue; diff --git a/test/jalview/util/ColorUtilsTest.java b/test/jalview/util/ColorUtilsTest.java index ca1aca0..a82b9c0 100644 --- a/test/jalview/util/ColorUtilsTest.java +++ b/test/jalview/util/ColorUtilsTest.java @@ -125,5 +125,12 @@ public class ColorUtilsTest .getGraduatedColour(40f, 10f, minColour, 30f, maxColour); assertEquals(maxColour, col); + + /* + * min = max + */ + col = ColorUtils + .getGraduatedColour(40f, 10f, minColour, 10f, maxColour); + assertEquals(minColour, col); } } -- 1.7.10.2