Example usage for java.lang Float compare

List of usage examples for java.lang Float compare

Introduction

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

Prototype

public static int compare(float f1, float f2) 

Source Link

Document

Compares the two specified float values.

Usage

From source file:com.klinker.android.launcher.launcher3.Workspace.java

private void updateStateForCustomContent(int screenCenter) {
    float translationX = 0;
    float progress = 0;
    if (hasCustomContent()) {
        int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);

        int scrollDelta = getScrollX() - getScrollForPage(index) - getLayoutTransitionOffsetForPage(index);
        float scrollRange = getScrollForPage(index + 1) - getScrollForPage(index);
        translationX = scrollRange - scrollDelta;
        progress = (scrollRange - scrollDelta) / scrollRange;

        if (mIsRtl) {
            translationX = Math.min(0, translationX);
        } else {/*w w  w. j  a  v a 2 s .c  om*/
            translationX = Math.max(0, translationX);
        }
        progress = Math.max(0, progress);
    }

    if (Float.compare(progress, mLastCustomContentScrollProgress) == 0)
        return;

    CellLayout cc = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID);
    if (progress > 0 && cc.getVisibility() != VISIBLE && !workspaceInModalState()) {
        cc.setVisibility(VISIBLE);
    }

    mLastCustomContentScrollProgress = progress;

    // We should only update the drag layer background alpha if we are not in all apps or the
    // widgets tray
    if (mState == State.NORMAL) {
        mLauncher.getDragLayer().setBackgroundAlpha(progress == 1 ? 0 : progress * 0.8f);
    }

    if (mLauncher.getHotseat() != null) {
        mLauncher.getHotseat().setTranslationX(translationX);
    }

    if (getPageIndicator() != null) {
        getPageIndicator().setTranslationX(translationX);
    }

    if (mCustomContentCallbacks != null) {
        mCustomContentCallbacks.onScrollProgressChanged(progress);
    }
}

From source file:com.wb.launcher3.Workspace.java

@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();
    super.screenScrolled(screenCenter);

    updatePageAlphaValues(screenCenter);
    updateStateForCustomContent(screenCenter);
    enableHwLayersOnVisiblePages();//w  w  w .java 2  s  . c  om

    boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl()))
            || (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));

    //*/Added by tyd Greg 2014-03-20,for transition effect
    if (!isSmall() && TydtechConfig.TRANSITION_EFFECT_ENABLED) {
        screenScrolledTydUI(screenCenter);
        return;
    }
    //*/
    if (shouldOverScroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.25f;
        final float rightBiasedPivot = 0.75f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        CellLayout cl = (CellLayout) getChildAt(index);
        float scrollProgress = getScrollProgress(screenCenter, cl, index);
        cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage);
        float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
        cl.setRotationY(rotation);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            cl.setCameraDistance(mDensity * mCameraDistance);
            cl.setPivotX(cl.getMeasuredWidth() * pivotX);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setOverscrollTransformsDirty(true);
        }
    } else {
        if (mOverscrollTransformsSet) {
            mOverscrollTransformsSet = false;
            ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
            ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
        }
    }
}

From source file:com.fairphone.fplauncher3.Workspace.java

private void updateStateForCustomContent(int screenCenter) {
    float translationX = 0;
    float progress = 0;
    if (hasCustomContent()) {
        int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);

        int scrollDelta = getScrollX() - getScrollForPage(index) - getLayoutTransitionOffsetForPage(index);
        float scrollRange = getScrollForPage(index + 1) - getScrollForPage(index);
        translationX = scrollRange - scrollDelta;
        progress = (scrollRange - scrollDelta) / scrollRange;

        if (isLayoutRtl()) {
            translationX = Math.min(0, translationX);
        } else {/*from  w ww  . ja v  a 2s.co  m*/
            translationX = Math.max(0, translationX);
        }
        progress = Math.max(0, progress);
    }

    if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) {
        return;
    }

    CellLayout cc = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID);
    if (progress > 0 && cc.getVisibility() != VISIBLE && !workspaceInModalState()) {
        cc.setVisibility(VISIBLE);
    }

    mLastCustomContentScrollProgress = progress;

    mLauncher.getDragLayer().setBackgroundAlpha(progress * 0.8f);

    if (getPageIndicator() != null) {
        getPageIndicator().setTranslationX(translationX);
    }

    if (mCustomContentCallbacks != null) {
        mCustomContentCallbacks.onScrollProgressChanged(progress);
    }
}

