开发者

Animation swingworker threading and timer

I must animate two graphs. Both graphs are related.

One graph display cartography of colour, and the other is diplaying a curve. I got values for the graph from a file.

So i must do 3 things in order to animate the graphs:

  • read values in the file build some array of object to hold the values
  • draw a curve progressively from the r开发者_开发百科ead values
  • draw one line in other graph from the read values

Each of these task must be repeated every x seconds. At the moment I'm doing it using a swing timer and a class extending SwingWorker. In the doInBackground method i read the file, loop through the values to build my object and fill an array.

In the process method I use some the array to build the curve, and in the done method I draw the line. But the result is not what I intend to do. The curve is drawing to fast. For exemple if I execute the timer every 2 seconds then the curve must take 2 seconds from one end of the graph to reach the other end. Then I must draw one line in the other graph. At the moment the curve is drawn at once every two seconds.

How can I organize this in different thread if possible ?


I'd suggest to take a look at Trident animation library. It will simplify a lot of this for you.


The curve is drawing to fast. For exemple if i execute the timer every 2 seconds then the curve must take 2 seconds from one end of the graph to reach the other end

Then start a second Timer within the first timer when it fires.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