0
我有我的第一类在另一个类返回填充值的数组绘制
public class GetResults{
public double[] tableOfresults() {
double[] outputArray = new double[100];
double time;
double results
for(time = 0; time<outputArray.length; i++) {
//Some values are calculated and then stored in an array as below
outputArray[(int)Time] = Results
}
return outputarray;
在图上我如何绘制点从功能该类只是计算一些值我想在图形绘制并将它们存储在数组中。
这下一个班级是实际绘制我的图上的点。我不确定一个简单的方法来获取点在我的X轴上绘制的时间值(时间是数组索引0,1,2,3 ect)和我的Y轴,这些是我的结果。我目前不得不把自己的所有职位。
public class graph{
GetResults gr = new GetResuts();
public XYSeries inputOutputGraph() {
XYSeries graph = new XYSeries("My graph");
XYDataset xyDataset = new XYSeriesCollection(graph);
graph.add(1, gr.tableOfResults()[1]);
graph.add(2, gr.tableOfResults()[2]);
graph.add(3, gr.tableOfResults()[3]);
graph.add(4, gr.tableOfResults()[4]);
在这里,我不得不自己添加值(我有1000做)。我需要的东西看起来像这样graph.add(gr.tableOfResults()[gr.Time],gr.tableOfResults()[gr.Results]); 因此,当我的时间上升到0,1,2,3时,它会绘制我的结果,该结果存储在该位置的索引0,1,2,3处。我怎么能这样做?我曾尝试代码^^,我得到了一个数组索引越界与我的数组大小设置为
JFreeChart chart = ChartFactory.createXYLineChart(
"Graph", "Time", "results",
xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame graphFrame = new ChartFrame("XYLine Chart", chart);
graphFrame.setVisible(true);
graphFrame.setSize(300, 300);
return graph;
}
}的vaue
由于这有助于与整理我的x轴的问题。但是现在如何在其中的位置处存储在我的数组内我的Y值读[1] [2] [3 ]等。所以在这个循环中,它应该有一些说,当我上升1,然后数组中的下一个值将绘制在那一点。谢谢 – user2041029 2013-02-11 17:39:38
添加一个'getCollection()'方法,该方法返回包含所有单个'XYSeries'的'XYSeriesCollection';因为有不止一个,你可以添加一个索引参数,例如'getSeries(int i)',它调用'XYSeriesCollection#getSeries()'。 – trashgod 2013-02-11 19:48:15