Example usage for java.lang Float NEGATIVE_INFINITY

List of usage examples for java.lang Float NEGATIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Float NEGATIVE_INFINITY.

Prototype

float NEGATIVE_INFINITY

To view the source code for java.lang Float NEGATIVE_INFINITY.

Click Source Link

Document

A constant holding the negative infinity of type float .

Usage

From source file:com.ericsson.deviceaccess.spi.impl.GenericDevicePropertiesImplTest.java

@Before
public void setup() throws Exception {
    metadataFloat = context.mock(GDPropertyMetadata.class, "metadataFloat");
    metadataArr = new ArrayList<>();
    metadataArr.add(metadataFloat);//  w w  w  .ja v  a  2 s.c o  m

    context.checking(new Expectations() {
        {
            allowing(metadataFloat).getDefaultNumberValue();
            will(returnValue(42.0f));
            allowing(metadataFloat).getDefaultStringValue();
            will(returnValue("42.0"));
            allowing(metadataFloat).getName();
            will(returnValue("fProp"));
            allowing(metadataFloat).getType();
            will(returnValue(Float.class));
            allowing(metadataFloat).getTypeName();
            will(returnValue("Float"));
            allowing(metadataFloat).getValidValues();
            will(returnValue(new String[0]));
            allowing(metadataFloat).getMinValue();
            will(returnValue(Float.NEGATIVE_INFINITY));
            allowing(metadataFloat).getMaxValue();
            will(returnValue(Float.POSITIVE_INFINITY));
            allowing(metadataFloat).serialize(Format.JSON);
            will(returnValue("{\"type\":\"float\"}"));
        }
    });

    props = new GDPropertiesImpl(metadataArr, null);
}

From source file:uk.co.modularaudio.mads.base.stereo_compressor.ui.AttenuationMeter.java

private void refillMeterImage() {
    //      log.debug("Repainting it.");

    if (outBufferedImageGraphics != null) {
        outBufferedImageGraphics.setColor(Color.BLACK);
        outBufferedImageGraphics.fillRect(0, 0, componentWidth, componentHeight);

        final int meterWidth = PREFERRED_METER_WIDTH;
        final int totalMeterHeight = componentHeight - 2;

        final int meterHeight = totalMeterHeight;
        final int meterHeightOffset = 0;

        final int yReverser = meterHeight + 1;

        float levelValue = 0.0f;
        if (currentMeterValueDb != Float.NEGATIVE_INFINITY) {
            levelValue = dbToLevelComputer.toNormalisedSliderLevelFromDb(currentMeterValueDb);
        }/*from  ww w.j a v  a  2s  .com*/

        outBufferedImageGraphics.setColor(OVER_THRESHOLD_COLOR);
        final float underVal = levelValue;
        int underBarHeightInPixels = (int) (underVal * meterHeight);
        underBarHeightInPixels = underBarHeightInPixels > meterHeight ? meterHeight
                : underBarHeightInPixels < 0 ? 0 : underBarHeightInPixels;
        //         int underStartY = meterHeight - underBarHeightInPixels + 1 + meterHeightOffset;
        //         outBufferedImageGraphics.fillRect( 3, underStartY, meterWidth - 4, underBarHeightInPixels );
        final int underStartY = underBarHeightInPixels + 1 + meterHeightOffset;
        outBufferedImageGraphics.fillRect(3, 1, meterWidth - 4, meterHeight - underStartY);

        float minLevelValue = 0.0f;
        final Color maxDbColor = OVER_THRESHOLD_COLOR;
        if (currentMinValueDb != Float.NEGATIVE_INFINITY) {
            minLevelValue = dbToLevelComputer.toNormalisedSliderLevelFromDb(currentMinValueDb);
        }
        outBufferedImageGraphics.setColor(maxDbColor);

        int minValueHeightInPixels = (int) (minLevelValue * meterHeight);
        minValueHeightInPixels = minValueHeightInPixels > meterHeight ? meterHeight
                : minValueHeightInPixels < 0 ? 0 : minValueHeightInPixels;
        final int minStartY = yReverser - minValueHeightInPixels + meterHeightOffset;
        outBufferedImageGraphics.drawLine(1, minStartY, meterWidth, minStartY);

        //      outBufferedImage.flush();
    }
}

From source file:uk.co.modularaudio.mads.base.common.ampmeter.BIAmpMeter.java

