2011-07-27 33 views
3

我試圖定義一個小程序,必須每n毫秒更新一次圖表。例如每500毫秒。這是代碼的一部分:JFreeChart DynamicTimeSeriesCollection,週期爲n毫秒

dataSet = new DynamicTimeSeriesCollection(1, 200, new Millisecond()); 
dataSet.setTimeBase(new Millisecond()); 

當我啓動應用程序時,它返回第二行引發的NullPointerException異常。如果我用秒代替Milliseconds,它可以工作。

現在的問題是:我怎樣才能設置一個毫秒的時間段而沒有異常?

感謝

回答

4

它看起來像pointsInTimeMillisecond不被初始化,但你可以在子類構造函數來完成:

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]; 
     } 
    } 
} 
+0

所以,是一個JFreeCharts錯誤呢? –

+1

可以說,是的;來源中的評論建議更多的是_todo_。 – trashgod

+0

明天早上我會在辦公室嘗試。 如何設置500毫秒的時間?這取決於我添加新數據的頻率嗎? – Maverik