Example usage for java.lang Float MIN_VALUE

List of usage examples for java.lang Float MIN_VALUE

Introduction

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

Prototype

float MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type float , 2-149.

Usage

From source file:com.rexmtorres.android.patternlock.PatternLockView.java

@Override
protected void onDraw(Canvas canvas) {
    final ArrayList<Cell> pattern = mPattern;
    final int count = pattern.size();
    final boolean[][] drawLookup = mPatternDrawLookup;
    if (mPatternDisplayMode == DisplayMode.Animate) {
        // figure out which circles to draw
        // + 1 so we pause on complete pattern
        final int oneCycle = (count + 1) * MILLIS_PER_CIRCLE_ANIMATING;
        final int spotInCycle = (int) (SystemClock.elapsedRealtime() - mAnimatingPeriodStart) % oneCycle;
        final int numCircles = spotInCycle / MILLIS_PER_CIRCLE_ANIMATING;
        clearPatternDrawLookup();/*w  w  w .  java2 s.  c om*/
        for (int i = 0; i < numCircles; i++) {
            final Cell cell = pattern.get(i);
            drawLookup[cell.getRow()][cell.getColumn()] = true;
        }
        // figure out in progress portion of ghosting line
        final boolean needToUpdateInProgressPoint = numCircles > 0 && numCircles < count;
        if (needToUpdateInProgressPoint) {
            final float percentageOfNextCircle = ((float) (spotInCycle % MILLIS_PER_CIRCLE_ANIMATING))
                    / MILLIS_PER_CIRCLE_ANIMATING;
            final Cell currentCell = pattern.get(numCircles - 1);
            final float centerX = getCenterXForColumn(currentCell.column);
            final float centerY = getCenterYForRow(currentCell.row);
            final Cell nextCell = pattern.get(numCircles);
            final float dx = percentageOfNextCircle * (getCenterXForColumn(nextCell.column) - centerX);
            final float dy = percentageOfNextCircle * (getCenterYForRow(nextCell.row) - centerY);
            mInProgressX = centerX + dx;
            mInProgressY = centerY + dy;
        }
        // TODO: Infinite loop here...
        invalidate();
    }
    final Path currentPath = mCurrentPath;
    currentPath.rewind();
    // draw the circles
    for (int i = 0; i < 3; i++) {
        float centerY = getCenterYForRow(i);
        for (int j = 0; j < 3; j++) {
            CellState cellState = mCellStates[i][j];
            float centerX = getCenterXForColumn(j);
            float translationY = cellState.translationY;
            drawDot(canvas, (int) centerX, (int) centerY + translationY, cellState.radius, drawLookup[i][j],
                    cellState.alpha, cellState.bitmapDot);
        }
    }

    // TODO: the path should be created and cached every time we hit-detect a cell
    // only the last segment of the path should be computed here
    // draw the path of the pattern (unless we are in stealth mode)
    final boolean drawPath = !mInStealthMode;
    if (drawPath) {
        mPathPaint.setColor(getCurrentColor(true /* partOfPattern */));
        boolean anyCircles = false;
        float lastX = 0f;
        float lastY = 0f;
        for (int i = 0; i < count; i++) {
            Cell cell = pattern.get(i);
            // only draw the part of the pattern stored in
            // the lookup table (this is only different in the case
            // of animation).
            if (!drawLookup[cell.row][cell.column]) {
                break;
            }
            anyCircles = true;
            float centerX = getCenterXForColumn(cell.column);
            float centerY = getCenterYForRow(cell.row);
            if (i != 0) {
                CellState state = mCellStates[cell.row][cell.column];
                currentPath.rewind();
                currentPath.moveTo(lastX, lastY);
                if (state.lineEndX != Float.MIN_VALUE && state.lineEndY != Float.MIN_VALUE) {
                    currentPath.lineTo(state.lineEndX, state.lineEndY);
                } else {
                    currentPath.lineTo(centerX, centerY);
                }
                canvas.drawPath(currentPath, mPathPaint);
            }
            lastX = centerX;
            lastY = centerY;
        }
        // draw last in progress section
        if ((mPatternInProgress || mPatternDisplayMode == DisplayMode.Animate) && anyCircles) {
            currentPath.rewind();
            currentPath.moveTo(lastX, lastY);
            currentPath.lineTo(mInProgressX, mInProgressY);
            mPathPaint.setAlpha(
                    (int) (calculateLastSegmentAlpha(mInProgressX, mInProgressY, lastX, lastY) * 255f));
            canvas.drawPath(currentPath, mPathPaint);
        }
    }
}