private Color getColorForDb(final float dbValue) {
    if (dbValue == Float.NEGATIVE_INFINITY) {
        return Color.green;
    } else if (dbValue > AmpMeter.ORANGE_THRESHOLD_DB) {
        return Color.RED;
    } else if (dbValue > AmpMeter.GREEN_THRESHOLD_DB) {
        return Color.orange;
    } else {//from w w w.  jav a 2  s . c  o m
        return Color.green;
    }
}

From source file:com.anhth12.optimize.solvers.BackTrackLineSearch.java

public double optimize(INDArray line, int lineSearchIteration, double initialStep, INDArray x, INDArray g)
        throws InvalidStepException {
    INDArray oldParameters;/* w w  w .j a  v  a 2 s .c o  m*/
    double slope, test, alamin, alam, alam2, tmplam;
    double rhs1, rhs2, a, b, disc, oldAlam;
    double f, fold, f2;
    oldParameters = x.dup();

    alam2 = 0.0;
    f2 = fold = optimizer.score();
    if (logger.isDebugEnabled()) {
        logger.trace("ENTERING BACKTRACK\n");
        logger.trace("Entering BackTrackLinnSearch, value = " + fold + ",\ndirection.oneNorm:"
                + line.norm1(Integer.MAX_VALUE) + "  direction.infNorm:" + FastMath.max(Float.NEGATIVE_INFINITY,
                        Transforms.abs(line).max(Integer.MAX_VALUE).getDouble(0)));
    }

    BooleanIndexing.applyWhere(g, new Or(Conditions.isNan(), Conditions.isInfinite()),
            new Value(Nd4j.EPS_THRESHOLD));
    LinAlgExceptions.assertValidNum(g);
    double sum = line.norm2(Integer.MAX_VALUE).getDouble(0);
    if (sum > stpmax) {
        logger.warn("attempted step too big. scaling: sum= " + sum + ", stpmax= " + stpmax);
        line.muli(stpmax / sum);
    }

    //dot product
    slope = Nd4j.getBlasWrapper().dot(g, line);
    logger.debug("slope = " + slope);

    if (slope < 0)
        throw new InvalidStepException("Slope = " + slope + " is negative");

    if (slope == 0)
        throw new InvalidStepException("Slope = " + slope + " is zero");

    // find maximum lambda
    // converge when (delta x) / x < REL_TOLX for all coordinates.
    //  the largest step size that triggers this threshold is
    //  precomputed and saved in alamin
    INDArray maxOldParams = Transforms.abs(oldParameters);
    BooleanIndexing.applyWhere(maxOldParams, new Condition() {
        @Override
        public Boolean apply(Number input) {
            return input.doubleValue() < 1.0;
        }

        @Override
        public Boolean apply(IComplexNumber input) {
            return false;
        }
    }, new Value(1.0));

    INDArray testMatrix = Transforms.abs(line).divi(maxOldParams);
    test = testMatrix.max(Integer.MAX_VALUE).getDouble(0);
    //no longer needed
    testMatrix = null;
    alamin = relTolx / test;

    alam = 1.0f;
    oldAlam = 0.0f;
    int iteration;
    // look for step size in direction given by "line"
    for (iteration = 0; iteration < maxIterations; iteration++) {
        // x = oldParameters + alam*line
        // initially, alam = 1.0, i.e. take full Newton step
        logger.trace("BackTrack loop iteration " + iteration + " : alam=" + alam + " oldAlam=" + oldAlam);
        logger.trace("before step, x.1norm: " + x.norm1(Integer.MAX_VALUE) + "\nalam: " + alam + "\noldAlam: "
                + oldAlam);
        assert (alam != oldAlam) : "alam == oldAlam";

        if (stepFunction == null)
            stepFunction = new DefaultStepFunction();
        stepFunction.step(x, line, new Object[] { alam, oldAlam }); //step

        double norm1 = x.norm1(Integer.MAX_VALUE).getDouble(0);
        logger.debug("after step, x.1norm: " + norm1);

        // check for convergence
        //convergence on delta x
        if ((alam < alamin) || smallAbsDiff(oldParameters, x)) {
            function.setParams(oldParameters);
            f = function.score();
            logger.trace("EXITING BACKTRACK: Jump too small (alamin = " + alamin
                    + "). Exiting and using xold. Value = " + f);
            return 0.0f;
        }

        function.setParams(x);
        oldAlam = alam;
        f = function.score();

        logger.debug("value = " + f);

        // sufficient function increase (Wolf condition)
        if (f >= fold + ALF * alam * slope) {

            logger.debug("EXITING BACKTRACK: value=" + f);

            if (f < fold)
                throw new IllegalStateException(
                        "Function did not increase: f = " + f + " < " + fold + " = fold");
            return alam;
        }

        // if value is infinite, i.e. we've
        // jumped to unstable territory, then scale down jump
        else if (Double.isInfinite(f) || Double.isInfinite(f2)) {
            logger.warn("Value is infinite after jump " + oldAlam + ". f=" + f + ", f2=" + f2
                    + ". Scaling back step size...");
            tmplam = .2f * alam;
            if (alam < alamin) { //convergence on delta x
                function.setParams(oldParameters);
                f = function.score();
                logger.warn("EXITING BACKTRACK: Jump too small. Exiting and using xold. Value=" + f);
                return 0.0f;
            }
        } else { // backtrack
            if (alam == 1.0) // first time through
                tmplam = -slope / (2.0f * (f - fold - slope));
            else {
                rhs1 = f - fold - alam * slope;
                rhs2 = f2 - fold - alam2 * slope;
                if ((alam - alam2) == 0)
                    throw new IllegalStateException("FAILURE: dividing by alam-alam2. alam=" + alam);
                a = (rhs1 / (FastMath.pow(alam, 2)) - rhs2 / (FastMath.pow(alam2, 2))) / (alam - alam2);
                b = (-alam2 * rhs1 / (alam * alam) + alam * rhs2 / (alam2 * alam2)) / (alam - alam2);
                if (a == 0.0)
                    tmplam = -slope / (2.0f * b);
                else {
                    disc = b * b - 3.0f * a * slope;
                    if (disc < 0.0) {
                        tmplam = .5f * alam;
                    } else if (b <= 0.0)
                        tmplam = (-b + FastMath.sqrt(disc)) / (3.0f * a);
                    else
                        tmplam = -slope / (b + FastMath.sqrt(disc));
                }
                if (tmplam > .5f * alam)
                    tmplam = .5f * alam; // lambda <= .5 lambda_1
            }
        }

        alam2 = alam;
        f2 = f;
        logger.debug("tmplam:" + tmplam);
        alam = Math.max(tmplam, .1f * alam); // lambda >= .1*Lambda_1

    }

    return 0.0f;
}

