java swing JFreeChart 重绘问题?
大大们好!!!我再做曲线图我先贴出我绘图的部分!publicTimeSeriesprepareData1(TimeSeriestimeseries,Stringdate,...
大大们好!!!
我再做曲线图我先贴出我绘图的部分!
public TimeSeries prepareData1(TimeSeries timeseries, String date, int i) {
Calendar c = Calendar.getInstance();
Date trueDate = DateUtil.formatDate("yyyyMMddHHmm", date + "0845");
c.setTime(trueDate);
c.add(Calendar.MINUTE, i);
int Buy = Math.round(Float.parseFloat(String.valueOf(c1.get(i).get(2))));//买
int Sell = Math.round(Float.parseFloat(String.valueOf(c1.get(i).get(3))));//卖
timeseries.addOrUpdate(new Minute(c.getTime()), (Sell - Buy) / 50);
return timeseries;
}
然後我有方法调用这个方法
public void timeseries() {
for (int i = 0; i < 301; i++) {
System.out.println("value" + i);
timeseries1 = prepareData1(timeseries1, getsDate(), i);
timeseries2 = prepareData2(timeseries2, getsDate(), i);
timeseries3 = prepareData3(timeseries3, getsDate(), i);
timeseries4 = prepareData4(timeseries4, getsDate(), i);
//timeseries5 = prepareData5(timeseries5, getsDate(), i);
timeseries6 = prepareData6(timeseries6, getsDate(), i);
repaint();
// validate();
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {}
}
}
我这调用方法的时候有试著重绘,但是都试等回圈跑完才重绘??
不知道有没有办法跑一次绘制一次???
求大大们指教,感激不尽!!!! 展开
我再做曲线图我先贴出我绘图的部分!
public TimeSeries prepareData1(TimeSeries timeseries, String date, int i) {
Calendar c = Calendar.getInstance();
Date trueDate = DateUtil.formatDate("yyyyMMddHHmm", date + "0845");
c.setTime(trueDate);
c.add(Calendar.MINUTE, i);
int Buy = Math.round(Float.parseFloat(String.valueOf(c1.get(i).get(2))));//买
int Sell = Math.round(Float.parseFloat(String.valueOf(c1.get(i).get(3))));//卖
timeseries.addOrUpdate(new Minute(c.getTime()), (Sell - Buy) / 50);
return timeseries;
}
然後我有方法调用这个方法
public void timeseries() {
for (int i = 0; i < 301; i++) {
System.out.println("value" + i);
timeseries1 = prepareData1(timeseries1, getsDate(), i);
timeseries2 = prepareData2(timeseries2, getsDate(), i);
timeseries3 = prepareData3(timeseries3, getsDate(), i);
timeseries4 = prepareData4(timeseries4, getsDate(), i);
//timeseries5 = prepareData5(timeseries5, getsDate(), i);
timeseries6 = prepareData6(timeseries6, getsDate(), i);
repaint();
// validate();
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {}
}
}
我这调用方法的时候有试著重绘,但是都试等回圈跑完才重绘??
不知道有没有办法跑一次绘制一次???
求大大们指教,感激不尽!!!! 展开
1个回答
展开全部
把你的循环操作放到一个单独的线程里执行,如果想看清楚每次重绘的效果,还需要加sleep
public void timeseries() {
Thread t = new Thread() {
public void run() {
for (int i = 0; i < 301; i++) {
System.out.println("value" + i);
timeseries1 = prepareData1(timeseries1, getsDate(), i);
timeseries2 = prepareData2(timeseries2, getsDate(), i);
timeseries3 = prepareData3(timeseries3, getsDate(), i);
timeseries4 = prepareData4(timeseries4, getsDate(), i);
//timeseries5 = prepareData5(timeseries5, getsDate(), i);
timeseries6 = prepareData6(timeseries6, getsDate(), i);
repaint();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
}
}
};
t.start();
}
更多追问追答
追问
可以正常实施了,是我没搞清楚,执行绪呀!!!!
那我想请问你一下,如果我要连接标记线??
那函数是要引用哪一个???
追答
TimeSeries图的话自动应该会把你输入的数据点连接到一起出现折线图啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询