FreeChart交互式图表编辑处理ChartMouseEven

FreeChart交互式图表编辑处理ChartMouseEven

本文介绍了JFreeChart交互式图表编辑处理ChartMouseEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试拦截ChartMouseEvent以修改使用ChartFactory.createXYLineChart方法创建的JFreeChart对象的XYSeries(并使用JDialog显示)。I'm trying to intercept ChartMouseEvent in order to modify an XYSeries of a JFreeChart object created with ChartFactory.createXYLineChart method (and displayed using a JDialog).我成功检索鼠标事件的坐标这样:I retrieve successfully the coordinate of the mouse event this way:public void chartMouseMoved(ChartMouseEvent arg0) { int x = arg0.getTrigger().getX(); int y = arg0.getTrigger().getY();坐标系(0,0)的原点位于图片中的红色方块。 现在,我想计算鼠标在哪个区间。为了做到这一点,我需要:The origin of the coordinate system (0,0) is located at the red square in the picture.Now, I would like to calculate in which interval is the mouse in. In order to do this I need: 灰色图表的左上角坐标(绿色方块) 灰色图表的高度和宽度我怎样才能得到这个值?How can I get this values?注意:我是JFreeChart的新手。如果我做错了,并且有更好的方法来实现这些目标,请让我朝着正确的方向前进。A note: I'm a JFreeChart newbie. If I'm doing this wrong, and there is a better way to do achive these goals, please put me in the right direction.推荐答案您是通过 ChartPanel 渲染地图吗?如果是,请查看 ChartPanel.getChartRenderingInfo()。getPlotInfo()。getDataArea()。这应该返回一个易于使用的 Rectangle2D 。If so, take a look at ChartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(). This should return a Rectangle2D that is easy to work with. 这篇关于JFreeChart交互式图表编辑处理ChartMouseEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 20:50