Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

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

Prototype

float MAX_VALUE

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

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:com.viewpagerindicator.MyDirectionalViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int width = getClientWidth();
    final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;/*from   w  ww.j ava  2 s .c o  m*/
            float offset = oldCurInfo.offset + oldCurInfo.widthFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.widthFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.widthFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    mLastOffset = curItem.position == N - 1 ? curItem.offset + curItem.widthFactor - 1 : Float.MAX_VALUE;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.widthFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + curItem.widthFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            mLastOffset = offset + ii.widthFactor - 1;
        }
        ii.offset = offset;
        offset += ii.widthFactor + marginOffset;
    }

    //        mNeedCalculatePageOffsets = false;
}

From source file:cn.androidy.materialdesignsample.ryanharterviewpager.ViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int size = isOrientationHorizontal() ? getClientWidth() : getClientHeight();
    final float marginOffset = size > 0 ? (float) mPageMargin / size : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;//from w  ww  .j ava2s.  c  o  m
            float offset = oldCurInfo.offset + oldCurInfo.sizeFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageSize(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.sizeFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageSize(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.sizeFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    mLastOffset = curItem.position == N - 1 ? curItem.offset + curItem.sizeFactor - 1 : Float.MAX_VALUE;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            offset -= mAdapter.getPageSize(pos--) + marginOffset;
        }
        offset -= ii.sizeFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + curItem.sizeFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageSize(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            mLastOffset = offset + ii.sizeFactor - 1;
        }
        ii.offset = offset;
        offset += ii.sizeFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}

From source file:com.baiiu.autoloopviewpager.loopvp.LoopViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int width = getWidth();
    final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            // ANALYZE ?????? + 1????????
            int itemIndex = 0;
            ItemInfo ii = null;/*from   w  w w .j a v a  2 s  .  c om*/
            float offset = oldCurInfo.offset + oldCurInfo.widthFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                // ANALYZE position ? pos ????? ItemInfo  mItems ??
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                // ANALYZE position ? pos ??? = position ? pos ?????
                // ItemInfo ?????
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.widthFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            // ANALYZE ????? - 1 ????????
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.widthFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    // CHANGE
    curItem.offset = 0;
    mFirstOffset = /* curItem.position == 0 ? curItem.offset : */-Float.MAX_VALUE;
    mLastOffset = /*
                   * curItem.position == N - 1 ? curItem.offset +
                   * curItem.widthFactor - 1 :
                   */Float.MAX_VALUE;

    float offset = curItem.offset;
    int pos = curItem.position - 1;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        // CHANGE
        while (pos > ii.position && N != 2) {
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.widthFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }

    offset = curItem.offset + curItem.widthFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            mLastOffset = offset + ii.widthFactor - 1;
        }
        ii.offset = offset;
        offset += ii.widthFactor + marginOffset;
    }

    // CHANGE
    if (N <= 3) {
        requestLayout();
    }

    mNeedCalculatePageOffsets = false;
}

From source file:org.fhcrc.cpl.viewer.ms2.commandline.PostProcessPepXMLCLM.java

