I've seen lots of threads about getting the plot coordinates of the mouse cursor, and I could manage to do that with the last release using some code like
Code: Select all
Point2D translate(Point p){
XYPlot plot = panel.getChart().getXYPlot();
Point2D p2D = panel.translateScreenToJava2D(p);
swap(p2D);
p2D.setLocation(plot.getDomainAxis().java2DToValue(p2D.getX(), panel.getScreenDataArea(), plot.getDomainAxisEdge()),plot.getRangeAxis().java2DToValue(p2D.getY(), panel.getScreenDataArea(), plot.getRangeAxisEdge())) ;
return p2D ;
}
This seems to work fine, but when rescaling the ChartPanel or the Frame holding it, the results are not correct anymore.
I read in the previous posts that the Rectangle passed as parameter to java2DToValue had to be scaled but I thought the method getScreenDataArea alread returns a scaled area ... the API changed a bit since the last posts about that so I'm a bit confused.
Any clue ?
Thanks,
Cédric.