X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2Fprofile%2FProfileChart.java;h=17ea32b2a4c004328b1ce1afcaf592b97423780c;hp=d989ebfdfb99f889ec853a3c38d040304fe02183;hb=140e9d165f85c3d4f0435a311e091209313faa2a;hpb=c0387c124840c9407e040600fda88f3c3e8f6aa6 diff --git a/tim/prune/gui/profile/ProfileChart.java b/tim/prune/gui/profile/ProfileChart.java index d989ebf..17ea32b 100644 --- a/tim/prune/gui/profile/ProfileChart.java +++ b/tim/prune/gui/profile/ProfileChart.java @@ -103,7 +103,7 @@ public class ProfileChart extends GenericDisplay implements MouseListener // Find minimum and maximum values to plot double minValue = _data.getMinValue(); double maxValue = _data.getMaxValue(); - if (maxValue <= minValue) {maxValue = minValue + 1;} + if (maxValue <= minValue) {maxValue = minValue + 1; minValue--;} final int numPoints = _track.getNumPoints(); _xScaleFactor = 1.0 * (width - 2 * BORDER_WIDTH - 1) / numPoints; @@ -153,15 +153,18 @@ public class ProfileChart extends GenericDisplay implements MouseListener } } // current point (make sure it's drawn last) - if (_data.hasData(selectedPoint)) + if (selectedPoint >= 0) { x = (int) (_xScaleFactor * selectedPoint) + 1; g.setColor(secondColour); g.fillRect(BORDER_WIDTH + x, height-usableHeight-BORDER_WIDTH+1, barWidth, usableHeight-2); - g.setColor(currentColour); - value = _data.getData(selectedPoint); - y = (int) (yScaleFactor * (value - minValue)); - g.fillRect(BORDER_WIDTH + x, height-BORDER_WIDTH - y, barWidth, y); + if (_data.hasData(selectedPoint)) + { + g.setColor(currentColour); + value = _data.getData(selectedPoint); + y = (int) (yScaleFactor * (value - minValue)); + g.fillRect(BORDER_WIDTH + x, height-BORDER_WIDTH - y, barWidth, y); + } } } catch (NullPointerException npe) { // ignore, probably due to data being changed