I created an XYLineChart and because the data was related to subsurface I inverted the range axis. Everything was fine - then I decided to add XYBoxAnnotation and couldn't get it to show up. After re-trying the demo and getting it to work I decided to comment out the axis invert statement and there was the box anno. Is this a known bug or is there some workaround that I can use to get the boxanno to work with the inverted y axis?
Thanks
XYBoxAnnotation
-
- Posts: 15
- Joined: Wed Nov 07, 2007 6:20 pm
Re: XYBoxAnnotation
I am having the same problem. Was there ever any resolution to this issue?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: XYBoxAnnotation
I just checked the source code for XYBoxAnnotation.
The annotation creates a Rectangle by converting the x0, x1, y0 and y1 coordinates (which are in data space) to java2D space. If one of the axis is inverted, then either the width or the height of the resulting rectangle will be < 0.
Solution: add this block to the source of XYBoxAnnotation, ahead of the line Rectangle2D box = null;
[edit: the source of XYBoxAnnotation needs to be edited, of course]
The annotation creates a Rectangle by converting the x0, x1, y0 and y1 coordinates (which are in data space) to java2D space. If one of the axis is inverted, then either the width or the height of the resulting rectangle will be < 0.
Solution: add this block to the source of XYBoxAnnotation, ahead of the line Rectangle2D box = null;
Code: Select all
if(transX0 > transX1){
double temp = transX0;
transX0 = transX1;
transX1 = temp;
}
if(transY1 > transY0){
double temp = transY0;
transY0 = transY1;
transY1 = temp;
}