how to draw annotations in view coordinates?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
whfolsom4
Posts: 2
Joined: Wed Oct 07, 2009 7:35 pm
antibot: No, of course not.

how to draw annotations in view coordinates?

Post by whfolsom4 » Wed Oct 07, 2009 7:48 pm

Apologies if this has been posted elsewhere - my search did not turn up a relevant answer. I have an issues with JFreeChart annotations - I would like to draw one of several Shapes at a given size, say 10x10 pixels. However, the Annotation API appears to require data space coordinates.

I am able to calculate this using the java2DToValue() method after the plot has been rendered, but this causes two side effects:
1. I cannot initially add the annotations prior to the XYPlot beign realized because this method returns Double.Infinity in that case.
2. If I zoom the plot, the annotation is scaled as well.

I would actually like to draw a specific shape in Java2D graphics context coordinates. Is this possible?

Thanks!

whfolsom4
Posts: 2
Joined: Wed Oct 07, 2009 7:35 pm
antibot: No, of course not.

Re: how to draw annotations in view coordinates?

Post by whfolsom4 » Mon Oct 12, 2009 4:02 pm

I ended up implementing my own subclass of AbstractXYAnnotation which translates but does not scale the Shape to solve problem #2. This also fixes problem #1 because the call to java2DToValue() is now made within the annotation's draw() method, not before the chart component has been realized.

korvus
Posts: 5
Joined: Mon Apr 28, 2008 7:14 pm

Re: how to draw annotations in view coordinates?

Post by korvus » Mon Nov 09, 2009 9:00 pm

Can you provide your changes? I'm looking to do something similar and would love to avoid developing the same solution...

Locked