JfreeChart 在RCP的view曲线图有关问题!
JfreeChart 在RCP的view曲线图问题!!
原帖在这里:
http://bbs.****.net/topics/350035255
在createPartControl()中加了这个线程, 但是只有System.out.println("************")打印, 而不能显示曲线, 不知道这是为什么?
就是以下的while放在哪里才正确?
------解决思路----------------------
你先写个简单 的 jfreechart 测试看看。
------解决思路----------------------
while应该放到线程的run方法中,同样的sleep也是
你放到里面,那个run方法是在ui线程执行的,一个死循环UI显然就没响应了
------解决思路----------------------
这个肯定不是你的代码吧... 看不到具体的代码没法说
关于异步更新界面, 推荐你看一下这个文章:
http://blog.****.net/dollyn/article/details/38582743
原帖在这里:
http://bbs.****.net/topics/350035255
在createPartControl()中加了这个线程, 但是只有System.out.println("************")打印, 而不能显示曲线, 不知道这是为什么?
就是以下的while放在哪里才正确?
public void createPartControl(Composite parent) {
timeSeries = new TimeSeries("异常报文", Millisecond.class);
timeSeries1 = new TimeSeries("超时报文", Millisecond.class);
timeSeries2 = new TimeSeries("正常报文", Millisecond.class);
timeSeries.add(new Millisecond(), (long) (Math.random() * 10 ));
timeSeries1.add(new Millisecond(), (long) (Math.random() * 30));
timeSeries2.add(new Millisecond(), (long) (Math.random() * 100));
final JFreeChart viewChart = createChart();
final ChartComposite frame = new ChartComposite(parent, SWT.NONE, viewChart, true);
frame.setDisplayToolTips(true);
frame.setHorizontalAxisTrace(false);
frame.setVerticalAxisTrace(false);
final Display display = Display.getCurrent();
new Thread(){
public void run() {
display.asyncExec(new Runnable(){
public void run() {
while(true) {
System.out.println("************");
timeSeries.addOrUpdate(new Millisecond(), (long) (Math.random() * 10 ));
timeSeries1.addOrUpdate(new Millisecond(), (long) (Math.random() * 30));
timeSeries2.addOrUpdate(new Millisecond(), (long) (Math.random() * 100));
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
};
}.start();
}
------解决思路----------------------
你先写个简单 的 jfreechart 测试看看。
------解决思路----------------------
while应该放到线程的run方法中,同样的sleep也是
你放到里面,那个run方法是在ui线程执行的,一个死循环UI显然就没响应了
------解决思路----------------------
这个肯定不是你的代码吧... 看不到具体的代码没法说
关于异步更新界面, 推荐你看一下这个文章:
http://blog.****.net/dollyn/article/details/38582743