[英]JFreeChart get mouse coordinates
在JFreeChart中有没有办法从ChartMouseEvent确定鼠标结束的x,y坐标(在绘图空间中)? 我尝试使用域十字准线值,但这看起来不准确,并且滞后于实际的鼠标事件。
谢谢,
杰夫
getTrigger()
鼠标坐标是相对于ChartPanel的,所以你需要转换它们:
Point2D p = chartPanel.translateScreenToJava2D(mouseChartEvent.getTrigger().getPoint());
Rectangle2D plotArea = chartPanel.getScreenDataArea();
XYPlot plot = (XYPlot) chart.getPlot(); // your plot
double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.