LogarithmicRenderer2D extends AbstractAxisRenderer2D { public double worldToView(Axis axis, Number value, boolean extrapolate) { checkAxisBounds(axis); 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(); } } double minLog = (min > 0.0) ? Math.log10(min) : 0.0; double maxLog = (max > 0.0) ? Math.log10(max) : 1.0; return (Math.log10(val) - minLog)*getShapeLength() / (maxLog - minLog); } LogarithmicRenderer2D(); double worldToView(Axis axis, Number value, boolean extrapolate); Number viewToWorld(Axis axis, double value, boolean extrapolate); @Override List<Tick> getTicks(Axis axis);  }
@Test public void testWorldToView() { assertEquals(Double.NEGATIVE_INFINITY, renderer.worldToView(axis, 0.0, true), DELTA); assertEquals(Math.log10( 0.1), renderer.worldToView(axis, 0.1, true), DELTA); assertEquals(Math.log10( 1.0), renderer.worldToView(axis, 1.0, true), DELTA); assertEquals(Math.log10( 5.0), renderer.worldToView(axis, 5.0, true), DELTA); assertEquals(Math.log10( 9.0), renderer.worldToView(axis, 9.0, true), DELTA); assertEquals(Math.log10(10.0), renderer.worldToView(axis, 10.0, true), DELTA); }