Bug/suggestion for mouse wheel zooming

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
JGoodwin
Posts: 27
Joined: Thu Sep 06, 2007 3:19 am
Location: Boston USA

Bug/suggestion for mouse wheel zooming

Post by JGoodwin » Wed Sep 09, 2009 10:24 pm

Hi,

I found it unexpected that ChartPanel.setRangeZoomable(false)
does not affect mouse-wheel zooming. I dont' see any obvious
design motivation for that, so I suppose it's just an oversight.

The fix seems simple: MouseWheelHandler in handleZoomable
should check Chartpanel.isRangeZoomable before calling
zoomRangeAxes (and analogously for the domain axes).

The original code was:

Code: Select all

 		if (direction > 0) {
			zoomable.zoomDomainAxes(increment, pinfo, p, true);
			zoomable.zoomRangeAxes(increment, pinfo, p, true);
		} else if (direction < 0) {
			zoomable.zoomDomainAxes(1.0 / increment, pinfo, p, true);
			zoomable.zoomRangeAxes(1.0 / increment, pinfo, p, true);
		}
My modified code is:

Code: Select all

		if (direction < 0)
			increment = 1.0 / increment;
		if (chartPanel.isRangeZoomable())
			zoomable.zoomRangeAxes(increment, pinfo, p, true);
		if (chartPanel.isDomainZoomable())
			zoomable.zoomDomainAxes(increment, pinfo, p, true);
In case anyone else has this issue before a new release:
To patch 1.0.13, I subclassed MouseWheelHandler to fix the
original bug, then subclassed ChartPanel to use my class
instead of the usual one, then fixed my own code to cons
up my own class of ChartPanel. Eccch. YMMV.

/jim

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Bug/suggestion for mouse wheel zooming

Post by david.gilbert » Thu Sep 10, 2009 8:28 am

Hi Jim,

Thanks for the report. I committed your fix to Subversion for inclusion in the 1.0.13 release.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked