+
+ /**
+ * Tests for the method that returns a colour graduated between darker() and
+ * brighter()
+ */
+ @Test(groups = { "Functional" })
+ public void testGetGraduatedColour_darkerToBrighter()
+ {
+ final Color colour = new Color(180, 200, 220);
+
+ /*
+ * value half-way between min and max does _not_ mean colour unchanged
+ * darker (*.7) is (126, 140, 154)
+ * brighter (*1/.7) is (255, 255, 255)
+ * midway is (190, 197, 204)
+ */
+ Color col = ColorUtils.getGraduatedColour(20f, 10f, 30f, colour);
+ assertEquals(190, col.getRed());
+ assertEquals(197, col.getGreen());
+ assertEquals(204, col.getBlue());
+
+ // minValue (or less) returns colour.darker()
+ // - or would do if Color.darker calculated better!
+ col = ColorUtils.getGraduatedColour(10f, 10f, 30f, colour);
+ assertEquals(col, new Color(126, 140, 154));
+ // Color.darker computes 125.999999 and rounds down!
+ assertEquals(new Color(125, 140, 154), colour.darker());
+ col = ColorUtils.getGraduatedColour(-10f, 10f, 30f, colour);
+ assertEquals(new Color(126, 140, 154), col);
+
+ // maxValue (or more) returns colour.brighter()
+ col = ColorUtils.getGraduatedColour(30f, 10f, 30f, colour);
+ assertEquals(colour.brighter(), col);
+ col = ColorUtils.getGraduatedColour(40f, 10f, 30f, colour);
+ assertEquals(colour.brighter(), col);
+
+ /*
+ * 'linear' mid-point between 0.7 and 1/0.7 is 1.057
+ * so the '
+ */
+ Color c = new Color(200, 200, 200);
+ col = ColorUtils.getGraduatedColour(106f, 0f, 200f, c);
+ assertEquals(c, col);
+ }