Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public double worldToView(Axis axis, Number value, boolean extrapolate) {
}
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() /
double result = (Math.log10(val) - minLog)*getShapeLength() /
(maxLog - minLog);
return Double.isFinite(result) ? result : 0;
}

/**
Expand All @@ -92,8 +93,9 @@ public Number viewToWorld(Axis axis, double value, boolean extrapolate) {
}
double minLog = (min > 0.0) ? Math.log10(min) : 0.0;
double maxLog = (max > 0.0) ? Math.log10(max) : 1.0;
return Math.pow(10.0,
double result = Math.pow(10.0,
value*(maxLog - minLog)/getShapeLength() + minLog);
return Double.isFinite(result) ? result : 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testDraw() {

@Test
public void testWorldToView() {
assertEquals(Double.NEGATIVE_INFINITY, renderer.worldToView(axis, 0.0, true), DELTA);
assertEquals(0, 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);
Expand Down