Jfree图表查找子图 [英] Jfree chart Find Subplot

查看:36
本文介绍了Jfree图表查找子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题,但是我被困在JFreechart的使用中.

This may sound very basic as a question, but i am stuck in JFreechart use.

让我列出我的问题:

  1. 我有一个CombinedDomainXYPlot,可以在需要时在其中添加子图.
  2. 我使用了自定义的JPopup菜单,并包含了一个菜单项,旨在为用户提供删除特定子图的功能
  3. 我假设可以使用主图的findSubplot方法找到一个子图.我可以获取鼠标位置,但无法使用PlotRenderingInfo做为输入所需的任何操作.

不胜感激.

推荐答案

您可以使用 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图表查找子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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