ContinuousColorMapper extends AbstractColorMapper<Double> { public abstract Paint get(double value);  abstract Paint get(double value); Paint get(Number value);  }
@Test public void testGetNumber() { MockContinuousColorMapper c = new MockContinuousColorMapper(); assertEquals(c.get(0.5), c.get(0.5f)); }
@Test public void testGetOmit() { MockContinuousColorMapper c = new MockContinuousColorMapper(); c.setMode(Mode.OMIT); assertNull(c.get(-0.5)); assertEquals(new Color( 0, 0, 0), c.get( 0.0)); assertEquals(new Color(128, 128, 128), c.get( 0.5)); assertEquals(new Color(255, 255, 255), c.get( 1.0)); assertNull(c.get( 1.5)); }
@Test public void testGetRepeat() { MockContinuousColorMapper c = new MockContinuousColorMapper(); c.setMode(Mode.REPEAT); assertEquals(new Color( 0, 0, 0), c.get(-0.5)); assertEquals(new Color( 0, 0, 0), c.get( 0.0)); assertEquals(new Color(128, 128, 128), c.get( 0.5)); assertEquals(new Color(255, 255, 255), c.get( 1.0)); assertEquals(new Color(255, 255, 255), c.get( 1.5)); }
@Test public void testGetCircular() { MockContinuousColorMapper c = new MockContinuousColorMapper(); c.setMode(Mode.CIRCULAR); assertEquals(new Color(128, 128, 128), c.get(-0.5)); assertEquals(new Color( 0, 0, 0), c.get( 0.0)); assertEquals(new Color(128, 128, 128), c.get( 0.5)); assertEquals(new Color(255, 255, 255), c.get( 1.0)); assertEquals(new Color(128, 128, 128), c.get( 1.5)); }
@Test public void testSerialization() throws IOException, ClassNotFoundException { MockContinuousColorMapper original = new MockContinuousColorMapper(); MockContinuousColorMapper deserialized = TestUtils.serializeAndDeserialize(original); assertEquals(original.getMode(), deserialized.getMode()); for (double x = -0.5; x <= 1.5; x += 0.5) { assertEquals(original.get(x), deserialized.get(x)); } }