1
這個問題是我的前一個問題的繼續,涉及到non-displaying of data。在給出的建議之後,我試圖繪製一個較小的數據範圍。正如已經觀察到的,當我處理不同大小的數據範圍時,渲染時間正在迅速增加。最後(或多或少)可接受的數據集(即加載到內存但不用於繪圖)包含16k個值。如果我只需要繪製其中的100個,渲染時間也非常龐大。JFreeChart圖表渲染問題
情節生成代碼如下:
public void plotXYChart(double dArray[][], String sPlotName, String sSeriesName,
String sRangeName, int iInitialPoint, int iPlotLength){
XYSeries series1 = new XYSeries(sSeriesName);
series1.clear();
series1.setNotify(false);
if (iInitialPoint+iPlotLength > dArray.length){
iPlotLength = dArray.length;
} else {
iPlotLength+=iInitialPoint;
}
for (int i=iInitialPoint; i < iPlotLength; i++){
series1.add(dArray[i][0], dArray[i][1], false);
}
System.out.println("Elements in series: " + series1.getItemCount());
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.removeAllSeries();
dataset.addSeries(series1);
System.out.println("Elements in dataset: " + dataset.getItemCount(0));
chart = null;
chart = new JFreeChart(new XYPlot(dataset, new NumberAxis(sSeriesName),
new NumberAxis(sRangeName), new SamplingXYLineRenderer()));
plotChart(sPlotName, chart);
XYPlot plot = (XYPlot) chart.getPlot();
plot.getDomainAxis().setStandardTickUnits(new StandardTickUnitSource());
plot.getRangeAxis().setStandardTickUnits(new StandardTickUnitSource());
}
爲JFramePanel的代碼,該代碼使用圖表的輸出是下一個:
private void plotChart(String sPlotName, JFreeChart chart){
if (this.cPanel!=null) {
cPanel.setChart(chart);
}
else
cPanel = new ChartPanel(chart, true);
this.chartFrame.add(cPanel);
if (this.chartFrame.isVisible() == false){
RefineryUtilities.centerFrameOnScreen(this.chartFrame);
}
this.chartFrame.pack();
this.chartFrame.setVisible(true);
}
我想請教一下改進爲了渲染時間,原因現在,我堅持這個問題。