5

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?

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
Bernard Burn
  • 661
  • 5
  • 20

2 Answers2

3

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.

Bernard Burn
  • 661
  • 5
  • 20
1

The mouse wheel listener implementation in the previous answer removes the zoom animation and does not zoom from the current mouse position. I found a workaround by hidding the rectangle using a transparent paint:

chartPanel.setZoomTriggerDistance(Integer.MAX_VALUE);
chartPanel.setFillZoomRectangle(false);
chartPanel.setZoomOutlinePaint(new Color(0f, 0f, 0f, 0f));
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
JDM
  • 83
  • 1
  • 6