Prevent repaint requests to be queued / check queue

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
KurtP
Posts: 3
Joined: Fri Dec 03, 2010 8:35 pm
antibot: No, of course not.

Prevent repaint requests to be queued / check queue

Post by KurtP » Tue Mar 08, 2011 10:16 pm

Hi - in an attempt to speed up updating my chart I learned about chart.setNotify(). Because multiple series' are updated at regular intervalls I set chart.setNotify(false), update the series', and then set chart.setNotify(true), which helped a lot compared to the previous version.

Nevertheless, updating my chart takes a few seconds, and while the chart is updating, the rest of the application does not respond. An interesting observation was that the chart updates itself (2 or 3 times) after I stopped adding new data. It appears as if the repaint requests are queued.

This has also been mentioned in a post from skunk (http://www.jfree.org/phpBB2/viewtopic.p ... eue#p83648):
In my experience, the most important thing is a design that never allows repaint requests to be queued. If 10 data updates arrive before the system has a chance to repaint the chart, you dont need to display the 9 stale states as long as the chart displays all the accumulated changes when it finally is repainted.
My question is how do I prevent repainting requests to be queued, repectively, how is it possible to check if the repaint queue is empty before setting chart.setNotify(true) again?

Thanks,
Kurt

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Prevent repaint requests to be queued / check queue

Post by paradoxoff » Wed Mar 09, 2011 9:33 pm

Not sure whether this is a good idea or will even work:
you could override ChartPanel and implement public void chartProgress(ChartProgressEvent event) and override repaint(),
In chartProgress, you could check for ChartProgressEvent.DRAWING_STARTED, and if true, set a flag that makes your overriden repaint() method to do nothing. Once you receive a ChartProgressEvent.DRAWING_FINISHED, call super.repaint() to finally make the changes visible by a single rendering pass.

Locked