From source file:com.cyou.poplauncher.Workspace.java

@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();
    super.screenScrolled(screenCenter);

    updatePageAlphaValues(screenCenter);
    updateStateForCustomContent(screenCenter);
    enableHwLayersOnVisiblePages();// w ww  . j a  va2  s .c  o  m

    boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl()))
            || (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));

    if (shouldOverScroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.25f;
        final float rightBiasedPivot = 0.75f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        CellLayout cl = (CellLayout) getChildAt(index);
        float scrollProgress = getScrollProgress(screenCenter, cl, index);
        cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage);
        float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
        cl.setRotationY(rotation);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            cl.setCameraDistance(mDensity * mCameraDistance);
            cl.setPivotX(cl.getMeasuredWidth() * pivotX);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setOverscrollTransformsDirty(true);
        }
    } else {
        if (mOverscrollTransformsSet && getChildCount() > 0) {
            mOverscrollTransformsSet = false;
            ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
            ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
        }
    }
}

From source file:com.auratech.launcher.Workspace.java

@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();
    super.screenScrolled(screenCenter);

    updatePageAlphaValues(screenCenter);
    updateStateForCustomContent(screenCenter);

    boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl()))
            || (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));

    if (shouldOverScroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.25f;
        final float rightBiasedPivot = 0.75f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        CellLayout cl = (CellLayout) getChildAt(index);
        float scrollProgress = getScrollProgress(screenCenter, cl, index);
        cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage);
        float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
        cl.setRotationY(rotation);//from   w  w  w  .  j a  v  a2 s .  c o m

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            cl.setCameraDistance(mDensity * mCameraDistance);
            cl.setPivotX(cl.getMeasuredWidth() * pivotX);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setOverscrollTransformsDirty(true);
        }
    } else {
        if (mOverscrollTransformsSet && getChildCount() > 0) {
            mOverscrollTransformsSet = false;
            ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
            ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
        }

        for (int i = 0; i < getChildCount(); i++) {
            View v = getPageAt(i);
            if (v != null) {
                float scrollProgress = getScrollProgress(screenCenter, v, i);
                mPageViewAnimation.pageViewAnime(scrollProgress, i, getChildCount(), mDensity, v);
            }
        }
    }

    enableHwLayersOnVisiblePages();
}

From source file:com.phonemetra.turbo.launcher.Workspace.java

@Override
protected void screenScrolled(int screenCenter) {
    final boolean isRtl = isLayoutRtl();

    boolean isOnLastPageBeforeCustomContent = false;
    if (hasCustomContent()) {
        int customContentWidth = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).getMeasuredWidth();
        isOnLastPageBeforeCustomContent = (mOverScrollX < customContentWidth && !isLayoutRtl())
                || ((mOverScrollX > mMaxScrollX - customContentWidth) && isLayoutRtl());
    }/*from w  w w  .j  a  v a2 s.  c o m*/
    mUseTransitionEffect = !isOnLastPageBeforeCustomContent && mState == State.NORMAL && !mIsSwitchingState;

    updatePageAlphaValues(screenCenter);

    super.screenScrolled(screenCenter);

    updateStateForCustomContent(screenCenter);
    enableHwLayersOnVisiblePages();

    boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl()))
            || (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));

    if (shouldOverScroll) {
        int index = 0;
        float pivotX = 0f;
        final float leftBiasedPivot = 0.25f;
        final float rightBiasedPivot = 0.75f;
        final int lowerIndex = 0;
        final int upperIndex = getChildCount() - 1;

        final boolean isLeftPage = mOverScrollX < 0;
        index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
        pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;

        CellLayout cl = (CellLayout) getChildAt(index);
        float scrollProgress = getScrollProgress(screenCenter, cl, index);
        cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage);
        float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
        cl.setRotationY(rotation);

        if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
            mOverscrollTransformsSet = true;
            mLastOverscrollPivotX = pivotX;
            cl.setCameraDistance(mDensity * mCameraDistance);
            cl.setPivotX(cl.getMeasuredWidth() * pivotX);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setOverscrollTransformsDirty(true);
        }
    } else {
        if (mOverscrollTransformsSet && getChildCount() > 0) {
            mOverscrollTransformsSet = false;
            ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
            ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
        }
    }
}