From source file:pipeline.misc_util.Utils.java

public static float getStackMax(ImagePlus source) {
    if (source == null) {
        Utils.log("Source stack in null in getStackMax", LogLevel.INFO);
        return 0;
    }//from www. java2  s.  c om
    ImageStack stack = source.getStack();
    float max = Float.MIN_VALUE;
    for (int i = 1; i <= stack.getSize(); i++) {
        float sliceMax = (max(stack.getProcessor(i).getPixels()));
        if (sliceMax > max)
            max = sliceMax;
    }
    return max;
}

From source file:net.iiit.siel.analysis.lang.LanguageIdentifier.java

/**
 * Identify./*from w  w w  . ja  v a2  s  . c  o  m*/
 *
 * @param content the content
 * @return the string
 */
public String identify(StringBuffer content) {
    // Added
    String lang = "", randomWord;
    StringBuffer text = content;
    if (text.length() <= 1)
        return "";

    LanguageIdentifierConstants.LangShortNames[] languagesSampled = new LanguageIdentifierConstants.LangShortNames[LanguageIdentifierConstants.totalRandomNumberTrials];
    /*
     * We need to analyse "text" now.
     */

    languagesSampled = getLanguagesSampled(text, LangIdentifierUtility.getRandomNumber(text.length() - 1,
            LanguageIdentifierConstants.totalRandomNumberTrials));

    // TODO uncomment the next line For TableMap purpose.(when needed
    // to create a lang-charRange table
    // languagesSampled = getLanguageAndForTaggingWithLangID(text);
    Boolean isNGramReqd = checkIsNGramReqd(languagesSampled);

    /*
     * if we already identified the right language then don't proceed to
     * ngram
     */
    if (!isNGramReqd) {
        //      System.out.println("Language is identified (without ngrams) as: "
        //            + languagesSampled[0].langShortName());
        /*
         * DONOT delete the next few lines, they should be enabled, when a
         * lang. mapping map needs to be generated. Set the
         * hashmapRangeMarker from start to end .. tag as LangID
         * 
         * String rangeMarkerString = this.langMarkerObject
         * .setLangRangeMarkerTableTillTheEnd(0); if
         * (!this.langMarkerObject.getLangRangeMarkerTable().containsKey(
         * languagesSampled[0].langShortName())) { ArrayList<String>
         * rangeMarkerArrayList = new ArrayList<String>();
         * rangeMarkerArrayList.add(rangeMarkerString);
         * this.langMarkerObject.getLangRangeMarkerTable().put(
         * languagesSampled[0].langShortName(), rangeMarkerArrayList); }
         * else { ArrayList<String> rangeMarkerArrayList = new
         * ArrayList<String>(); rangeMarkerArrayList = this.langMarkerObject
         * .getLangRangeMarkerTable().get(
         * languagesSampled[0].langShortName());
         * rangeMarkerArrayList.add(rangeMarkerString);
         * 
         * this.langMarkerObject.getLangRangeMarkerTable().put(
         * languagesSampled[0].langShortName(), rangeMarkerArrayList); }
         */

        return languagesSampled[0].langShortName();
    }

    //   System.out.print("Using NGP...  ");
    // Code to calculate n-gram profile similarity
    suspect.analyze(text);
    Iterator iter = suspect.getSorted().iterator();
    float topscore = Float.MIN_VALUE;
    HashMap scores = new HashMap();
    NGramEntry searched = null;
    List<String> listOfLang = new ArrayList<String>();
    int decide_point = 0;
    while (iter.hasNext()) {

        searched = (NGramEntry) iter.next();

        NGramEntry[] ngrams = (NGramEntry[]) ngramsIdx.get(searched.getSeq());

        /*
         * Check if ngrams is null, implies that such a sequence of
         * characters is not found in our profiles, which implies that the
         * profile is a foreign profile.
         */
        if (ngrams == null) {
            /*
             * Check if the searched.getSeq() has a indicUnicode
             */
            Boolean isForeignLangID = checkCharSequence(searched.getSeq());

            /*
             * Set the lang as unknown for foreignLangID.
             */
            if (isForeignLangID) {
                decide_point++;
                lang = LanguageIdentifierConstants.UKNOWN_LANG;
            }

        }
        if (ngrams != null) {
            for (int j = 0; j < ngrams.length; j++) {
                NGramProfile profile = ngrams[j].getProfile();
                /*
                 * Check when profile is null
                 */
                if (profile == null) {
                    profile = new NGramProfile(LanguageIdentifierConstants.UKNOWN_LANG,
                            NGramProfile.DEFAULT_MIN_NGRAM_LENGTH, NGramProfile.DEFAULT_MAX_NGRAM_LENGTH);
                }

                Float pScore = (Float) scores.get(profile);
                if (pScore == null) {
                    pScore = new Float(0);
                }
                float plScore = pScore.floatValue();
                plScore += ngrams[j].getFrequency() + searched.getFrequency();
                scores.put(profile, new Float(plScore));

                /*
                 * If the plScore is greater than topScore --> add
                 * the langId to list
                 */
                if (plScore > topscore) {
                    topscore = plScore;
                    lang = profile.getName();
                    /*
                     * Add the lang to list
                     */
                    if (!listOfLang.contains(lang)) {
                        listOfLang.add(lang);
                    }

                }
            }
        }
    }

    if (listOfLang.contains(LanguageIdentifierConstants.UKNOWN_LANG)
            && decide_point >= (content.length() * 0.1)) {
        lang = LanguageIdentifierConstants.UKNOWN_LANG;
    }
    System.out.println("Lang identified thru ngrams test =" + lang);
    return lang;
}

