JFreeChart DynamicTimeSeriesCollection,周期为n毫秒
我正在尝试使用必须每n毫秒更新一次的图表定义一个applet。 例如,每500毫秒。 这是代码的一部分:
dataSet = new DynamicTimeSeriesCollection(1, 200, new Millisecond()); dataSet.setTimeBase(new Millisecond());
当我启动应用程序时,它返回第二行引发的NullPointerException。 如果我用秒代替毫秒,它就可以了。
问题是:如何在没有例外的情况下设置n毫秒的时间段?
谢谢
看起来似乎没有为Millisecond
初始化pointsInTime
,但是您可以在子类构造函数中执行此操作:
private static class MilliDTSC extends DynamicTimeSeriesCollection { public MilliDTSC(int nSeries, int nMoments, RegularTimePeriod timeSample) { super(nSeries, nMoments, timeSample); if (timeSample instanceof Millisecond) { this.pointsInTime = new Millisecond[nMoments]; } } }