public void calibrate() {

        double minValue = minData;
        double maxValue = maxData;

        if (minAxisFlag== AT_ZERO) {
            minValue = 0;
        } else if (minAxisFlag == AT_VALUE) {
            minValue = this.minValue;
        }

        if (maxAxisFlag== AT_ZERO) {
            maxValue = 0;
        } else if (maxAxisFlag == AT_VALUE) {
            maxValue = this.maxValue;
        }

        double range = maxValue - minValue;
        if (range < 0.0) {
            range = 0.0;
        }

        epsilon = range * 1.0E-10;

        if (isAutomatic) {
            // We must find the optimum minMajorTick and maxMajorTick so
            // that they contain the data range (minData to maxData) and
            // are in the right order of magnitude

            if (range < 1.0E-30) {
                if (minData < 0.0) {
                    majorTick = Math.pow(10.0, Math.floor(log10(Math.abs(minData))));
                    minTick = Math.floor(minData / majorTick) * majorTick;
                    maxTick = 0.0;
                } else if (minData > 0.0) {
                    majorTick = Math.pow(10.0, Math.floor(log10(Math.abs(minData))));
                    minTick = 0.0;
                    maxTick = Math.ceil(maxData / majorTick) * majorTick;
                } else {
                    minTick = -1.0;
                    maxTick = 1.0;
                    majorTick = 1.0;
                }

                minorTick = majorTick;
                majorTickCount = 1;
                minorTickCount = 0;

            } else {
                // First find order of magnitude below the data range...
                majorTick = Math.pow(10.0, Math.floor(log10(range)));

                calcMinTick();
                calcMaxTick();

                calcMajorTick();
                calcMinorTick();
            }
        }

        minAxis = minTick;
        maxAxis = maxTick;

        handleAxisFlags();

        isCalibrated=true;
    }