作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有 2 个子图 (XYPlot) 的 JFreeChart
。
我有 XYImageAnnotation
,我想将其变成按钮,但我找不到监听鼠标点击任何注释的方法。
你知道有什么方法可以做到这一点吗?
最佳答案
I have no idea how to listen [for] click from annotations
在您的 ChartMouseListener
中,您将获得一个 ChartMouseEvent
。使用它来获取作为 XYAnnotationEntity
的 ChartEntity
。
chartPanel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent cme) {
ChartEntity ce = cme.getEntity();
if (ce instanceof XYAnnotationEntity) {
// handle the click
}
}
}
否则,请查找您添加注释的 XYItemEntity
。
关于java - JFreeChart XYPlot XYImageAnnotation 鼠标点击监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35043299/
我在 JFreeChart - XYLineChart 上绘制图像时遇到困难。主要问题是注释的 x 和 y 坐标是实时动态更新的。因此,在我的代码中添加注释并清除注释以绘制新注释会导致闪烁,这对用户来
我有一个带有 2 个子图 (XYPlot) 的 JFreeChart。 我有 XYImageAnnotation,我想将其变成按钮,但我找不到监听鼠标点击任何注释的方法。 你知道有什么方法可以做到这一
我是一名优秀的程序员,十分优秀!