+ AnnotationColourGradient testee = new AnnotationColourGradient(ann,
+ minColour, maxColour, AnnotationColourGradient.BELOW_THRESHOLD);
+
+ for (int col = 0; col < WIDTH; col++)
+ {
+ Color result = testee.shadeCalculation(ann, col);
+ /*
+ * colour is derived regardless of the threshold value
+ * (the renderer will suppress colouring if above/below threshold)
+ */
+ Color expected = new Color(50 + 10 * col, 200 - 10 * col,
+ 150 + 10 * col);
+ assertEquals(result, expected, "for column " + col);
+ }
+
+ /*
+ * now make 0-5 the span of the colour range
+ * (annotation value == column number in this test)
+ */
+ testee.setThresholdIsMinMax(true);
+ for (int col = THRESHOLD_FIVE + 1; col < WIDTH; col++)
+ {
+ /*
+ * colours above the threshold are computed as before
+ */
+ Color expected = new Color(50 + 10 * col, 200 - 10 * col,
+ 150 + 10 * col);
+ Color result = testee.shadeCalculation(ann, col);
+ assertEquals(result, expected, "for column " + col);
+ }
+
+ for (int col = 0; col <= THRESHOLD_FIVE; col++)
+ {
+ /*
+ * colours for values <= threshold are graduated
+ * range is 0-5 so steps of 100/5 = 20
+ */
+ Color expected = new Color(50 + 20 * col, 200 - 20 * col,
+ 150 + 20 * col);
+ Color result = testee.shadeCalculation(ann, col);
+ assertEquals(result, expected, "for column " + col);
+ }
+ }
+
+ /**
+ * Test the 'colour above threshold' case
+ */
+ @Test(groups = "Functional")
+ public void testFindColour_aboveThreshold()
+ {
+ AnnotationColourGradient testee = new AnnotationColourGradient(ann,
+ minColour, maxColour, AnnotationColourGradient.ABOVE_THRESHOLD);
+ testee = (AnnotationColourGradient) testee.getInstance(al, null);
+
+ for (int col = 0; col < WIDTH; col++)
+ {
+ Color result = testee.findColour('a', col, seq);
+ /*
+ * expect white below threshold of 5
+ */
+ Color expected = col < 5 ? Color.white : new Color(50 + 10 * col,
+ 200 - 10 * col,
+ 150 + 10 * col);
+ assertEquals(result, expected, "for column " + col);
+ }
+
+ /*
+ * now make 6-10 the span of the colour range
+ * (annotation value == column number in this test)
+ */
+ testee.setThresholdIsMinMax(true);
+ for (int col = 0; col < WIDTH; col++)
+ {
+ /*
+ * 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,
+ 200 - 20 * factor,
+ 150 + 20 * factor);
+ Color result = testee.findColour('a', col, seq);
+ assertEquals(result, expected, "for column " + col);
+ }
+ }
+
+ /**
+ * Test the 'colour below threshold' case
+ */
+ @Test(groups = "Functional")
+ public void testFindColour_belowThreshold()
+ {
+ AnnotationColourGradient testee = new AnnotationColourGradient(ann,
+ minColour, maxColour, AnnotationColourGradient.BELOW_THRESHOLD);
+ testee = (AnnotationColourGradient) testee.getInstance(al, null);
+
+ 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,
+ 200 - 10 * col, 150 + 10 * col);
+ assertEquals(result, expected, "for column " + col);
+ }
+
+ /*
+ * now make 0-5 the span of the colour range
+ * (annotation value == column number in this test)
+ */
+ testee.setThresholdIsMinMax(true);
+ for (int col = 0; col < WIDTH; col++)
+ {
+ /*
+ * 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,
+ 200 - 20 * col, 150 + 20 * col);
+ Color result = testee.findColour('a', col, seq);
+ assertEquals(result, expected, "for column " + col);
+ }
+ }
+
+ @Test(groups = "Functional")
+ public void testFindColour_noThreshold()
+ {
+ AnnotationColourGradient testee = new AnnotationColourGradient(ann,
+ minColour, maxColour, AnnotationColourGradient.NO_THRESHOLD);
+ testee = (AnnotationColourGradient) testee.getInstance(al, null);
+
+ for (int col = 0; col < WIDTH; col++)
+ {
+ Color result = testee.findColour('a', col, seq);
+ /*
+ * column <n> is n/10 of the way from minCol to maxCol
+ */
+ Color expected = new Color(50 + 10 * col, 200 - 10 * col,
+ 150 + 10 * col);
+ assertEquals(result, expected, "for column " + col);
+ }
+ }
+
+ @Test(groups = "Functional")
+ public void testFindColour_originalColours()
+ {
+ AnnotationColourGradient testee = new AnnotationColourGradient(ann,
+ minColour, maxColour, AnnotationColourGradient.NO_THRESHOLD);
+ testee = (AnnotationColourGradient) testee.getInstance(al, null);
+
+ /*
+ * flag corresponding to 'use original colours' checkbox
+ * - just use the individual annotation colours
+ */
+ testee.setPredefinedColours(true);