Skip to content

Commit 40baa0e

Browse files
committed
halfhp#26 Fixed an NPE issue when drawing null values with a PointLabeler.
1 parent 29a30cc commit 40baa0e

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

androidplot-core/src/main/java/com/androidplot/xy/LineAndPointRenderer.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,18 @@ protected void renderPoints(Canvas canvas, RectF plotArea, XYSeries series, int
246246
final PointLabeler pointLabeler = hasPointLabelFormatter ? formatter.getPointLabeler() : null;
247247
for(int i = iStart; i < iEnd; i++) {
248248
PointF p = points.get(i);
249+
if(p != null) {
249250

250-
// if vertexPaint is available, draw vertex:
251-
if (vertexPaint != null) {
252-
canvas.drawPoint(p.x, p.y, vertexPaint);
253-
}
251+
// if vertexPaint is available, draw vertex:
252+
if (vertexPaint != null) {
253+
canvas.drawPoint(p.x, p.y, vertexPaint);
254+
}
254255

255-
// if textPaint and pointLabeler are available, draw point's text label:
256-
if (pointLabeler != null) {
257-
canvas.drawText(pointLabeler.getLabel(series, i),
258-
p.x + plf.hOffset, p.y + plf.vOffset, plf.getTextPaint());
256+
// if textPaint and pointLabeler are available, draw point's text label:
257+
if (pointLabeler != null) {
258+
canvas.drawText(pointLabeler.getLabel(series, i),
259+
p.x + plf.hOffset, p.y + plf.vOffset, plf.getTextPaint());
260+
}
259261
}
260262
}
261263
}

0 commit comments

Comments
 (0)