From source file:br.com.blackhubos.eventozero.util.Framework.java

/**
 * Verifica o tamanho da igualdade entre duas strings (comparao).
 *
 * @param expected A primeira string//ww  w. ja va2s . c  o  m
 * @param obtained A segunda string
 * @param normalize Remover acentos durante o processamento?
 * @param lower Transformar em lower case para processar?
 * @param trim remover espaos para processar?
 * @return Retorna um float entre 0 e 1, sendo 0 = nada haver e 1 = igual, podendo ser por exemplo 0.5.. etc.
 */
public static float equals(String expected, String obtained, final boolean normalize, final boolean lower,
        final boolean trim) {
    if (normalize) {
        expected = Framework.normalize(expected);
        obtained = Framework.normalize(obtained);
    }

    if (lower) {
        expected = expected.toLowerCase();
        obtained = obtained.toLowerCase();
    }

    if (trim) {
        expected = expected.trim();
        obtained = obtained.trim();
    }

    if (expected.length() != obtained.length()) {
        final int iDiff = Math.abs(expected.length() - obtained.length());
        final int iLen = Math.max(expected.length(), obtained.length());
        String sBigger, sSmaller, sAux;

        if (iLen == expected.length()) {
            sBigger = expected;
            sSmaller = obtained;
        } else {
            sBigger = obtained;
            sSmaller = expected;
        }

        float fSim, fMaxSimilarity = Float.MIN_VALUE;
        for (int i = 0; i <= sSmaller.length(); i++) {
            sAux = sSmaller.substring(0, i) + sBigger.substring(i, i + iDiff) + sSmaller.substring(i);
            fSim = Framework.checkSameSize(sBigger, sAux);
            if (fSim > fMaxSimilarity) {
                fMaxSimilarity = fSim;
            }
        }
        return fMaxSimilarity - ((1f * iDiff) / iLen);
    } else {
        return Framework.checkSameSize(expected, obtained);
    }
}

From source file:com.nridge.core.base.field.Field.java

/**
 * Returns a <i>float</i> representation of the field
 * value string./*from ww  w . jav a  2 s .c  o  m*/
 *
 * @param aValue Numeric string value.
 *
 * @return Converted value.
 */
public static float createFloat(String aValue) {
    if (StringUtils.isNotEmpty(aValue))
        return Float.parseFloat(aValue);
    else
        return Float.MIN_VALUE;
}

