LinearRenderer2D extends AbstractAxisRenderer2D { public Number viewToWorld(Axis axis, double value, boolean extrapolate) { double min = axis.getMin().doubleValue(); double max = axis.getMax().doubleValue(); if (!extrapolate) { if (value <= 0.0) { return min; } if (value >= getShapeLength()) { return max; } } return value/getShapeLength()*(max - min) + min; } LinearRenderer2D(); double worldToView(Axis axis, Number value, boolean extrapolate); Number viewToWorld(Axis axis, double value, boolean extrapolate);  }
@Test public void testViewToWorld() { assertEquals( -5.0, renderer.viewToWorld(axis, 0.0, false)); assertEquals( 0.0, renderer.viewToWorld(axis, 0.5, false)); assertEquals( 3.0, renderer.viewToWorld(axis, 0.8, false)); assertEquals( 5.0, renderer.viewToWorld(axis, 1.0, false)); assertEquals(-10.0, renderer.viewToWorld(axis, -0.5, true)); assertEquals( -5.0, renderer.viewToWorld(axis, 0.0, true)); assertEquals( 0.0, renderer.viewToWorld(axis, 0.5, true)); assertEquals( 3.0, renderer.viewToWorld(axis, 0.8, true)); assertEquals( 5.0, renderer.viewToWorld(axis, 1.0, true)); assertEquals( 10.0, renderer.viewToWorld(axis, 1.5, true)); }