如何通过拖动鼠标禁用缩放而不通过jfreechart中的mousewheellistener禁用? [英] How to disable zoom by mouse dragged without disabling by mousewheellistener in jfreechart?

查看:116
本文介绍了如何通过拖动鼠标禁用缩放而不通过jfreechart中的mousewheellistener禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过鼠标拖动(绘制该矩形)禁用缩放,但不禁用MouseWheel缩放。我在另一个主题中找到了如何在将鼠标向左拖动(restoreAutoBounds)时禁用缩放重置,我对如何解决此问题感兴趣。有没有一点快捷方式呢?

I would like to disable zooming by mouse dragging(which paints that rectangle), but not disable zooming by MouseWheel. I found in another topic how to disable zoom reset while dragging mouse to left (restoreAutoBounds) and I'm interested in how to solve this problem. Is there a little shortcut to do that?

推荐答案

好的,我已经完成了,重写了MouseWheelListener。在chartPannel.setMouseZoomable(false)之后。:

Ok, I've done it, by overriding MouseWheelListener. After chartPannel.setMouseZoomable(false).:

chartPanel.addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent arg0) {
            if (arg0.getWheelRotation() > 0) {
                chartPanel.zoomOutDomain(0.5, 0.5);
            } else if (arg0.getWheelRotation() < 0) {
                chartPanel.zoomInDomain(1.5, 1.5);
            }
        }
    });

缩放(输入/输出)域,因为我只想重新缩放域轴。

zoom(In/Out)Domain, because I wanted to rescale only domain axis.

这篇关于如何通过拖动鼠标禁用缩放而不通过jfreechart中的mousewheellistener禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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