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