Even i do not call run() chart is not updated. May be I make a mistake.
Jérôme Serré ____________________________ Manage your cellar <http://www.macave.eu/> http://www.macave.eu De : Greg Brown [mailto:[email protected]] Envoyé : lundi 21 novembre 2011 15:13 À : [email protected] Objet : Re: How to refresh a HighLowChartView You don't need to call run() on the return value. Just call queueCallback() - the system will take care of running it for you later. If you call run() yourself, it still gets executed on the background thread. On Nov 21, 2011, at 8:45 AM, Jérôme Serré wrote: I wrote ProcessClass: public void run() { bla bla bla ApplicationContext.queueCallback(myChart).run(); } My chart implements runnable And myChart.run() { ((ValueSeries<Candlestick>)this.getChartData().get(0)).add(recordToCandlesti ck(record)); } Is it correct ? Jérôme Serré ____________________________ Manage your cellar <http://www.macave.eu/> http://www.macave.eu De : Greg Brown [mailto:[email protected]] Envoyé : lundi 21 novembre 2011 14:04 À : [email protected] Objet : Re: How to refresh a HighLowChartView It sounds like you might still be updating the UI from the background thread. Have you updated your code to use ApplicationContext#queueCallback()? On Nov 19, 2011, at 3:56 AM, Jérôme Serré wrote: Ok, I didnt know. It works. Thank you Greg. But there is a but J For the changes to appear on the chart I must "move" by hand. How can I get it to refresh automatically ? Jérôme Serré ____________________________ Manage your cellar <http://www.macave.eu/> http://www.macave.eu De : Greg Brown <mailto:[mailto:[email protected]]> [mailto:[email protected]] Envoyé : vendredi 18 novembre 2011 23:11 À : <mailto:[email protected]> [email protected] Objet : Re: How to refresh a HighLowChartView You can't call any method that will update the UI from a background thread. Most UI toolkits have a similar restriction. On Nov 18, 2011, at 5:03 PM, Jérôme Serré wrote: Correct. In fact in the run method (daemon) I add a Record in a pivot arrayList and my Chart Class (and some others) listen this event : public void itemInserted(List<T> list, int index) { Update ChartData } Ok, I think, I cannot use the event ? Jérôme Serré ____________________________ Manage your cellar http://www.macave.eu <http://www.macave.eu/> De : Greg Brown <mailto:[mailto:[email protected]]> [mailto:[email protected]] Envoyé : vendredi 18 novembre 2011 21:17 À : <mailto:[email protected]> [email protected] Objet : Re: How to refresh a HighLowChartView I assume you have an implementation of Runnable that performs the background action of your thread, correct? When the thread's run() method completes, you need to call ApplicationContext#queueCallback() with a new Runnable that updates your UI. On Nov 18, 2011, at 2:59 PM, Jérôme Serré wrote: Im really sorry but i dont understand. public class Test implements Application { **** some components *** final Thread t = ExtractProcess.getProcess(resolution, data, chart); ApplicationContext.queueCallback(t).run(); The thread is running but none graphics elements are visible on ihm ! Jérôme Serré ____________________________ Manage your cellar http://www.macave.eu <http://www.macave.eu/> De : Greg Brown <mailto:[mailto:[email protected]]> [mailto:[email protected]] Envoyé : vendredi 18 novembre 2011 19:29 À : <mailto:[email protected]> [email protected] Objet : Re: How to refresh a HighLowChartView I tested without thread and it works, I use Thread not TaskAdapter or ApplicationContext#queueCallback() May I keep Thread and use ApplicationContext#queueCallback() Yes. And How to use it ? Just put the code you want to run on the UI thread in the run() method (same as SwingUtilities#invokeLater() in Swing).
