我的上一个问题仍在继续,与non-displaying of data有关。根据给定的建议,我试图绘制一个较小的数据范围。正如我所观察到的那样,当我处理不同大小的数据范围时,渲染时间正在迅速增加。最后(或多或少)可接受的数据集(加载到内存但不用于绘图)包含16k的值。如果我只需要绘制其中的100个,渲染时间也很长。
情节生成代码如下:
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);
}
我想问一下渲染时间的改进,因为现在,我坚持这个问题。