From source file:org.vertx.java.http.eventbusbridge.integration.MessagePublishTest.java

@Test
public void testPublishingFloatXml() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Float;
    final Float sentFloat = Float.MIN_VALUE;
    Map<String, String> expectations = createExpectations(generateUniqueAddress(),
            Base64.encodeAsString(sentFloat.toString()), messageType);
    final AtomicInteger completedCount = new AtomicInteger(0);
    Handler<Message> messagePublishHandler = new MessagePublishHandler(sentFloat, expectations, completedCount);
    registerListenersAndCheckForResponses(messagePublishHandler, expectations, NUMBER_OF_PUBLISH_HANDLERS,
            completedCount);/* w w w. jav  a  2 s  .c  o m*/
    String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_XML, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(),
            MediaType.APPLICATION_XML);
}

From source file:com.nridge.core.base.field.Field.java

/**
 * Returns a <i>Float</i> representation of the field
 * value string./*from   w  w w  .  j  a va2  s.  co m*/
 *
 * @param aValue Numeric string value.
 *
 * @return Converted value.
 */
public static Float createFloatObject(String aValue) {
    if (StringUtils.isNotEmpty(aValue))
        return Float.valueOf(aValue);
    else
        return Float.MIN_VALUE;
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private void updateBarChart() {
    BarChart barChart = getBarChart();//ww w  .  j av  a 2  s  .co m
    if (barChart == null) {
        return;
    }
    if (freqLeqStats.size() <= 2) {
        return;
    }
    double[] pearsons = computePearson();
    if (pearsons == null) {
        return;
    }

    float YMin = Float.MAX_VALUE;
    float YMax = Float.MIN_VALUE;

    ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();

    // Read all white noise values for indexing before usage
    ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>();
    int idfreq = 0;
    for (double value : pearsons) {
        YMax = Math.max(YMax, (float) value);
        YMin = Math.min(YMin, (float) value);
        yMeasure.add(new BarEntry((float) value, idfreq++));
    }
    BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation");
    freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]);
    freqSet.setValueTextColor(Color.WHITE);
    freqSet.setDrawValues(true);
    dataSets.add(freqSet);

    ArrayList<String> xVals = new ArrayList<String>();
    double[] freqs = FFTSignalProcessing
            .computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION);
    for (double freqValue : freqs) {
        xVals.add(Spectrogram.formatFrequency((int) freqValue));
    }

    // create a data object with the datasets
    BarData data = new BarData(xVals, dataSets);
    barChart.setData(data);
    YAxis yl = barChart.getAxisLeft();
    yl.setAxisMinValue(YMin - 0.1f);
    yl.setAxisMaxValue(YMax + 0.1f);

    barChart.invalidate();
}

From source file:org.dcm4che2.tool.dcmwado.DcmWado.java

public final void setWindow(String[] window) {
    if (window.length != 2)
        throw new IllegalArgumentException("Illegal argument for -voi");
    parseFloat(window[0], "Illegal argument for -voi", Float.MIN_VALUE, Float.MAX_VALUE);
    parseFloat(window[1], "Illegal argument for -voi", 0, Float.MAX_VALUE);
    this.window = window;
}

From source file:mil.jpeojtrs.sca.util.tests.AnyUtilsTest.java

