JFreeChart获取鼠标坐标
在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());
- 使用Google Spreadsheet API在Google中的Google驱动器中创建电子表格
- 如何使用HttpURLConnection和Java中的CookieManager为每个连接使用不同的cookie
- 在使用先前元素值对每个元素执行操作之后,使用Java 8 Stream Reduce返回List
- 我的内部API类是否应该都在一个包中?
- 如何解决’java.lang.OutOfMemoryError:超出GC开销限制’
- 我在哪里可以看到HSQL数据库和表
- 什么是SwingUtilities.invokeLater
- Java 8:为什么我不能将这个二进制字符串解析为long?
- Fitnesse maven-classpath-plugin与Guava jar冲突