From source file:com.android.launcher3.Workspace.java

private void updateStateForCustomContent(int screenCenter) {
    float translationX = 0;
    float progress = 0;
    if (hasCustomContent()) {
        int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);

        int scrollDelta = getScrollX() - getScrollForPage(index) - getLayoutTransitionOffsetForPage(index);
        float scrollRange = getScrollForPage(index + 1) - getScrollForPage(index);
        translationX = scrollRange - scrollDelta;
        progress = (scrollRange - scrollDelta) / scrollRange;

        if (isLayoutRtl()) {
            translationX = Math.min(0, translationX);
        } else {//  w w w.j a  v a 2  s.c  o m
            translationX = Math.max(0, translationX);
        }
        progress = Math.max(0, progress);
    }

    if (Float.compare(progress, mLastCustomContentScrollProgress) == 0)
        return;

    CellLayout cc = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID);
    if (progress > 0 && cc.getVisibility() != VISIBLE && !workspaceInModalState()) {
        cc.setVisibility(VISIBLE);
    }

    mLastCustomContentScrollProgress = progress;

    mLauncher.getDragLayer().setBackgroundAlpha(progress * 0.8f);

    if (mLauncher.getHotseat() != null) {
        mLauncher.getHotseat().setTranslationX(translationX);
    }

    if (getPageIndicator() != null) {
        getPageIndicator().setTranslationX(translationX);
    }

    if (mCustomContentCallbacks != null) {
        mCustomContentCallbacks.onScrollProgressChanged(progress);
    }
}

From source file:org.ejbca.core.model.ra.raadmin.EndEntityProfile.java

