NullPointer exception - version 0.9.4

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Belinda

NullPointer exception - version 0.9.4

Post by Belinda » Wed Nov 27, 2002 12:45 pm

Hi

I am getting the following exception for graphs that were working fine with previous versions. Is there anything I need to do to prevent this?

Many thanks,
Belinda

java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:882)
at com.jrefinery.chart.DateAxis.nextStandardDate(Unknown Source)
at com.jrefinery.chart.DateAxis.calculateLowestVisibleTickValue(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.refreshTicks(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.reserveHeight(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown Source)
at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at uk.co.hemscott.charting.JFreeCharter.plot(JFreeCharter.java:282)
at uk.co.hemscott.charting.XmlDataSource.plot(XmlDataSource.java:34)
at uk.co.hemscott.charting.HistoricFireIndexGifGenerator.plot(HistoricFireIndexGifGenerator.java:232)
at uk.co.hemscott.charting.StudioIntradayIndex.createGraph(StudioIntradayIndex.java:73)
at uk.co.hemscott.charting.StudioIntradayIndex.main(StudioIntradayIndex.java:38)

Dave Gilbert

Re: NullPointer exception - version 0.9.4

Post by Dave Gilbert » Wed Nov 27, 2002 1:03 pm

Hi Belinda,

One of the things that has changed in 0.9.4 is the constants used to specify the units in the DateTickUnit class. Make sure your code is using one of the following:

public static final int YEAR = 0;
public static final int MONTH = 1;
public static final int DAY = 2;
public static final int HOUR = 3;
public static final int MINUTE = 4;
public static final int SECOND = 5;
public static final int MILLISECOND = 6;

Previously, the code used the constants from the java.util.Calendar class, but only a subset of them were valid.

I will look at the code and amend it so you get a sensible exception (i.e. one that explains what has gone wrong) BEFORE it gets to that null pointer exception.

Regards,

DG

Belinda

Re: NullPointer exception - version 0.9.4

Post by Belinda » Wed Nov 27, 2002 1:27 pm

Thanks for the quick reply, David.

That worked a treat.


Belinda

Locked