Example usage for com.google.common.collect Range lowerEndpoint

List of usage examples for com.google.common.collect Range lowerEndpoint

Introduction

In this page you can find the example usage for com.google.common.collect Range lowerEndpoint.

Prototype

public C lowerEndpoint() 

Source Link

Document

Returns the lower endpoint of this range.

Usage

From source file:com.yahoo.gondola.container.AdminClient.java

/**
 * Split shard./* w  ww .j  av  a  2s.  c  o  m*/
 *
 * @param fromShardId the from shard id
 * @param toShardId   the to shard id
 * @throws AdminException the admin exception
 */
public void splitShard(String fromShardId, String toShardId) throws AdminException, InterruptedException {
    Range<Integer> range = lookupSplitRange(fromShardId, toShardId);
    assignBuckets(range.lowerEndpoint(), range.upperEndpoint(), fromShardId, toShardId);
}

From source file:com.yahoo.gondola.container.AdminClient.java

/**
 * Merge shard.//from  w  w  w.  j  a v a  2  s . com
 *
 * @param fromShardId the from shard id
 * @param toShardId   the to shard id
 * @throws AdminException the admin exception
 */
public void mergeShard(String fromShardId, String toShardId) throws AdminException, InterruptedException {
    Range<Integer> range = lookupMergeRange(fromShardId, toShardId);
    assignBuckets(range.lowerEndpoint(), range.upperEndpoint(), fromShardId, toShardId);
}

From source file:net.sf.mzmine.parameters.dialogs.ParameterSetupDialogWithChromatogramPreview.java

private void updateTitle() {

    NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
    NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();

    Range<Double> rtRange = rtRangeBox.getValue();
    Range<Double> mzRange = mzRangeBox.getValue();

    String title = "m/z: " + mzFormat.format(mzRange.lowerEndpoint()) + " - "
            + mzFormat.format(mzRange.upperEndpoint()) + ", RT: " + rtFormat.format(rtRange.lowerEndpoint())
            + " - " + rtFormat.format(rtRange.upperEndpoint());

    // update plot title
    ticPlot.setTitle(previewDataFile.getName(), title);
}

From source file:org.openehealth.ipf.commons.ihe.fhir.LazyBundleProvider.java

@Override
public List<IBaseResource> getResources(int fromIndex, int toIndex) {
    if (!cacheResults) {
        return getPartialResult(fromIndex, toIndex);
    }//from   w  ww.  j a  v  a  2  s . c  o m
    LOG.debug("Cached results contain the following ranges: {}. Requesting resources from index {} to {}",
            resultRanges, fromIndex, toIndex);
    Range<Integer> wanted = Range.closedOpen(fromIndex, toIndex);
    RangeSet<Integer> needed = resultRanges.required(wanted);
    LOG.debug("Requiring the following ranges {}", needed);
    for (Range<Integer> requiredRange : needed.asDescendingSetOfRanges()) {
        LOG.debug("Now requesting the following range {}", requiredRange);
        List<IBaseResource> results = getPartialResult(requiredRange.lowerEndpoint(),
                requiredRange.upperEndpoint());
        LOG.debug("Got back a list of size {}", results.size());
        if (!results.isEmpty()) {
            cacheAll(requiredRange.lowerEndpoint(), results);
            // Take care, potentially less elements than requested have been retrieved
            resultRanges.add(Range.closedOpen(requiredRange.lowerEndpoint(),
                    requiredRange.lowerEndpoint() + results.size()));
        }
    }
    LOG.debug("Cached results now contain the following ranges: {}", resultRanges);

    // Everything went OK, return whatever we got
    return cachedResults.subList(fromIndex,
            Math.min(cachedResults.size(), Math.min(cachedResults.size(), toIndex)));
}

From source file:org.eclipse.fx.ui.controls.styledtext.internal.LineHelper.java

