}
if (plot instanceof ValueAxisPlot) {
final ValueAxisPlot vap = (ValueAxisPlot) plot;
Range r = vap.getDataRange(this);
if (r == null) {
r = new Range(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND);
}
double upper = r.getUpperBound();
double lower = r.getLowerBound();
if (this.rangeType == RangeType.POSITIVE) {
lower = Math.max(0.0, lower);
upper = Math.max(0.0, upper);
} else if (this.rangeType == RangeType.NEGATIVE) {
lower = Math.min(0.0, lower);
upper = Math.min(0.0, upper);
}
if (this.getAutoRangeIncludesZero()) {
lower = Math.min(lower, 0.0);
upper = Math.max(upper, 0.0);
}
final double range = upper - lower;
// if fixed auto range, then derive lower bound...
final double fixedAutoRange = this.getFixedAutoRange();
if (fixedAutoRange > 0.0) {
lower = upper - fixedAutoRange;
} else {
// ensure the autorange is at least <minRange> in size...
final double minRange = this.getAutoRangeMinimumSize();
if (range < minRange) {
final double expand = (minRange - range) / 2;
upper = upper + expand;
lower = lower - expand;
if (lower == upper) { // see bug report 1549218
final double adjust = Math.abs(lower) / 10.0;
lower = lower - adjust;
upper = upper + adjust;
}
if (this.rangeType == RangeType.POSITIVE) {
if (lower < 0.0) {
upper = upper - lower;
lower = 0.0;
}
} else if (this.rangeType == RangeType.NEGATIVE) {
if (upper > 0.0) {
lower = lower - upper;
upper = 0.0;
}
}
}
if (this.getAutoRangeStickyZero()) {
if (upper <= 0.0) {
upper = Math.min(0.0, upper + this.getUpperMargin()
* range);
} else {
upper = upper + this.getUpperMargin() * range;
}
if (lower >= 0.0) {
lower = Math.max(0.0, lower - this.getLowerMargin()
* range);
} else {
lower = lower - this.getLowerMargin() * range;
}
} else {
upper = upper + this.getUpperMargin() * range;
lower = lower - this.getLowerMargin() * range;
}
}
this.setRange(new Range(lower, upper), false, false);
}
}