/** Implementation of UpgradableDataHashMap function upgrade. */
public void upgrade() {
    log.trace(">upgrade");
    if (Float.compare(LATEST_VERSION, getVersion()) != 0) {
        String msg = intres.getLocalizedMessage("ra.eeprofileupgrade", new Float(getVersion()));
        log.info(msg);//from ww w.  j  a  v  a 2 s.  com
        // New version of the class, upgrade
        if (getVersion() < 1) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberarray = (ArrayList<Integer>) data.get(NUMBERARRAY);
            while (numberarray.size() < 37) {
                numberarray.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberarray);
        }
        if (getVersion() < 2) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberarray = (ArrayList<Integer>) data.get(NUMBERARRAY);
            while (numberarray.size() < 39) {
                numberarray.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberarray);
            addField(AVAILCAS);
            addField(DEFAULTCA);
            setRequired(AVAILCAS, 0, true);
            setRequired(DEFAULTCA, 0, true);
        }
        if (getVersion() < 3) {
            // These fields have been removed in version 8, no need for this upgrade
            //setNotificationSubject("");
            //setNotificationSender("");
            //setNotificationMessage("");
        }
        if (getVersion() < 4) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberoffields = (ArrayList<Integer>) data.get(NUMBERARRAY);
            for (int i = numberoffields.size(); i < dataConstants.size(); i++) {
                numberoffields.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberoffields);
        }
        // Support for DirectoryName altname field in profile version 5
        if (getVersion() < 5) {
            addField(DnComponents.DIRECTORYNAME);
            setValue(DnComponents.DIRECTORYNAME, 0, "");
            setRequired(DnComponents.DIRECTORYNAME, 0, false);
            setUse(DnComponents.DIRECTORYNAME, 0, true);
            setModifyable(DnComponents.DIRECTORYNAME, 0, true);
        }
        // Support for Subject Directory Attributes field in profile version 6
        if (getVersion() < 6) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberoffields = (ArrayList<Integer>) data.get(NUMBERARRAY);
            for (int i = numberoffields.size(); i < dataConstants.size(); i++) {
                numberoffields.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberoffields);
            data.put(SUBJECTDIRATTRFIELDORDER, new ArrayList<Integer>());

            for (int i = getParameterNumber(DnComponents.DATEOFBIRTH); i <= getParameterNumber(
                    DnComponents.COUNTRYOFRESIDENCE); i++) {
                addField(getParameter(i));
                setValue(getParameter(i), 0, "");
                setRequired(getParameter(i), 0, false);
                setUse(getParameter(i), 0, false);
                setModifyable(getParameter(i), 0, true);
            }
        }
        // Support for Start Time and End Time field in profile version 7
        if (getVersion() < 7) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberoffields = (ArrayList<Integer>) data.get(NUMBERARRAY);
            for (int i = numberoffields.size(); i < dataConstants.size(); i++) {
                numberoffields.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberoffields);
            addField(STARTTIME);
            setValue(STARTTIME, 0, "");
            setRequired(STARTTIME, 0, false);
            setUse(STARTTIME, 0, false);
            setModifyable(STARTTIME, 0, true);
            addField(ENDTIME);
            setValue(ENDTIME, 0, "");
            setRequired(ENDTIME, 0, false);
            setUse(ENDTIME, 0, false);
            setModifyable(ENDTIME, 0, true);
        }
        // Notifications is now a more general mechanism in version 8
        if (getVersion() < 8) {
            log.debug("Upgrading User Notifications");
            if (data.get(UserNotification.NOTIFICATIONSENDER) != null) {
                UserNotification not = new UserNotification();
                not.setNotificationSender((String) data.get(UserNotification.NOTIFICATIONSENDER));
                if (data.get(UserNotification.NOTIFICATIONSUBJECT) != null) {
                    not.setNotificationSubject((String) data.get(UserNotification.NOTIFICATIONSUBJECT));
                }
                if (data.get(UserNotification.NOTIFICATIONMESSAGE) != null) {
                    not.setNotificationMessage((String) data.get(UserNotification.NOTIFICATIONMESSAGE));
                }
                // Add the statuschanges we used to send notifications about
                String events = UserNotification.EVENTS_EDITUSER;
                not.setNotificationEvents(events);
                // The old recipients where always the user
                not.setNotificationRecipient(UserNotification.RCPT_USER);
                addUserNotification(not);
            }
        }
        // Support for allowed requests in profile version 9
        if (getVersion() < 9) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> numberoffields = (ArrayList<Integer>) data.get(NUMBERARRAY);
            for (int i = numberoffields.size(); i < dataConstants.size(); i++) {
                numberoffields.add(Integer.valueOf(0));
            }
            data.put(NUMBERARRAY, numberoffields);
            addField(ALLOWEDREQUESTS);
            setValue(ALLOWEDREQUESTS, 0, "");
            setRequired(ALLOWEDREQUESTS, 0, false);
            setUse(ALLOWEDREQUESTS, 0, false);
            setModifyable(ALLOWEDREQUESTS, 0, true);
        }
        // Support for merging DN from WS-API with default values in profile, in profile version 10
        if (getVersion() < 10) {
            setAllowMergeDnWebServices(false);
        }
        // Support for issuance revocation status in profile version 11
        if (getVersion() < 11) {
            setRequired(ISSUANCEREVOCATIONREASON, 0, false);
            setUse(ISSUANCEREVOCATIONREASON, 0, false);
            setModifyable(ISSUANCEREVOCATIONREASON, 0, true);
            setValue(ISSUANCEREVOCATIONREASON, 0, "" + RevokedCertInfo.NOT_REVOKED);
            setRequired(CARDNUMBER, 0, false);
            setUse(CARDNUMBER, 0, false);
            setModifyable(CARDNUMBER, 0, true);
        }
        // Support for maximum number of failed login attempts in profile version 12
        if (getVersion() < 12) {
            setRequired(MAXFAILEDLOGINS, 0, false);
            setUse(MAXFAILEDLOGINS, 0, false);
            setModifyable(MAXFAILEDLOGINS, 0, true);
            setValue(MAXFAILEDLOGINS, 0, Integer.toString(ExtendedInformation.DEFAULT_MAXLOGINATTEMPTS));
        }
        /* In EJBCA 4.0.0 we changed the date format to ISO 8601.
         * In the Admin GUI the example was:
         *     DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ejbcawebbean.getLocale())
         * but the only absolute format that could have worked is the same enforced by the 
         * doesUserFullfillEndEntityProfile check and this is what need to upgrade from:
         *       DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US)
         */
        if (getVersion() < 13) {
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT,
                    Locale.US);
            final FastDateFormat newDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm");
            try {
                final String oldStartTime = getValue(STARTTIME, 0);
                if (!isEmptyOrRelative(oldStartTime)) {
                    // We use an absolute time format, so we need to upgrade
                    final String newStartTime = newDateFormat.format(oldDateFormat.parse(oldStartTime));
                    setValue(STARTTIME, 0, newStartTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + STARTTIME + " from \"" + oldStartTime + "\" to \""
                                + newStartTime + "\" in EndEntityProfile.");
                    }
                }
            } catch (ParseException e) {
                log.error("Unable to upgrade " + STARTTIME
                        + " in EndEntityProfile! Manual interaction is required (edit and verify).", e);
            }
            try {
                final String oldEndTime = getValue(ENDTIME, 0);
                if (!isEmptyOrRelative(oldEndTime)) {
                    // We use an absolute time format, so we need to upgrade
                    final String newEndTime = newDateFormat.format(oldDateFormat.parse(oldEndTime));
                    setValue(ENDTIME, 0, newEndTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + ENDTIME + " from \"" + oldEndTime + "\" to \"" + newEndTime
                                + "\" in EndEntityProfile.");
                    }
                }
            } catch (ParseException e) {
                log.error("Unable to upgrade " + ENDTIME
                        + " in EndEntityProfile! Manual interaction is required (edit and verify).", e);
            }
        }
        /*
         * In version 13 we converted some dates to the "yyyy-MM-dd HH:mm" format using default Locale.
         * These needs to be converted to the same format but should be stored in UTC, so we always know what the times are.
         */
        if (getVersion() < 14) {
            final String[] timePatterns = { "yyyy-MM-dd HH:mm" };
            final String oldStartTime = getValue(STARTTIME, 0);
            if (!isEmptyOrRelative(oldStartTime)) {
                try {
                    final String newStartTime = ValidityDate
                            .formatAsUTC(DateUtils.parseDateStrictly(oldStartTime, timePatterns));
                    setValue(STARTTIME, 0, newStartTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + STARTTIME + " from \"" + oldStartTime + "\" to \""
                                + newStartTime + "\" in EndEntityProfile.");
                    }
                } catch (ParseException e) {
                    log.error("Unable to upgrade " + STARTTIME
                            + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).",
                            e);
                }
            }
            final String oldEndTime = getValue(ENDTIME, 0);
            if (!isEmptyOrRelative(oldEndTime)) {
                // We use an absolute time format, so we need to upgrade
                try {
                    final String newEndTime = ValidityDate
                            .formatAsUTC(DateUtils.parseDateStrictly(oldEndTime, timePatterns));
                    setValue(ENDTIME, 0, newEndTime);
                    if (log.isDebugEnabled()) {
                        log.debug("Upgraded " + ENDTIME + " from \"" + oldEndTime + "\" to \"" + newEndTime
                                + "\" in EndEntityProfile.");
                    }
                } catch (ParseException e) {
                    log.error("Unable to upgrade " + ENDTIME
                            + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).",
                            e);
                }
            }
        }
        // Finally, update the version stored in the map to the current version
        data.put(VERSION, new Float(LATEST_VERSION));
    }
    log.trace("<upgrade");
}

