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);
}
我想请教一下改进为了渲染时间,原因现在,我坚持这个问题。