Menu

#279 Mousewheel Zoom Out in LogAxis Fixed

open
nobody
None
5
2012-11-27
2011-05-27
No

If you use the mousewheel to zoom out on a LogAxis the function ValueAxis.resizeRange2 sometimes changes the lowerBound of the axis range to a negativ value which isn't possible with a LogAxis.

Solution:
override the function resizeRange2 in LogAxis with the following function:

/**
* Increases or decreases the axis range by the specified percentage about
* the specified anchor value and sends an {@link AxisChangeEvent} to all
* registered listeners.
* <P>
* To double the length of the axis range, use 200% (2.0).
* To halve the length of the axis range, use 50% (0.5).
*
* @param percent the resize factor.
* @param anchorValue the new central value after the resize.
*
* @see #resizeRange(double)
*
* @since 1.0.13
*/
@Override
public void resizeRange2(double percent, double anchorValue) {
if (percent > 0.0) {
double left = anchorValue - getLowerBound();
double right = getUpperBound() - anchorValue;
Range adjusted = new Range(anchorValue - left * percent,
anchorValue + right * percent);
if(adjusted.getLowerBound()<=0) return;
setRange(adjusted);
}
else {
setAutoRange(true);
}
}

Discussion


Log in to post a comment.