在JChart2D中获取光标的坐标 [英] Get coordinates of cursor in JChart2D

查看:92
本文介绍了在JChart2D中获取光标的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JChart2D跟踪双精度数组的值.我正在使用ZoomableChart,并且当光标停留在代码中的ZoomableChart上时,我想获取光标的坐标(x,y),以在JLabel中显示它们并画一条垂直线.

I'm using JChart2D for trace a values of a double array. I'm using ZoomableChart and I want get coordinates (x, y) of cursor when this stay over ZoomableChart in my code to show them in a JLabel and draw a vertical line.

  • 如何获取光标的坐标?
  • 我怎么画这条线?

推荐答案

很简单.将 MouseMotionListener 添加到 ZoomableChart .

To get a point is easy. Add a MouseMotionListener to the ZoomableChart.

我猜您希望此信息表示图表中数据中的点,而不是可能缩放的ZoomableChart组件本身中的点.为此,您需要查找类似的内容(浏览我今天听说过的今天"课程的文档.)

I'm guessing you want this information to represent a point in the data in the chart, rather than in the potentially zoomed ZoomableChart component itself. For that you'll need to look to something like (trawling through the docs for a class I heard of 'today'..) Chart2D.getPointFinder(), the finder apparently offers getNearestPoint(MouseEvent,Chart2D) to map a MouseEvent back to the underlying structure.

去吧! :)

这篇关于在JChart2D中获取光标的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