Java Code Examples for org.jfree.data.RangeType#POSITIVE

The following examples show how to use org.jfree.data.RangeType#POSITIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberAxis.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 2
Source File: NumberAxis.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 3
Source File: NumberAxis.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 4
Source File: NumberAxis.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 5
Source File: NumberAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 6
Source File: NumberAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }
        
        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 7
Source File: NumberAxis.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}
 
Example 8
Source File: NumberAxis.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        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 (getAutoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        }
        else {
            // ensure the autorange is at least <minRange> in size...
            double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                double expand = (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
                if (lower == upper) { // see bug report 1549218
                    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 (getAutoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                }
                else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                }
                else {
                    lower = lower - getLowerMargin() * range;
                }
            }
            else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        setRange(new Range(lower, upper), false, false);
    }

}