Hi,
When I'm using the standard linear axis (X and Y), I can draw elipses around my selected XYPlot chart points using the XYShapeAnnotation and they appear as I expect (i.e circles aroudn the points).
However when I create XYPlot charts with a log axis using LogarithmicAxis for example on the y axis these same elipses no longer draw circles but flattened or stretched elipses of differing sizes.
I believe this is because the height and width I am using needs to be adjusted to log rather than linear values, but weas hoping there was some facility related to the LogarithmicAxis which could convert this for me.
Any idea's how to get my elipses looking like circles again on a log scale?
Thanks
Snoopygee
Logarithmic XYShapeAnnotation
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Logarithmic XYShapeAnnotation
You probably need to write a custom annotation for this, one that positions a circle centered on some (x, y) value, but leaves the width and height at some fixed size (so as not to be distorted by the log axes).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Re: Logarithmic XYShapeAnnotation
Hi David,
That sounds like a great approach!
Without meaning to sound like I want you to write the whole thing for me, I'm not entirely sure how to approach writing a custom annotation class. Any suggestions on the approach would be much appreciated.
Would you suggest simply replacing the draw method of the XYShapeAnnotation class to ignore the width and height?
Thanks
Snoopygee
That sounds like a great approach!
Without meaning to sound like I want you to write the whole thing for me, I'm not entirely sure how to approach writing a custom annotation class. Any suggestions on the approach would be much appreciated.
Would you suggest simply replacing the draw method of the XYShapeAnnotation class to ignore the width and height?
Thanks
Snoopygee
Re: Logarithmic XYShapeAnnotation
Hi,
In order to achieve what you have suggested would you suggest replacing the draw method of the XYShapeAnnotation class to ignore the width and height?
Thanks
Snoopygee
In order to achieve what you have suggested would you suggest replacing the draw method of the XYShapeAnnotation class to ignore the width and height?
Thanks
Snoopygee
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Logarithmic XYShapeAnnotation
Kind of. The present XYShapeAnnotation uses two AffineTransforms to define the position and the size of the shape. In order to get what you want, you could try the following:snoopygee wrote: In order to achieve what you have suggested would you suggest replacing the draw method of the XYShapeAnnotation class to ignore the width and height?
- use a Shape centered at (0,0).
- translate that Shape with an AffineTransform to the x,y-location in java2D space (you can use valueToJava2D(...) method to translate the data coordinates to java2D coordinates) and draw it.