From source file:phat.audio.listeners.XYRMSAudioChart.java

public float getMax(MicrophoneData md) {
    int numSamples = md.getData().length / md.getAudioFormat().getFrameSize();
    float[] out = new float[numSamples];
    FloatSampleTools.byte2floatInterleaved(md.getData(), 0, out, 0, numSamples, md.getAudioFormat());

    float max = Float.NEGATIVE_INFINITY;
    float value = 0;
    for (float f : out) {
        value = Math.abs(f);//ww  w  .  j  av  a2  s .c om
        if (value > max) {
            max = value;
        }
    }
    return max;
}

From source file:org.nd4j.linalg.solvers.VectorizedBackTrackLineSearch.java

public double optimize(INDArray line, int lineSearchIteration, double initialStep) throws InvalidStepException {
    INDArray g, x, oldParameters;/*from   w  w w.ja v a2s .  co m*/
    double slope, test, alamin, alam, alam2, tmplam;
    double rhs1, rhs2, a, b, disc, oldAlam;
    double f, fold, f2;
    g = function.getValueGradient(lineSearchIteration); // gradient
    x = function.getParameters(); // parameters
    oldParameters = x.dup();

    alam2 = tmplam = 0.0f;
    f2 = fold = function.getValue();
    if (logger.isDebugEnabled()) {
        logger.trace("ENTERING BACKTRACK\n");
        logger.trace("Entering BackTrackLnSrch, value=" + fold + ",\ndirection.oneNorm:"
                + line.norm1(Integer.MAX_VALUE) + "  direction.infNorm:" + FastMath.max(Float.NEGATIVE_INFINITY,
                        (double) Transforms.abs(line).max(Integer.MAX_VALUE).element()));
    }

    LinAlgExceptions.assertValidNum(g);
    double sum = (double) line.norm2(Integer.MAX_VALUE).element();
    if (sum > stpmax) {
        logger.warn("attempted step too big. scaling: sum= " + sum + ", stpmax= " + stpmax);
        line.muli(stpmax / sum);
    }

    //dot product
    slope = Nd4j.getBlasWrapper().dot(g, line);
    logger.debug("slope = " + slope);

    if (slope < 0) {
        throw new InvalidStepException("Slope = " + slope + " is negative");
    }
    if (slope == 0)
        throw new InvalidStepException("Slope = " + slope + " is zero");

    // find maximum lambda
    // converge when (delta x) / x < REL_TOLX for all coordinates.
    //  the largest step size that triggers this threshold is
    //  precomputed and saved in alamin
    INDArray maxOldParams = Nd4j.create(line.length());
    for (int i = 0; i < line.length(); i++) {
        maxOldParams.putScalar(i, Math.max(Math.abs(oldParameters.getDouble(i)), 1.0));

    }

    INDArray testMatrix = Transforms.abs(line).div(maxOldParams);

    test = testMatrix.max(Integer.MAX_VALUE).getDouble(0);

    alamin = relTolx / test;

    alam = 1.0f;
    oldAlam = 0.0f;
    int iteration = 0;
    // look for step size in direction given by "line"
    for (iteration = 0; iteration < maxIterations; iteration++) {
        function.setCurrentIteration(lineSearchIteration);
        // x = oldParameters + alam*line
        // initially, alam = 1.0, i.e. take full Newton step
        logger.trace("BackTrack loop iteration " + iteration + " : alam=" + alam + " oldAlam=" + oldAlam);
        logger.trace("before step, x.1norm: " + x.norm1(Integer.MAX_VALUE) + "\nalam: " + alam + "\noldAlam: "
                + oldAlam);
        assert (alam != oldAlam) : "alam == oldAlam";

        x.addi(line.mul(alam - oldAlam)); // step

        double norm1 = x.norm1(Integer.MAX_VALUE).getDouble(0);
        logger.debug("after step, x.1norm: " + norm1);

        // check for convergence
        //convergence on delta x
        if ((alam < alamin) || smallAbsDiff(oldParameters, x)) {
            //            if ((alam < alamin)) {
            function.setParameters(oldParameters);
            f = function.getValue();
            logger.trace("EXITING BACKTRACK: Jump too small (alamin=" + alamin
                    + "). Exiting and using xold. Value=" + f);
            return 0.0f;
        }

        function.setParameters(x);
        oldAlam = alam;
        f = function.getValue();

        logger.debug("value = " + f);

        // sufficient function increase (Wolf condition)
        if (f >= fold + ALF * alam * slope) {

            logger.debug("EXITING BACKTRACK: value=" + f);

            if (f < fold)
                throw new IllegalStateException("Function did not increase: f=" + f + " < " + fold + "=fold");
            return alam;
        }

        // if value is infinite, i.e. we've
        // jumped to unstable territory, then scale down jump
        else if (Double.isInfinite(f) || Double.isInfinite(f2)) {
            logger.warn("Value is infinite after jump " + oldAlam + ". f=" + f + ", f2=" + f2
                    + ". Scaling back step size...");
            tmplam = .2f * alam;
            if (alam < alamin) { //convergence on delta x
                function.setParameters(oldParameters);
                f = function.getValue();
                logger.warn("EXITING BACKTRACK: Jump too small. Exiting and using xold. Value=" + f);
                return 0.0f;
            }
        } else { // backtrack
            if (alam == 1.0) // first time through
                tmplam = -slope / (2.0f * (f - fold - slope));
            else {
                rhs1 = f - fold - alam * slope;
                rhs2 = f2 - fold - alam2 * slope;
                assert ((alam - alam2) != 0) : "FAILURE: dividing by alam-alam2. alam=" + alam;
                a = (rhs1 / (double) (FastMath.pow(alam, 2)) - rhs2 / (double) (FastMath.pow(alam2, 2)))
                        / (alam - alam2);
                b = (-alam2 * rhs1 / (alam * alam) + alam * rhs2 / (alam2 * alam2)) / (alam - alam2);
                if (a == 0.0)
                    tmplam = -slope / (2.0f * b);
                else {
                    disc = b * b - 3.0f * a * slope;
                    if (disc < 0.0) {
                        tmplam = .5f * alam;
                    } else if (b <= 0.0)
                        tmplam = (-b + (double) FastMath.sqrt(disc)) / (3.0f * a);
                    else
                        tmplam = -slope / (b + (double) FastMath.sqrt(disc));
                }
                if (tmplam > .5f * alam)
                    tmplam = .5f * alam; // lambda <= .5 lambda_1
            }
        }

        alam2 = alam;
        f2 = f;
        logger.debug("tmplam:" + tmplam);
        alam = Math.max(tmplam, .1f * alam); // lambda >= .1*Lambda_1

    }

    if (iteration >= maxIterations)
        throw new IllegalStateException("Too many iterations.");
    return 0.0f;
}

