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!
how to draw annotations in view coordinates?
Re: how to draw annotations in view coordinates?
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.
Re: how to draw annotations in view coordinates?
Can you provide your changes? I'm looking to do something similar and would love to avoid developing the same solution...