protected void processFeatureSet(FeatureSet featureSet) {

    if (filterByProteinPrefix) {
        filterByProteinPrefix(featureSet);
    }/*  w ww  . jav a  2s  .c  om*/

    filterOnQualityScores(featureSet);

    if (stripLightIDs) {
        int numFeaturesBefore = featureSet.getFeatures().length;
        List<Feature> featuresToKeep = new ArrayList<Feature>();

        for (Feature feature : featureSet.getFeatures()) {
            if (!IsotopicLabelExtraInfoDef.isLightLabeled(feature, labelType))
                featuresToKeep.add(feature);
        }
        featureSet.setFeatures(featuresToKeep.toArray(new Feature[0]));

        ApplicationContext.setMessage("\tStripped " + (numFeaturesBefore - featureSet.getFeatures().length)
                + " light-identified peptides. Kept " + featureSet.getFeatures().length + " out of "
                + numFeaturesBefore + " identifications.");
    }

    if (peptidesToStrip != null) {
        int numFeaturesBefore = featureSet.getFeatures().length;
        List<Feature> featuresToKeep = new ArrayList<Feature>();
        for (Feature feature : featureSet.getFeatures()) {
            String peptide = MS2ExtraInfoDef.getFirstPeptide(feature);
            if (peptide == null)
                continue;
            if (!peptidesToStrip.contains(peptide))
                featuresToKeep.add(feature);
        }
        featureSet.setFeatures(featuresToKeep.toArray(new Feature[0]));

        ApplicationContext.setMessage("\tStripped indicated peptides. Kept " + featureSet.getFeatures().length
                + " out of " + numFeaturesBefore + " identifications.");
    }
    if (proteinsToStrip != null) {
        int numFeaturesBefore = featureSet.getFeatures().length;
        Set<String> proteinsNotOnStripListWithStrippedPeptides = new HashSet<String>();
        List<Feature> featuresToKeep = new ArrayList<Feature>();
        for (Feature feature : featureSet.getFeatures()) {
            List<String> proteins = MS2ExtraInfoDef.getProteinList(feature);
            if (proteins == null)
                continue;
            Set<String> proteinsNotOnStripListThisFeature = new HashSet<String>();
            boolean foundBadProtein = false;
            for (String protein : proteins) {
                if (proteinsToStrip.contains(protein)) {
                    foundBadProtein = true;
                } else
                    proteinsNotOnStripListThisFeature.add(protein);

            }
            if (foundBadProtein) {
                proteinsNotOnStripListWithStrippedPeptides.addAll(proteinsNotOnStripListThisFeature);
            } else {
                featuresToKeep.add(feature);
            }
        }
        featureSet.setFeatures(featuresToKeep.toArray(new Feature[0]));
        //            StringBuffer proteinsNotOnListWithStrippedBuf =
        //                    new StringBuffer("Proteins not on list that have stripped peptides");
        //            for (String protein : proteinsNotOnStripListWithStrippedPeptides)
        //                proteinsNotOnListWithStrippedBuf.append("," + protein);
        //            ApplicationContext.setMessage(proteinsNotOnListWithStrippedBuf.toString());
        ApplicationContext.setMessage("\tStripped indicated proteins. Kept " + featureSet.getFeatures().length
                + " out of " + numFeaturesBefore + " identifications.");
    }

    if (stripQuantMatchingRegexp) {
        int numStrippedQuant = 0;
        for (Feature feature : featureSet.getFeatures()) {
            String peptide = MS2ExtraInfoDef.getFirstPeptide(feature);
            if (peptide == null)
                continue;
            if (peptide.matches(regexp) && IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                numStrippedQuant++;
            }
        }
        ApplicationContext.setMessage("\tStripped quantitation from " + numStrippedQuant
                + " features with peptides matching regexp " + regexp);
    }

    if (proteinsToStripQuant != null) {
        Set<String> proteinsNotOnStripQuantListWithStrippedPeptides = new HashSet<String>();
        for (Feature feature : featureSet.getFeatures()) {
            List<String> proteins = MS2ExtraInfoDef.getProteinList(feature);
            if (proteins == null)
                continue;
            Set<String> proteinsNotOnStripQuantListThisFeature = new HashSet<String>();
            boolean foundBadProtein = false;
            for (String protein : proteins) {
                if (proteinsToStripQuant.contains(protein)) {
                    foundBadProtein = true;
                } else
                    proteinsNotOnStripQuantListThisFeature.add(protein);

            }
            if (foundBadProtein) {
                proteinsNotOnStripQuantListWithStrippedPeptides.addAll(proteinsNotOnStripQuantListThisFeature);
                IsotopicLabelExtraInfoDef.removeRatio(feature);
            }
        }

        StringBuffer proteinsNotOnListWithStrippedBuf = new StringBuffer(
                "Proteins not on list that have quantitation-stripped peptides");
        for (String protein : proteinsNotOnStripQuantListWithStrippedPeptides)
            proteinsNotOnListWithStrippedBuf.append("," + protein);
        ApplicationContext.setMessage(proteinsNotOnListWithStrippedBuf.toString());
        ApplicationContext.setMessage("\tStripped quantitative events from indicated proteins.");
    }

    if (proteinsToKeep != null) {
        int numFeaturesBefore = featureSet.getFeatures().length;
        List<Feature> featuresToKeep = new ArrayList<Feature>();
        for (Feature feature : featureSet.getFeatures()) {
            List<String> proteins = MS2ExtraInfoDef.getProteinList(feature);
            if (proteins == null)
                continue;
            boolean shouldKeep = false;
            for (String protein : proteins) {
                if (proteinsToKeep.contains(protein)) {
                    shouldKeep = true;
                    break;
                }
            }
            if (shouldKeep) {
                featuresToKeep.add(feature);
            }
        }
        featureSet.setFeatures(featuresToKeep.toArray(new Feature[0]));
        ApplicationContext.setMessage("\tKept only indicated proteins. Kept " + featureSet.getFeatures().length
                + " out of " + numFeaturesBefore + " identifications.");
    }

    if (stripQuantMissingLightOrHeavyWithinRun) {
        stripQuantWithoutLightOrHeavyIDWithinSet(featureSet);
    }

    if (minQuantPeptideProphet > 0f) {
        int numFeaturesQuantStripped = 0;
        for (Feature feature : featureSet.getFeatures()) {
            if (MS2ExtraInfoDef.getPeptideProphet(feature) < minQuantPeptideProphet
                    && IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                numFeaturesQuantStripped++;
            }
        }
        ApplicationContext.infoMessage("\tStripped quantitation from " + numFeaturesQuantStripped
                + " features with PeptideProphet < " + minQuantPeptideProphet);
    }

    if (minRatio > 0f) {
        int numFeaturesQuantStripped = 0;
        for (Feature feature : featureSet.getFeatures()) {
            if (IsotopicLabelExtraInfoDef.hasRatio(feature)
                    && IsotopicLabelExtraInfoDef.getRatio(feature) < minRatio) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                numFeaturesQuantStripped++;
            }
        }
        ApplicationContext.infoMessage("\tStripped quantitation from " + numFeaturesQuantStripped
                + " features with ratio < " + minRatio);
    }

    if (maxRatio < Float.MAX_VALUE) {
        int numFeaturesQuantStripped = 0;
        for (Feature feature : featureSet.getFeatures()) {
            if (IsotopicLabelExtraInfoDef.hasRatio(feature)
                    && IsotopicLabelExtraInfoDef.getRatio(feature) > maxRatio) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                numFeaturesQuantStripped++;
            }
        }
        ApplicationContext.infoMessage("\tStripped quantitation from " + numFeaturesQuantStripped
                + " features with ratio > " + maxRatio);
    }

    if (maxQuantExpect < Float.MAX_VALUE) {
        int numFeaturesQuantStripped = 0;
        int numQuantFeaturesWithNoExpect = 0;
        for (Feature feature : featureSet.getFeatures()) {
            String expectString = MS2ExtraInfoDef.getSearchScore(feature, "expect");
            if (expectString == null) {
                if (IsotopicLabelExtraInfoDef.hasRatio(feature))
                    numQuantFeaturesWithNoExpect++;
                continue;
            }
            Float expectScore = Float.parseFloat(expectString);

            if (expectScore > maxQuantExpect && IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                numFeaturesQuantStripped++;
            }
        }
        ApplicationContext.infoMessage("\tStripped quantitation from " + numFeaturesQuantStripped
                + " features with expect > " + maxQuantExpect);
        if (numQuantFeaturesWithNoExpect > 0)
            ApplicationContext.infoMessage("\t\tNote: " + numQuantFeaturesWithNoExpect
                    + " quantified features had no expect score, were left alone");
    }

    if (stripQuantNotInHeavyAcrossAll || stripQuantMissingLightOrHeavyAcrossAll) {
        Set<String> strippedPeptidesThisRun = new HashSet<String>();
        Set<String> allPeptides = new HashSet<String>();
        Set<String> allQuantifiedPeptides = new HashSet<String>();

        for (Feature feature : featureSet.getFeatures()) {
            String peptide = MS2ExtraInfoDef.getFirstPeptide(feature);
            if (peptide == null)
                continue;
            allPeptides.add(peptide);
            if (IsotopicLabelExtraInfoDef.hasRatio(feature))
                allQuantifiedPeptides.add(peptide);
            else
                continue;

            boolean shouldRemove = false;

            //only one of the two variables will be true, so take the appropriate action
            if (stripQuantMissingLightOrHeavyAcrossAll) {
                if (!heavyPeptidesAllRuns.contains(peptide) || !lightPeptidesAllRuns.contains(peptide))
                    shouldRemove = true;
            }
            //not MissingLightOrHeavy, so must be NotInHeavy
            else {
                if (!heavyPeptidesAllRuns.contains(peptide))
                    shouldRemove = true;
            }
            if (shouldRemove) {
                IsotopicLabelExtraInfoDef.removeRatio(feature);
                strippedPeptidesThisRun.add(peptide);
            }
        }
        ApplicationContext.infoMessage("\tStripped quant from " + strippedPeptidesThisRun.size()
                + " peptides (out of " + allPeptides.size() + " total, " + allQuantifiedPeptides.size()
                + " quantified) not found in appropriate states in any run");
    }

    //filter on fractional deltamass
    if (maxFracDeltaMass != null) {
        List<Feature> featuresToKeep = new ArrayList<Feature>();

        int numFeaturesStripped = 0;

        for (Feature feature : featureSet.getFeatures()) {
            float deltaMass = MS2ExtraInfoDef.getDeltaMass(feature);

            float fracDeltaMass = (float) ((deltaMass + .5) % 1) - .5f;
            if (fracDeltaMass < -.5f)
                fracDeltaMass += 1f;

            if (maxFracDeltaMass.getDeltaMassType() == AnalyzeICAT.DELTA_MASS_PPM)
                fracDeltaMass = fracDeltaMass * 1000000f / feature.getMass();

            if (fracDeltaMass <= maxFracDeltaMass.getDeltaMass())
                featuresToKeep.add(feature);
            else
                numFeaturesStripped++;
        }
        featureSet.setFeatures(featuresToKeep.toArray(new Feature[0]));
        ApplicationContext.infoMessage("\tStripped " + numFeaturesStripped
                + " features with fractional deltamass > " + maxFracDeltaMass);
    }

    if (adjustQuantZeroAreas) {
        adjustQuantZeroAreas(featureSet);
    }

    if (stripQuantZeroAreas) {
        int numQuantStripped = 0;
        for (Feature feature : featureSet.getFeatures()) {
            if (IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                float lightIntensity = (float) IsotopicLabelExtraInfoDef.getLightIntensity(feature);
                float heavyIntensity = (float) IsotopicLabelExtraInfoDef.getHeavyIntensity(feature);

                if (lightIntensity == 0 || heavyIntensity == 0) {
                    IsotopicLabelExtraInfoDef.removeRatio(feature);
                    numQuantStripped++;
                }
            }
        }
        ApplicationContext.infoMessage("Stripped quantitation from " + numQuantStripped
                + " features with zero light and/or heavy area");
    }

    if (stripQuantSingleScans) {
        int numQuantStripped = 0;
        for (Feature feature : featureSet.getFeatures()) {
            if (IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                if ((IsotopicLabelExtraInfoDef.getLightFirstScan(feature) == IsotopicLabelExtraInfoDef
                        .getLightLastScan(feature))
                        || (IsotopicLabelExtraInfoDef.getHeavyFirstScan(feature) == IsotopicLabelExtraInfoDef
                                .getHeavyLastScan(feature))) {
                    IsotopicLabelExtraInfoDef.removeRatio(feature);
                    numQuantStripped++;
                }
            }
        }
        ApplicationContext.infoMessage("Stripped quantitation from " + numQuantStripped
                + " features with a single scan for light or heavy species");
    }

    if (medianCenter) {
        if (medianCenterByNumCysteines) {
            Map<Integer, Float> numCysteineMedianLogRatioMapThisFile = fileNumCysteinesMedianLogRatioMap
                    .get(featureSet.getSourceFile());
            for (Feature feature : featureSet.getFeatures()) {
                if (IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                    float ratio = (float) IsotopicLabelExtraInfoDef.getRatio(feature);
                    String peptide = MS2ExtraInfoDef.getFirstPeptide(feature);
                    if (peptide != null) {
                        int numCysteines = countCysteines(peptide);
                        //if (peptide.equals("QSSGENCDVVVNTLGK")) throw new RuntimeException("heavy_area is NaN! Light: " +
                        //IsotopicLabelExtraInfoDef.getLightIntensity(feature) + ", old heavy: " +
                        //        IsotopicLabelExtraInfoDef.getHeavyIntensity(feature) + ", old ratio: " + ratio + ", numcys: " + numCysteines +
                        //     ", containsKey? " + numCysteineMedianLogRatioMapThisFile.containsKey(numCysteines));
                        if (numCysteineMedianLogRatioMapThisFile.containsKey(numCysteines)) {
                            float newRatio = (float) Math.exp(
                                    Math.log(ratio) - numCysteineMedianLogRatioMapThisFile.get(numCysteines));
                            IsotopicLabelExtraInfoDef.setRatio(feature, newRatio);
                            //dhmay 20091215, fixing divide-by-zero area that left NaN in output pepXML heavy_areas
                            double newHeavyIntensity = IsotopicLabelExtraInfoDef.getHeavyIntensity(feature);
                            if (newRatio > 0)
                                newHeavyIntensity = IsotopicLabelExtraInfoDef.getLightIntensity(feature)
                                        / newRatio;
                            //if (peptide.equals("QSSGENCDVVVNTLGK")) throw new RuntimeException("heavy_area is NaN! Light: " +
                            //IsotopicLabelExtraInfoDef.getLightIntensity(feature) + ", old heavy: " +
                            //        IsotopicLabelExtraInfoDef.getHeavyIntensity(feature) + ", new heavy: " + newHeavyIntensity + ", new ratio: " + newRatio);
                            IsotopicLabelExtraInfoDef.setHeavyIntensity(feature, newHeavyIntensity);
                        }
                    }
                }
            }
        } else {
            float medianLogRatioThisFile = 0;
            if (medianRatioForCentering != -1)
                medianLogRatioThisFile = (float) Math.log(medianRatioForCentering);
            else
                medianLogRatioThisFile = fileMedianLogRatioMap.get(featureSet.getSourceFile());
            ApplicationContext.infoMessage("Median centering file " + featureSet.getSourceFile().getName()
                    + ", median: " + medianLogRatioThisFile);
            //List<Float> newLogRatios = new ArrayList<Float>();
            //List<Float> oldLogRatios = new ArrayList<Float>();

            for (Feature feature : featureSet.getFeatures()) {
                if (IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                    float ratio = (float) IsotopicLabelExtraInfoDef.getRatio(feature);
                    float newRatio = (float) Math.exp(Math.log(ratio) - medianLogRatioThisFile);
                    //newLogRatios.add((float)Math.log(newRatio));
                    //oldLogRatios.add((float)Math.log(ratio));

                    IsotopicLabelExtraInfoDef.setRatio(feature, newRatio);
                    //dhmay 20091215, fixing divide-by-zero area that left NaN in output pepXML heavy_areas
                    double newHeavyIntensity = IsotopicLabelExtraInfoDef.getHeavyIntensity(feature);
                    if (newRatio > 0)
                        newHeavyIntensity = IsotopicLabelExtraInfoDef.getLightIntensity(feature) / newRatio;
                    IsotopicLabelExtraInfoDef.setHeavyIntensity(feature, newHeavyIntensity);
                }
            }
            //System.err.println("Old median log ratio: " + BasicStatistics.median(oldLogRatios));
            //System.err.println("New median log ratio: " + BasicStatistics.median(newLogRatios));

        }
    }

}