From source file:org.deeplearning4j.optimize.solvers.VectorizedBackTrackLineSearch.java

public double optimize(INDArray line, int lineSearchIteration, double initialStep) throws InvalidStepException {
    INDArray g, x, oldParameters;/*ww w.ja  v  a 2 s  .c om*/
    double slope, test, alamin, alam, alam2, tmplam;
    double rhs1, rhs2, a, b, disc, oldAlam;
    double f, fold, f2;
    g = function.getValueGradient(lineSearchIteration); // gradient
    x = function.getParameters(); // parameters
    oldParameters = x.dup();

    alam2 = tmplam = 0.0f;
    f2 = fold = function.getValue();
    if (logger.isDebugEnabled()) {
        logger.trace("ENTERING BACKTRACK\n");
        logger.trace("Entering BackTrackLnSrch, value=" + fold + ",\ndirection.oneNorm:"
                + line.norm1(Integer.MAX_VALUE) + "  direction.infNorm:" + FastMath.max(Float.NEGATIVE_INFINITY,
                        Transforms.abs(line).max(Integer.MAX_VALUE).getDouble(0)));
    }

    LinAlgExceptions.assertValidNum(g);
    double sum = line.norm2(Integer.MAX_VALUE).getDouble(0);
    if (sum > stpmax) {
        logger.warn("attempted step too big. scaling: sum= " + sum + ", stpmax= " + stpmax);
        line.muli(stpmax / sum);
    }

    //dot product
    slope = Nd4j.getBlasWrapper().dot(g, line);
    logger.debug("slope = " + slope);

    if (slope < 0) {
        throw new InvalidStepException("Slope = " + slope + " is negative");
    }
    if (slope == 0)
        throw new InvalidStepException("Slope = " + slope + " is zero");

    // find maximum lambda
    // converge when (delta x) / x < REL_TOLX for all coordinates.
    //  the largest step size that triggers this threshold is
    //  precomputed and saved in alamin
    INDArray maxOldParams = Nd4j.create(line.length());
    for (int i = 0; i < line.length(); i++) {
        maxOldParams.putScalar(i, Math.max(Math.abs(oldParameters.getDouble(i)), 1.0));

    }

    INDArray testMatrix = Transforms.abs(line).div(maxOldParams);

    test = testMatrix.max(Integer.MAX_VALUE).getDouble(0);

    alamin = relTolx / test;

    alam = 1.0f;
    oldAlam = 0.0f;
    int iteration = 0;
    // look for step size in direction given by "line"
    for (iteration = 0; iteration < maxIterations; iteration++) {
        function.setCurrentIteration(lineSearchIteration);
        // x = oldParameters + alam*line
        // initially, alam = 1.0, i.e. take full Newton step
        logger.trace("BackTrack loop iteration " + iteration + " : alam=" + alam + " oldAlam=" + oldAlam);
        logger.trace("before step, x.1norm: " + x.norm1(Integer.MAX_VALUE) + "\nalam: " + alam + "\noldAlam: "
                + oldAlam);
        assert (alam != oldAlam) : "alam == oldAlam";

        x.addi(line.mul(alam - oldAlam)); // step

        double norm1 = x.norm1(Integer.MAX_VALUE).getDouble(0);
        logger.debug("after step, x.1norm: " + norm1);

        // check for convergence
        //convergence on delta x
        if ((alam < alamin) || smallAbsDiff(oldParameters, x)) {
            //            if ((alam < alamin)) {
            function.setParameters(oldParameters);
            f = function.getValue();
            logger.trace("EXITING BACKTRACK: Jump too small (alamin=" + alamin
                    + "). Exiting and using xold. Value=" + f);
            return 0.0f;
        }

        function.setParameters(x);
        oldAlam = alam;
        f = function.getValue();

        logger.debug("value = " + f);

        // sufficient function increase (Wolf condition)
        if (f >= fold + ALF * alam * slope) {

            logger.debug("EXITING BACKTRACK: value=" + f);

            if (f < fold)
                throw new IllegalStateException("Function did not increase: f=" + f + " < " + fold + "=fold");
            return alam;
        }

        // if value is infinite, i.e. we've
        // jumped to unstable territory, then scale down jump
        else if (Double.isInfinite(f) || Double.isInfinite(f2)) {
            logger.warn("Value is infinite after jump " + oldAlam + ". f=" + f + ", f2=" + f2
                    + ". Scaling back step size...");
            tmplam = .2f * alam;
            if (alam < alamin) { //convergence on delta x
                function.setParameters(oldParameters);
                f = function.getValue();
                logger.warn("EXITING BACKTRACK: Jump too small. Exiting and using xold. Value=" + f);
                return 0.0f;
            }
        } else { // backtrack
            if (alam == 1.0) // first time through
                tmplam = -slope / (2.0f * (f - fold - slope));
            else {
                rhs1 = f - fold - alam * slope;
                rhs2 = f2 - fold - alam2 * slope;
                assert ((alam - alam2) != 0) : "FAILURE: dividing by alam-alam2. alam=" + alam;
                a = (rhs1 / (double) (FastMath.pow(alam, 2)) - rhs2 / (double) (FastMath.pow(alam2, 2)))
                        / (alam - alam2);
                b = (-alam2 * rhs1 / (alam * alam) + alam * rhs2 / (alam2 * alam2)) / (alam - alam2);
                if (a == 0.0)
                    tmplam = -slope / (2.0f * b);
                else {
                    disc = b * b - 3.0f * a * slope;
                    if (disc < 0.0) {
                        tmplam = .5f * alam;
                    } else if (b <= 0.0)
                        tmplam = (-b + (double) FastMath.sqrt(disc)) / (3.0f * a);
                    else
                        tmplam = -slope / (b + (double) FastMath.sqrt(disc));
                }
                if (tmplam > .5f * alam)
                    tmplam = .5f * alam; // lambda <= .5 lambda_1
            }
        }

        alam2 = alam;
        f2 = f;
        logger.debug("tmplam:" + tmplam);
        alam = Math.max(tmplam, .1f * alam); // lambda >= .1*Lambda_1

    }

    if (iteration >= maxIterations)
        throw new IllegalStateException("Too many iterations.");
    return 0.0f;
}

