本文介绍了Jfree图表查找子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CombinedDomainXYPlot,可以在需要时在其中添加子图.
我使用了自定义的JPopup菜单,并包含了一个菜单项,旨在为用户提供删除特定子图的功能
我假设可以使用主图的findSubplot方法找到一个子图.我可以获取鼠标位置,但无法使用PlotRenderingInfo做为输入所需的任何操作.
这可能是一个非常基本的问题,但是我被困在JFreechart的使用中.
This may sound very basic as a question, but i am stuck in JFreechart use.
让我列出我的问题:
不胜感激.
推荐答案您可以使用 getSubplots() .要了解单击了哪个子图,请检查 ChartMouseEvent 从ChartPanel发送,如此处所示.
You can get a List of subplots using getSubplots(). To learn which subplot was clicked, examine the ChartMouseEvent that was sent from the ChartPanel, as suggested here.
附录:这是ChartMouseListener的简单实现,将在单击每个ChartEntity时显示它们.
Addendum: Here's a simple implementation of ChartMouseListener that will show each ChartEntity as it is clicked.
ChartPanel panel = ... panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { System.out.println(e.getEntity().getClass()); } @Override public void chartMouseMoved(ChartMouseEvent event) {} });更多推荐
Jfree图表查找子图
发布评论