From source file:net.fengg.parallaxdirectionalviewpager.DirectionalViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int dimension = getClientDimension();
    final float marginOffset = dimension > 0 ? (float) mPageMargin / dimension : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;/*from   ww w .  j  a va2s . com*/
            float offset = oldCurInfo.offset + oldCurInfo.dimensionFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.dimensionFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.dimensionFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    setLastOffset(curItem.position == N - 1 ? curItem.offset + curItem.dimensionFactor - 1 : Float.MAX_VALUE);
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            // We're using getPageWidth() regardless of direction...
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.dimensionFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + curItem.dimensionFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            setLastOffset(offset + ii.dimensionFactor - 1);
        }
        ii.offset = offset;
        offset += ii.dimensionFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}

From source file:com.tjych.swip.vertical.DirectionalViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int dimension = getClientDimension();
    final float marginOffset = dimension > 0 ? (float) mPageMargin / dimension : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;//from  www .jav a 2  s. c om
            float offset = oldCurInfo.offset + oldCurInfo.dimensionFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an swip_item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.dimensionFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an swip_item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.dimensionFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    setLastOffset(curItem.position == N - 1 ? curItem.offset + curItem.dimensionFactor - 1 : Float.MAX_VALUE);
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            // We're using getPageWidth() regardless of direction...
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.dimensionFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + curItem.dimensionFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            setLastOffset(offset + ii.dimensionFactor - 1);
        }
        ii.offset = offset;
        offset += ii.dimensionFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}