From source file:uk.co.modularaudio.mads.base.stereo_compressor.ui.OutSignalAmpMeter.java

private void refillMeterImage() {
    //      log.debug("Repainting it.");
    if (outBufferedImage != null) {

        outBufferedImageGraphics.setColor(Color.BLACK);
        outBufferedImageGraphics.fillRect(0, 0, componentWidth, componentHeight);

        final int meterWidth = PREFERRED_METER_WIDTH;
        final int totalMeterHeight = componentHeight - 2;

        final int meterHeight = (showClipBox ? totalMeterHeight - meterWidth : totalMeterHeight);
        final int meterHeightOffset = (showClipBox ? meterWidth : 0);

        float levelValue = 0.0f;
        if (currentMeterValueDb != Float.NEGATIVE_INFINITY) {
            levelValue = dbToLevelComputer.toNormalisedSliderLevelFromDb(currentMeterValueDb);
        }/*ww  w  . j a  v  a2s  .  com*/

        outBufferedImageGraphics.setColor(Color.GREEN);
        final float greenVal = (levelValue >= greenThresholdLevel ? greenThresholdLevel : levelValue);
        int greenBarHeightInPixels = (int) (greenVal * meterHeight);
        greenBarHeightInPixels = (greenBarHeightInPixels > (meterHeight) ? (meterHeight)
                : (greenBarHeightInPixels < 0 ? 0 : greenBarHeightInPixels));
        final int greenStartY = meterHeight - greenBarHeightInPixels + 1 + meterHeightOffset;
        outBufferedImageGraphics.fillRect(3, greenStartY, meterWidth - 4, greenBarHeightInPixels);

        if (currentMeterValueDb > GREEN_THRESHOLD_DB) {
            outBufferedImageGraphics.setColor(Color.orange);
            final float orangeVal = (levelValue >= orangeThreholdLevel ? orangeThreholdLevel : levelValue);
            int orangeBarHeightInPixels = (int) (orangeVal * meterHeight);
            orangeBarHeightInPixels = (orangeBarHeightInPixels > (meterHeight) ? (meterHeight)
                    : (orangeBarHeightInPixels < 0 ? 0 : orangeBarHeightInPixels));
            // Take off the green
            orangeBarHeightInPixels -= greenBarHeightInPixels;
            final int orangeStartY = greenStartY - orangeBarHeightInPixels;
            //         int orangeEndY = greenStartY;
            outBufferedImageGraphics.fillRect(3, orangeStartY, meterWidth - 4, orangeBarHeightInPixels);

            if (currentMeterValueDb > ORANGE_THRESHOLD_DB) {
                outBufferedImageGraphics.setColor(Color.RED);
                final float redVal = levelValue;
                int redBarHeightInPixels = (int) (redVal * meterHeight);
                redBarHeightInPixels = (redBarHeightInPixels > (meterHeight) ? (meterHeight)
                        : (redBarHeightInPixels < 0 ? 0 : redBarHeightInPixels));
                // Take off the green and orange
                redBarHeightInPixels = redBarHeightInPixels
                        - (greenBarHeightInPixels + orangeBarHeightInPixels);
                final int redStartY = orangeStartY - redBarHeightInPixels;
                //            int redEndY = orangeStartY;
                outBufferedImageGraphics.fillRect(3, redStartY, meterWidth - 4, redBarHeightInPixels);

            }
        }

        float maxLevelValue = 0.0f;
        final Color maxDbColor = getColorForDb(currentMaxValueDb);
        if (currentMaxValueDb != Float.NEGATIVE_INFINITY) {
            maxLevelValue = dbToLevelComputer.toNormalisedSliderLevelFromDb(currentMaxValueDb);
        }
        outBufferedImageGraphics.setColor(maxDbColor);

        int maxValueHeightInPixels = (int) (maxLevelValue * meterHeight);
        maxValueHeightInPixels = (maxValueHeightInPixels > (meterHeight) ? (meterHeight)
                : (maxValueHeightInPixels < 0 ? 0 : maxValueHeightInPixels));
        final int yReverser = meterHeight + 1;
        final int maxStartY = yReverser - maxValueHeightInPixels + meterHeightOffset;
        outBufferedImageGraphics.drawLine(1, maxStartY, meterWidth, maxStartY);

        if (showClipBox) {
            if (currentMaxValueDb >= 1.0f) {
                // Should already be the right colour
                //            g.setColor( getColorForDb( 0.0f ) );
                outBufferedImageGraphics.fillRect(1, 1, meterWidth, meterWidth - 1);
            }
        } else {
        }
    }
}