@Test
public void test_convertAnySequences() throws Exception {
    // Test Strings
    Object obj = null;/*  www  .j a  v  a2s  .co  m*/
    Any theAny = JacorbUtil.init().create_any();

    final String[] stringInitialValue = new String[] { "a", "b", "c" };
    StringSeqHelper.insert(theAny, stringInitialValue);
    final String[] stringExtractedValue = StringSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(stringInitialValue, stringExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof String[]);
    Assert.assertTrue(Arrays.equals(stringInitialValue, (String[]) obj));

    // Test Doubles
    obj = null;
    theAny = JacorbUtil.init().create_any();

    final double[] doubleInitialValue = new double[] { 0.1, 0.2, 0.3 };
    DoubleSeqHelper.insert(theAny, doubleInitialValue);
    final double[] doubleExtractedValue = DoubleSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(doubleInitialValue, doubleExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Double[]);
    Assert.assertTrue(Arrays.equals(ArrayUtils.toObject(doubleInitialValue), (Double[]) obj));

    // Test Integers
    obj = null;
    theAny = JacorbUtil.init().create_any();

    final int[] intInitialValue = new int[] { 1, 2, 3 };
    LongSeqHelper.insert(theAny, intInitialValue);
    final int[] intExtractedValue = LongSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(intInitialValue, intExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Integer[]);
    Assert.assertTrue(Arrays.equals(ArrayUtils.toObject(intInitialValue), (Integer[]) obj));

    // Test Recursive Sequence
    obj = null;
    final Any[] theAnys = new Any[2];
    theAnys[0] = JacorbUtil.init().create_any();
    theAnys[1] = JacorbUtil.init().create_any();

    LongSeqHelper.insert(theAnys[0], intInitialValue);
    LongSeqHelper.insert(theAnys[1], intInitialValue);
    AnySeqHelper.insert(theAny, theAnys);

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Object[]);
    int[] extractedIntArray = ArrayUtils.toPrimitive((Integer[]) ((Object[]) obj)[0]);
    Assert.assertTrue(Arrays.equals(intInitialValue, extractedIntArray));
    extractedIntArray = ArrayUtils.toPrimitive((Integer[]) ((Object[]) obj)[1]);
    Assert.assertTrue(Arrays.equals(intInitialValue, extractedIntArray));

    String[] str = (String[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new String[] { "2", "3" }, TCKind.tk_string));
    Assert.assertEquals("2", str[0]);
    str = (String[]) AnyUtils.convertAny(AnyUtils.toAnySequence(new String[] { "3", "4" }, TCKind.tk_wstring));
    Assert.assertEquals("3", str[0]);
    final Boolean[] bool = (Boolean[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new boolean[] { false, true }, TCKind.tk_boolean));
    Assert.assertTrue(bool[1].booleanValue());
    final Short[] b = (Short[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new byte[] { Byte.MIN_VALUE, Byte.MAX_VALUE }, TCKind.tk_octet));
    Assert.assertEquals(Byte.MAX_VALUE, b[1].byteValue());
    Character[] c = (Character[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new char[] { 'r', 'h' }, TCKind.tk_char));
    Assert.assertEquals('h', c[1].charValue());
    c = (Character[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new Character[] { '2', '3' }, TCKind.tk_wchar));
    Assert.assertEquals('2', c[0].charValue());
    final Short[] s = (Short[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new short[] { Short.MIN_VALUE, Short.MAX_VALUE }, TCKind.tk_short));
    Assert.assertEquals(Short.MAX_VALUE, s[1].shortValue());
    final Integer[] i = (Integer[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE }, TCKind.tk_long));
    Assert.assertEquals(Integer.MAX_VALUE, i[1].intValue());
    final Long[] l = (Long[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new long[] { Long.MIN_VALUE, Long.MAX_VALUE }, TCKind.tk_longlong));
    Assert.assertEquals(Long.MAX_VALUE, l[1].longValue());
    final Float[] f = (Float[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new float[] { Float.MIN_VALUE, Float.MAX_VALUE }, TCKind.tk_float));
    Assert.assertEquals(Float.MAX_VALUE, f[1].floatValue(), 0.00001);
    final Double[] d = (Double[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new double[] { Double.MIN_VALUE, Double.MAX_VALUE }, TCKind.tk_double));
    Assert.assertEquals(Double.MAX_VALUE, d[1].doubleValue(), 0.00001);
    final Integer[] us = (Integer[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new short[] { Short.MIN_VALUE, Short.MAX_VALUE }, TCKind.tk_ushort));
    Assert.assertEquals(Short.MAX_VALUE, us[1].intValue());
    final Long[] ui = (Long[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE }, TCKind.tk_ulong));
    Assert.assertEquals(Integer.MAX_VALUE, ui[1].longValue());
    final BigInteger[] ul = (BigInteger[]) AnyUtils.convertAny(AnyUtils
            .toAnySequence(new BigInteger[] { new BigInteger("2"), new BigInteger("3") }, TCKind.tk_ulonglong));
    Assert.assertEquals(3L, ul[1].longValue());

}