jxlayer and annotation

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

jxlayer and annotation

Post by develop » Thu Apr 02, 2009 1:25 pm

Hi David,

you suggested in some other post, that jxlayer can be used with Jfreechart. so here is i am thinking.
I need to show TextAnnotation on chart. (real time, updates about 4 times a second)
when i change the value of annotation i have to call chart.setNotify(true) which will repaint the whole chart which will be cpu intensive.
instead if i use JXlayer to show TextAnnotation on top of chart and just update that instead of updating whole chart ?
is this idea of mine is even considerable ? should i even try or just forget about that?

i will really appreciate some thoughts here. and some idea about reducing cpu load.

Thanks

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: jxlayer and annotation

Post by david.gilbert » Thu Apr 02, 2009 2:09 pm

I have used JXLayer on a client project to draw crosshairs over a plot. It works quite nicely, but I'm wondering now if JXLayer is strictly necessary for this. It still results in a repaint of the underlying chart, but if the chart doesn't change and the ChartPanel uses an offscreen image buffer then the performance is still good. What I'm experimenting with right now is to do away with the JXLayer dependency and just add the concept of an Overlay for the ChartPanel, where the Overlay interface has a method something like this:

Code: Select all

public void paintOverlay(Graphics2D g2, ChartPanel chartPanel);
...and the ChartPanel manages list of 0, 1 or many overlays that it draws AFTER the chart has been drawn/painted. I'm pretty sure this will work for plain drawing, I'm less sure that it will offer the same facilities as JXLayer when it comes to capturing mouse and keyboard events.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Re: jxlayer and annotation

Post by develop » Fri Apr 03, 2009 1:44 pm

Thanks david for reply, can you roughly say how much time it will take before this overlay functionality incorporated into jfreechart ?
does this concept can be used to improve performance of overall chart ?

i agree with you about not creating dependency on jxlayer after reading your reply.

Thanks

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: jxlayer and annotation

Post by david.gilbert » Mon Apr 06, 2009 8:48 am

I might get it into the 1.0.13 release (which is already late). It does increase performance, but only to the extent that it does the layer rendering separately from the chart rendering, which means that you can rely on the off-screen chart buffer to "blit" the chart onto the panel (assuming nothing in the underlying chart has changed) then use Java2D calls to draw the layer stuff on top of that.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Re: jxlayer and annotation

Post by develop » Mon Apr 06, 2009 3:32 pm

Thanks a lot for reply.
This would definitely help. i cant wait to see 1.0.13

Locked