XYAnnotation and XYAnnotationEntity

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ted Hill
Posts: 54
Joined: Mon Jun 12, 2006 7:39 pm

XYAnnotation and XYAnnotationEntity

Post by Ted Hill » Tue Jul 11, 2006 9:48 pm

I have created an annotation which extends AbstractXYAnnotation

I add the annotation to my chartPanel's XYPlot.

When I click the mouse on one of these annotations, I call

chartPanel.getEntityForPoint(x,y) in my mouseClicked listener.

getEntityForPoint(x,y) either returns null or returns the tooltip associated with my annotation class when I click on the annotation.

I was expecting that it would return the annotation instance itself.

Is there someway to get the annotation itself when clicking the mouse on it?

Thank you,
Ted Hill

gribas
Posts: 32
Joined: Thu Jan 26, 2006 5:34 pm

Post by gribas » Wed Jul 12, 2006 3:10 pm

Yeah, you could...

...Keep track of your annotations and then iterate through them until you find a match.

...Change XYAnnotationEntity and add a new constructor to receive a XYAbstractAnnotation along with methods to retrieve that annotation object.

...Change XYPlot and create a method to retrieve an annotation given a x,y coordinate similar to getEntityForPoint().

regards,
Gustavo

vtec
Posts: 1
Joined: Sat Aug 25, 2007 4:58 pm

Post by vtec » Sun Aug 26, 2007 2:02 am

Is there anything new on this subject? What I want to do is to highlight annotations which are near the mouse cursor but all I can get with chartPanel.getChartRenderingInfo().getEntityCollection() is ChartEntity objects. Well there exists a XYAnnotationEntity class but it seems that it is not yet in use not to mention connected with XYAnnotation implementation, right? Does anybody have a sample solution and want to share it?

Best regards,

Marcus

Locked