Clear annoations added on Renderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
nubiste
Posts: 13
Joined: Mon Aug 04, 2008 9:53 am

Clear annoations added on Renderer

Post by nubiste » Fri Aug 29, 2008 11:48 am

Hi,

I have a problem deleting annotations that I've added on a LineAndShape or Step renderer.

plot.clearAnnotations() works fine for annotations added with the plot.addAnnotation(annotation) method.

When added with renderer.addAnnotation(annotation) method calling clearAnnotations on the plot does nothing. Which seems reasonable... but how do I clear annotations added on the renderer?

Thanks
Stelios

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

Post by david.gilbert » Fri Aug 29, 2008 1:06 pm

It seems the equivalent to clearAnnotations() in the renderer is removeAnnotations(). I think I will rename it for consistency.
David Gilbert
JFreeChart Project Leader

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

nubiste
Posts: 13
Joined: Mon Aug 04, 2008 9:53 am

Post by nubiste » Fri Aug 29, 2008 1:42 pm

Can't believe I didn't see that, its clear enough in any case...

btw I noticed in the XYTextAnnotation if you put a carriage return it does have effect but you can't see the line that goes under. Is there any standard way to overcome this, do I need to override the XYTextAnnotation class?

thanks
stelios

nubiste
Posts: 13
Joined: Mon Aug 04, 2008 9:53 am

Post by nubiste » Fri Aug 29, 2008 1:45 pm

sorry for the many posts..
Is there any advantage on adding the annotation on the renderer instead of the plot. Both seem to work fine, is the only difference the event they fire?

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

Post by david.gilbert » Fri Aug 29, 2008 3:30 pm

nubiste wrote:Is there any advantage on adding the annotation on the renderer instead of the plot. Both seem to work fine, is the only difference the event they fire?
Attaching annotations to a particular renderer is just a way of enabling annotations to be plotted against secondary axes. The annotations attached to the plot are always plotted against the primary axes.
David Gilbert
JFreeChart Project Leader

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

Locked