From source file:au.org.ala.layers.intersect.Grid.java

public void printMinMax() {
    float min = Float.MAX_VALUE;
    float max = -1 * Float.MAX_VALUE;
    float[] data = this.getGrid();
    int numMissing = 0;
    for (float d : data) {
        if (Float.isNaN(d)) {
            numMissing++;//from  w w  w .j  a  v  a  2  s. c om
        }
        if (d < min) {
            min = d;
        }
        if (d > max) {
            max = d;
        }
    }
    if (min != this.minval || max != this.maxval) {
        logger.error(this.filename + " ERR header(" + this.minval + " " + this.maxval + ") actual(" + min + " "
                + max + ") number missing(" + numMissing + " of " + data.length + ")");
    } else {
        logger.error(this.filename + " OK header(" + this.minval + " " + this.maxval + ") number missing("
                + numMissing + " of " + data.length + ")");
    }
}

From source file:com.my.infiniteviewpager.view.InfiniteViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int width = getClientWidth();
    final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;/*from  w  w w  . j av a 2s  .  c o m*/
            float offset = oldCurInfo.offset + oldCurInfo.widthFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.widthFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.widthFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = -Float.MAX_VALUE;
    mLastOffset = Float.MAX_VALUE;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.widthFactor + marginOffset;
        ii.offset = offset;
    }
    offset = curItem.offset + curItem.widthFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        ii.offset = offset;
        offset += ii.widthFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int width = getClientWidth();
    final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;//from   ww  w  .  ja  v  a  2  s.  c om
            float offset = oldCurInfo.offset + oldCurInfo.lengthFactor + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += ii.lengthFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= ii.lengthFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    mLastOffset = curItem.position == N - 1 ? curItem.offset + curItem.lengthFactor - 1 : Float.MAX_VALUE;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= ii.lengthFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + curItem.lengthFactor + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            mLastOffset = offset + ii.lengthFactor - 1;
        }
        ii.offset = offset;
        offset += ii.lengthFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}

