From a2450baeb2c469fc96fa1f2d31be1d93d19835ec Mon Sep 17 00:00:00 2001 From: Tim Molter <tim@knowm.org> Date: Mon, 5 Oct 2015 00:21:56 +0200 Subject: [PATCH] LogarithmicCalculator abort when really small chart --- .../internal/chartpart/AxisTickLogarithmicCalculator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLogarithmicCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLogarithmicCalculator.java index f5e1e3ea..f810c8cf 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLogarithmicCalculator.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLogarithmicCalculator.java @@ -58,6 +58,11 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator { // tick space - a percentage of the working space available for ticks double tickSpace = styleManager.getAxisTickSpacePercentage() * workingSpace; // in plot space + // this prevents an infinite loop when the plot gets sized really small. + if (tickSpace < styleManager.getXAxisTickMarkSpacingHint()) { + return; + } + // where the tick should begin in the working space in pixels double margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace); @@ -81,9 +86,8 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator { logMax = (int) (Math.log10(styleManager.getXAxisMax())); // no floor } - // double firstPosition = getFirstPosition(tickStep); - // System.out.println("firstPosition: " + firstPosition); double firstPosition = Utils.pow(10, logMin); + // System.out.println("firstPosition: " + firstPosition); double tickStep = Utils.pow(10, logMin - 1); for (int i = logMin; i <= logMax; i++) { // for each decade -- GitLab