From source file:net.sourceforge.jabm.agent.AgentList.java

public double getMaxFitness() {
    double result = Float.NEGATIVE_INFINITY;
    for (Agent agent : agents) {
        if (agent.getPayoff() > result) {
            result = agent.getPayoff();/*from   w  w  w  . j ava2  s .  co  m*/
        }
    }
    return result;
}

From source file:net.minecraftforge.common.model.animation.AnimationStateMachine.java

/**
 * post-loading initialization hook.//from w  w w .  jav  a  2s  . c o  m
 */
void initialize() {
    if (parameters == null) {
        throw new JsonParseException("Animation State Machine should contain \"parameters\" key.");
    }
    if (clips == null) {
        throw new JsonParseException("Animation State Machine should contain \"clips\" key.");
    }
    if (states == null) {
        throw new JsonParseException("Animation State Machine should contain \"states\" key.");
    }
    if (transitions == null) {
        throw new JsonParseException("Animation State Machine should contain \"transitions\" key.");
    }
    shouldHandleSpecialEvents = true;
    lastPollTime = Float.NEGATIVE_INFINITY;
    // setting the starting state
    IClip state = clips.get(startState);
    if (!clips.containsKey(startState) || !states.contains(startState)) {
        throw new IllegalStateException("unknown state: " + startState);
    }
    currentStateName = startState;
    currentState = state;
}