From source file:ml.shifu.shifu.core.dtrain.dt.DTWorker.java

private float updateOneVsAllTargetValue(float ideal) {
    // if one vs all, set correlated idea value according to trainerId which means in trainer with id 0, target
    // 0 is treated with 1, other are 0. Such target value are set to index of tags like [0, 1, 2, 3] compared
    // with ["a", "b", "c", "d"]
    return Float.compare(ideal, trainerId) == 0 ? 1f : 0f;
}

From source file:org.apache.solr.SolrTestCaseJ4.java

public boolean compareSolrDocumentList(Object expected, Object actual) {
    if (!(expected instanceof SolrDocumentList) || !(actual instanceof SolrDocumentList)) {
        return false;
    }//from w w w .ja va  2  s .c  o m

    if (expected == actual) {
        return true;
    }

    SolrDocumentList list1 = (SolrDocumentList) expected;
    SolrDocumentList list2 = (SolrDocumentList) actual;

    if (Float.compare(list1.getMaxScore(), list2.getMaxScore()) != 0
            || list1.getNumFound() != list2.getNumFound() || list1.getStart() != list2.getStart()) {
        return false;
    }
    for (int i = 0; i < list1.getNumFound(); i++) {
        if (!compareSolrDocument(list1.get(i), list2.get(i))) {
            return false;
        }
    }
    return true;
}