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?
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.
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With