private com.google.common.collect.Range<Integer> mapToLocal(int index,
        com.google.common.collect.Range<Integer> global) {
    return com.google.common.collect.Range.range(
            Integer.valueOf(global.lowerEndpoint().intValue() - getOffset(index)), global.lowerBoundType(),
            Integer.valueOf(global.upperEndpoint().intValue() - getOffset(index)), global.upperBoundType());
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.build.fix.DocumentToDocumentationWordFixer.java

@Override
public Optional<ICompletionProposal> asContentProposal(final IMarker marker, final IDocument document,
        final RobotSuiteFile suiteModel) {
    final Optional<ICompletionProposal> proposal = Optional.empty();

    final Range<Integer> defRange = getRange(marker);
    final Optional<? extends RobotSuiteFileSection> section = suiteModel.findSection(sectionClass);
    if (section.isPresent()) {
        try {/*from w  ww.j  a v a 2s. c o  m*/
            return createProposal(document, section.get().findElement(defRange.lowerEndpoint()));
        } catch (final BadLocationException e) {
        }
    }

    return proposal;

}

From source file:org.apache.pulsar.common.naming.NamespaceBundleFactory.java

/**
 * Fetches {@link NamespaceBundles} from cache for a given namespace. finds target bundle, split into numBundles and
 * returns new {@link NamespaceBundles} with newly split bundles into it.
 *
 * @param targetBundle// w w w . ja va  2s .  c om
 *            {@link NamespaceBundle} needs to be split
 * @param numBundles
 *            split into numBundles
 * @return List of split {@link NamespaceBundle} and {@link NamespaceBundles} that contains final bundles including
 *         split bundles for a given namespace
 * @throws Exception
 */
public Pair<NamespaceBundles, List<NamespaceBundle>> splitBundles(NamespaceBundle targetBundle, int numBundles)
        throws Exception {
    checkNotNull(targetBundle, "can't split null bundle");
    checkNotNull(targetBundle.getNamespaceObject(), "namespace must be present");
    NamespaceName nsname = targetBundle.getNamespaceObject();
    NamespaceBundles sourceBundle = bundlesCache.synchronous().get(nsname);

    final int lastIndex = sourceBundle.partitions.length - 1;

    final long[] partitions = new long[sourceBundle.partitions.length + (numBundles - 1)];
    int pos = 0;
    int splitPartition = -1;
    for (int i = 0; i < lastIndex; i++) {
        final Range<Long> range = targetBundle.getKeyRange();
        if (sourceBundle.partitions[i] == range.lowerEndpoint()
                && (range.upperEndpoint() == sourceBundle.partitions[i + 1])) {
            splitPartition = i;
            Long maxVal = sourceBundle.partitions[i + 1];
            Long minVal = sourceBundle.partitions[i];
            Long segSize = (maxVal - minVal) / numBundles;
            partitions[pos++] = minVal;
            Long curPartition = minVal + segSize;
            for (int j = 0; j < numBundles - 1; j++) {
                partitions[pos++] = curPartition;
                curPartition += segSize;
            }
        } else {
            partitions[pos++] = sourceBundle.partitions[i];
        }
    }
    partitions[pos] = sourceBundle.partitions[lastIndex];
    if (splitPartition != -1) {
        NamespaceBundles splittedNsBundles = new NamespaceBundles(nsname, partitions, this);
        List<NamespaceBundle> splittedBundles = splittedNsBundles.getBundles().subList(splitPartition,
                (splitPartition + numBundles));
        return new ImmutablePair<NamespaceBundles, List<NamespaceBundle>>(splittedNsBundles, splittedBundles);
    }
    return null;
}

From source file:edu.cmu.sv.modelinference.eventtool.EventVisualizer.java

private void setViolationMarkers(Collection<Range<Integer>> violations, XYPlot plot) {
    for (Range<Integer> violation : violations) {

        ValueMarker startViolationMarker = new ValueMarker(violation.lowerEndpoint()); // position is the value on the axis
        startViolationMarker.setPaint(Color.BLACK);
        startViolationMarker.setStroke(new BasicStroke(1.0f));
        plot.addDomainMarker(startViolationMarker);

        ValueMarker endViolationMarker = new ValueMarker(violation.upperEndpoint()); // position is the value on the axis
        endViolationMarker.setPaint(Color.GREEN);
        endViolationMarker.setStroke(new BasicStroke(0.5f));
        plot.addDomainMarker(endViolationMarker);
    }//from w  ww  .j a v a 2s  .co m
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.build.fix.SettingSimpleWordReplacer.java

@Override
public Optional<ICompletionProposal> asContentProposal(final IMarker marker, final IDocument document,
        final RobotSuiteFile suiteModel) {
    final Optional<ICompletionProposal> proposal = Optional.empty();

    final Range<Integer> defRange = getRange(marker);
    final Optional<? extends RobotSuiteFileSection> section = suiteModel.findSection(sectionClass);
    if (section.isPresent()) {
        try {//from  w  w w .j a  v a 2 s.  com
            return createProposal(document, section.get().findElement(defRange.lowerEndpoint()));
        } catch (final BadLocationException e) {
        }
    }

    return proposal;
}

From source file:org.robotframework.ide.eclipse.main.plugin.assist.RedKeywordProposal.java

@Override
public StyledString getStyledLabel() {
    final StyledString label = new StyledString(getNameFromDefinition(),
            isDeprecated() ? Stylers.Common.STRIKEOUT_STYLER : Stylers.Common.EMPTY_STYLER);
    for (final Range<Integer> matchingRange : match) {
        for (final StyleRange styleRange : label.getStyleRanges()) {
            final int length = Math.min(matchingRange.upperEndpoint() - matchingRange.lowerEndpoint(),
                    label.length() - matchingRange.lowerEndpoint());
            label.setStyle(matchingRange.lowerEndpoint(), length,
                    Stylers.mixingStyler(styleRange, Stylers.Common.MARKED_PREFIX_STYLER));
        }/*from   ww w  .  j a  v  a2s.  c om*/
    }
    return label;
}