I want to animate the drawing of XYSplineRenderer
. The animation should be smooth and in the future I want to be able to modify the velocity. But at the moment just a smooth animation would be fine.
I was reading about SwingWorker
and also this thread, however I really cannot figure out how to work with XYSeries
. How should I add points to series
inside doInBackground
(it says that XYSeries is not iterable)?
Any example would be really appreciated.
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
GUI t = new GUI();
t.runCalc();
}
});
}
public void runCalc() {
TwoWorker task = new TwoWorker();
task.addPropertyChangeListener(new PropertyChangeListener() {
});
task.execute();
}
// UNDER CONSTRUCTION !!!
private class TwoWorker extends SwingWorker<Double, Double>
{
@Override
protected XYSeries doInBackground() throws Exception
{
for (int i = 0; i < solution.size(); i++)
{
series.add(solution.point(i).lat(),solution.point(i).lon());
Thread.sleep(1000);
}
return XYSeries;
}
}
P.S. solution
is just the collection of points defined by latitude and longitude. Based on this points, XYSplineRenderer
is constructed.