From source file:dev.dworks.libs.widget.ViewPager.java

private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
    final int N = mAdapter.getCount();
    final int factor = mOrientation == HORIZONTAL ? getClientWidth() : getClientHeight();
    final float marginOffset = factor > 0 ? (float) mPageMargin / factor : 0;
    // Fix up offsets for later layout.
    if (oldCurInfo != null) {
        final int oldCurPosition = oldCurInfo.position;
        // Base offsets off of oldCurInfo.
        if (oldCurPosition < curItem.position) {
            int itemIndex = 0;
            ItemInfo ii = null;//from  www .  ja v  a 2 s  . com
            float offset = oldCurInfo.offset
                    + (mOrientation == HORIZONTAL ? oldCurInfo.widthFactor : oldCurInfo.heightFactor)
                    + marginOffset;
            for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) {
                ii = mItems.get(itemIndex);
                while (pos > ii.position && itemIndex < mItems.size() - 1) {
                    itemIndex++;
                    ii = mItems.get(itemIndex);
                }
                while (pos < ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset += mAdapter.getPageWidth(pos) + marginOffset;
                    pos++;
                }
                ii.offset = offset;
                offset += mOrientation == HORIZONTAL ? ii.widthFactor : ii.heightFactor + marginOffset;
            }
        } else if (oldCurPosition > curItem.position) {
            int itemIndex = mItems.size() - 1;
            ItemInfo ii = null;
            float offset = oldCurInfo.offset;
            for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) {
                ii = mItems.get(itemIndex);
                while (pos < ii.position && itemIndex > 0) {
                    itemIndex--;
                    ii = mItems.get(itemIndex);
                }
                while (pos > ii.position) {
                    // We don't have an item populated for this,
                    // ask the adapter for an offset.
                    offset -= mAdapter.getPageWidth(pos) + marginOffset;
                    pos--;
                }
                offset -= mOrientation == HORIZONTAL ? ii.widthFactor : ii.heightFactor + marginOffset;
                ii.offset = offset;
            }
        }
    }

    // Base all offsets off of curItem.
    final int itemCount = mItems.size();
    float offset = curItem.offset;
    int pos = curItem.position - 1;
    mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE;
    mLastOffset = curItem.position == N - 1
            ? curItem.offset + (mOrientation == HORIZONTAL ? curItem.widthFactor : curItem.heightFactor) - 1
            : Float.MAX_VALUE;
    // Previous pages
    for (int i = curIndex - 1; i >= 0; i--, pos--) {
        final ItemInfo ii = mItems.get(i);
        while (pos > ii.position) {
            offset -= mAdapter.getPageWidth(pos--) + marginOffset;
        }
        offset -= mOrientation == HORIZONTAL ? ii.widthFactor : ii.heightFactor + marginOffset;
        ii.offset = offset;
        if (ii.position == 0)
            mFirstOffset = offset;
    }
    offset = curItem.offset + (mOrientation == HORIZONTAL ? curItem.widthFactor : curItem.heightFactor)
            + marginOffset;
    pos = curItem.position + 1;
    // Next pages
    for (int i = curIndex + 1; i < itemCount; i++, pos++) {
        final ItemInfo ii = mItems.get(i);
        while (pos < ii.position) {
            offset += mAdapter.getPageWidth(pos++) + marginOffset;
        }
        if (ii.position == N - 1) {
            mLastOffset = offset + mOrientation == HORIZONTAL ? ii.widthFactor : ii.heightFactor - 1;
        }
        ii.offset = offset;
        offset += mOrientation == HORIZONTAL ? ii.widthFactor : ii.heightFactor + marginOffset;
    }

    mNeedCalculatePageOffsets = false;
}