From 7697ac95a76786f8dcc37916d15a9897b37749a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 15 Nov 2021 23:28:01 +0100 Subject: [PATCH] NPE fix --- gradle.properties | 4 +-- .../AxesChartSeriesNumericalNoErrorBars.java | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index f8db79d..c77146d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group = org.xbib.graphics name = graphics -version = 4.0.4 +version = 4.0.5 gradle.wrapper.version = 6.6.1 -pdfbox.version = 2.0.23 +pdfbox.version = 2.0.24 jna.version = 5.8.0 zxing.version = 3.3.1 reflections.version = 0.9.11 diff --git a/graphics-chart/src/main/java/org/xbib/graphics/chart/series/AxesChartSeriesNumericalNoErrorBars.java b/graphics-chart/src/main/java/org/xbib/graphics/chart/series/AxesChartSeriesNumericalNoErrorBars.java index 931a482..cc99693 100644 --- a/graphics-chart/src/main/java/org/xbib/graphics/chart/series/AxesChartSeriesNumericalNoErrorBars.java +++ b/graphics-chart/src/main/java/org/xbib/graphics/chart/series/AxesChartSeriesNumericalNoErrorBars.java @@ -33,16 +33,20 @@ public abstract class AxesChartSeriesNumericalNoErrorBars extends MarkerSeries { @Override protected void calculateMinMax() { List xMinMax = findMinMax(xData); - setXMin(xMinMax.get(0)); - setXMax(xMinMax.get(1)); + if (xMinMax != null) { + setXMin(xMinMax.get(0)); + setXMax(xMinMax.get(1)); + } List yMinMax; if (extraValues == null) { yMinMax = findMinMax(yData); } else { yMinMax = findMinMaxWithErrorBars(yData, extraValues); } - setYMin(yMinMax.get(0)); - setYMax(yMinMax.get(1)); + if (yMinMax != null) { + setYMin(yMinMax.get(0)); + setYMax(yMinMax.get(1)); + } } List findMinMax(List data) { @@ -82,6 +86,20 @@ public abstract class AxesChartSeriesNumericalNoErrorBars extends MarkerSeries { if (bd.doubleValue() > max) { max = bd.doubleValue(); } + } else if (dataPoint instanceof Long) { + long i = (Long) dataPoint; + if (min == null) { + min = (double) i; + } + if (max == null) { + max = (double) i; + } + if (i < min) { + min = (double) i; + } + if (i > max) { + max = (double) i; + } } else if (dataPoint instanceof Integer) { int i = (Integer) dataPoint; if (min == null) {