How to disable scaling by mouse dragging without disconnecting using mousewheellistener in jfreechart?

I would like to disable zoom when dragging with the mouse (which draws this rectangle), but does not disable zoom with MouseWheel. I found in another topic how to disable reset scaling when dragging the mouse left (restoreAutoBounds), and I am wondering how to solve this problem. Is there a small combination for this?

+5
source share
2 answers

Ok, I did this 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 the axis of the domain.

+3
source

. , :

chartPanel.setZoomTriggerDistance(Integer.MAX_VALUE);
chartPanel.setFillZoomRectangle(false);
chartPanel.setZoomOutlinePaint(new Color(0f, 0f, 0f, 0f));
+1

All Articles