List of usage examples for com.google.common.collect Range lowerEndpoint
public C lowerEndpoint()
From source file:io.github.mzmine.parameters.parametertypes.ranges.DoubleRangeEditor.java
@SuppressWarnings("null") @Override/*from w w w. ja v a2s. c o m*/ public void setValue(Range<Double> value) { if (value == null) return; String minValue; String maxValue; if (numberFormat != null) { minValue = String.valueOf(numberFormat.format(value.lowerEndpoint())); maxValue = String.valueOf(numberFormat.format(value.upperEndpoint())); } else { minValue = String.valueOf(value.lowerEndpoint()); maxValue = String.valueOf(value.upperEndpoint()); } minTxtField.setText(minValue); maxTxtField.setText(maxValue); }
From source file:net.sf.mzmine.modules.visualization.threed.ThreeDPeakCells.java
/** * Create a peak bounding box.// ww w. j av a2 s .c om * * @param peak * the peak. * @return the bounding box as a gridded set. * @throws VisADException * if there are VisAD problems. */ private Data createPeakBox(final Feature peak) throws VisADException { // Get the extents. final Range<Double> rtRange = peak.getRawDataPointsRTRange(); final Range<Double> mzRange = peak.getRawDataPointsMZRange(); final float rtMin = rtRange.lowerEndpoint().floatValue(); final float rtMax = rtRange.upperEndpoint().floatValue(); final float mzMin = mzRange.lowerEndpoint().floatValue(); final float mzMax = mzRange.upperEndpoint().floatValue(); final float heightMin = 1.0f; final float heightMax = peak.getRawDataPointsIntensityRange().upperEndpoint().floatValue(); // Create the box set. return GriddedSet.create(pointTupleType, new float[][] { { rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMin, rtMin, rtMin, rtMax, rtMax, rtMax, rtMax, }, { mzMin, mzMin, mzMin, mzMin, mzMax, mzMax, mzMax, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax }, { heightMin, heightMin, heightMax, heightMax, heightMax, heightMax, heightMin, heightMin, heightMin, heightMin, heightMax, heightMax, heightMax, heightMax, heightMin, heightMin } }, new int[] { 2, 8 }); }
From source file:com.wealdtech.collect.TreeRangedMap.java
@Nullable private K findFloor(final Range<K> key) { final K lowerEndpoint; final Map.Entry<K, TwoTuple<Range<K>, V>> floorEntry = underlying.floorEntry(key.lowerEndpoint()); if (floorEntry != null && floorEntry.getValue().getS().upperEndpoint().compareTo(key.lowerEndpoint()) > 0) { lowerEndpoint = floorEntry.getKey(); } else {/* w ww . ja v a 2 s . c om*/ lowerEndpoint = key.lowerEndpoint(); } return lowerEndpoint; }
From source file:io.github.mzmine.parameters.parametertypes.ranges.MZRangeEditor.java
@Override public void setValue(Range<Double> value) { if (value == null) return;//from ww w. j a v a2 s . co m String minValue; String maxValue; NumberFormat numberFormat = MZmineCore.getConfiguration().getMZFormat(); minValue = numberFormat.format(value.lowerEndpoint()); maxValue = numberFormat.format(value.upperEndpoint()); minTxtField.setText(minValue); maxTxtField.setText(maxValue); }
From source file:com.wealdtech.collect.TreeRangedMap.java
@Override public void put(final Range<K> key, final V value) { validateRange(key);/*from w w w. jav a 2 s.c om*/ K resultantStart = key.lowerEndpoint(); K resultantEnd = key.upperEndpoint(); // Truncate or coalesce anything which overlaps the start of our new entry final Map.Entry<K, TwoTuple<Range<K>, V>> prior = getEntry(key.lowerEndpoint()); if (prior != null) { if (prior.getValue().getT().equals(value)) { // Values are the same so we can coalesce. if (resultantEnd.compareTo(prior.getValue().getS().upperEndpoint()) < 0) { // Existing entry already covers this; we don't have to do anything more return; } underlying.remove(prior.getKey()); // Set our start to the start of the prior entry resultantStart = prior.getKey(); } else { // Values are different; truncate prior item underlying.put(prior.getKey(), new TwoTuple<>(Range.closedOpen(prior.getKey(), resultantStart), prior.getValue().getT())); // If the prior entry stretches beyond the new entry we also need to put in our remaining item if (resultantEnd.compareTo(prior.getValue().getS().upperEndpoint()) < 0) { underlying.put(resultantEnd, new TwoTuple<>(Range.closedOpen(resultantEnd, prior.getValue().getS().upperEndpoint()), prior.getValue().getT())); } } } // Remove any items which are covered by our new entry, and truncate or coalesce anything which overlaps the end of it Map.Entry<K, TwoTuple<Range<K>, V>> potentialVictim = underlying.ceilingEntry(resultantStart); while (potentialVictim != null) { if (key.encloses(potentialVictim.getValue().getS())) { // Totally enclosed; remove it underlying.remove(potentialVictim.getKey()); potentialVictim = underlying.ceilingEntry(resultantStart); } else if (key.contains(potentialVictim.getKey())) { // Partial overlap if (potentialVictim.getValue().getT().equals(value)) { // Values are the same so we can coalesce. Remove the entry and update our bounds accordingly resultantEnd = potentialVictim.getValue().getS().upperEndpoint(); underlying.remove(potentialVictim.getKey()); } else { // Values are different; truncate victim item underlying.remove(potentialVictim.getKey()); underlying.put(resultantEnd, new TwoTuple<>( Range.closedOpen(resultantEnd, potentialVictim.getValue().getS().upperEndpoint()), potentialVictim.getValue().getT())); } potentialVictim = null; } else { // No relationship potentialVictim = null; } } // Write out our final result underlying.put(resultantStart, new TwoTuple<>(Range.closedOpen(resultantStart, resultantEnd), value)); }
From source file:edu.cmu.sphinx.alignment.LongTextAligner.java
/** * Aligns query sequence with the previously built database. * * @return indices of alignment// w w w. java2 s . com */ public int[] align(List<String> words, Range<Integer> range) { if (range.upperEndpoint() - range.lowerEndpoint() < tupleSize || words.size() < tupleSize) { return new GlobalSequenceAligner<String>( refWords.subList(range.lowerEndpoint(), range.upperEndpoint() + 1), range.lowerEndpoint()) .align(words); } int[] result = new int[words.size()]; fill(result, -1); int lastIndex = 0; for (Alignment.Node node : new Alignment(getTuples(words), range).getIndices()) { // for (int j = 0; j < tupleSize; ++j) lastIndex = max(lastIndex, node.getQueryIndex()); for (; lastIndex < node.getQueryIndex() + tupleSize; ++lastIndex) result[lastIndex] = node.getDatabaseIndex() + lastIndex - node.getQueryIndex(); } return result; }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.ProposalMatch.java
Optional<ProposalMatch> mapAndShiftToFragment(final int startIndex, final int length) { final List<Range<Integer>> rangesInDomain = new ArrayList<>(); final Range<Integer> targetDomain = Range.closedOpen(startIndex, startIndex + length); for (final Range<Integer> match : this) { if (match.encloses(targetDomain)) { rangesInDomain.add(targetDomain); } else if (targetDomain.encloses(match)) { rangesInDomain.add(match);/*from w ww . j a va 2 s . c o m*/ } else if (match.lowerEndpoint().intValue() <= startIndex && startIndex <= match.upperEndpoint().intValue()) { rangesInDomain.add(Range.closedOpen(startIndex, match.upperEndpoint())); } else if (match.lowerEndpoint().intValue() <= startIndex + length && startIndex + startIndex <= match.upperEndpoint().intValue()) { rangesInDomain.add(Range.closedOpen(match.lowerEndpoint(), startIndex + length)); } } final List<Range<Integer>> newMatches = new ArrayList<>(); for (final Range<Integer> match : rangesInDomain) { newMatches .add(Range.closedOpen(match.lowerEndpoint() - startIndex, match.upperEndpoint() - startIndex)); } return newMatches.isEmpty() ? Optional.<ProposalMatch>empty() : Optional.of(new ProposalMatch(newMatches)); }
From source file:com.yahoo.gondola.container.client.ZookeeperShardManagerClient.java
@Override public void rollbackBuckets(Range<Integer> splitRange) throws ShardManagerException, InterruptedException { sendActionToAll(MIGRATE_ROLLBACK, splitRange.lowerEndpoint(), splitRange.upperEndpoint()); if (!waitCondition(null, ZookeeperStat::isNormalOperational, 3000)) { throw new ShardManagerException(FAILED_BUCKET_ROLLBACK, "timed out"); }//from w ww .j a v a 2s . c o m sendActionToAll(NOOP); }
From source file:org.corpus_tools.peppermodules.annis.Audio2ANNISMapper.java
private void outputVirtualTokenAnnotations() { for (Map.Entry<Long, Range<Double>> e : virtTokenTimes.entrySet()) { Range<Double> r = e.getValue(); String val = null; if (r.hasLowerBound() && r.hasUpperBound()) { val = r.lowerEndpoint() + "-" + r.upperEndpoint(); } else if (r.hasLowerBound()) { val = "" + r.lowerEndpoint(); } else if (r.hasUpperBound()) { val = "-" + r.upperEndpoint(); }// w w w. j av a 2s .c om if (val != null) { mapSNodeAnnotation(e.getKey(), "annis", "time", val); } } }
From source file:it.units.malelab.ege.ge.mapper.WeightedHierarchicalMapper.java
@Override protected List<Range<Integer>> getChildrenSlices(Range<Integer> range, List<T> symbols) { if (!weightChildren) { return super.getChildrenSlices(range, symbols); }/*from w w w. j a v a2 s . c om*/ List<Range<Integer>> ranges; if (symbols.size() > (range.upperEndpoint() - range.lowerEndpoint())) { ranges = new ArrayList<>(symbols.size()); for (T symbol : symbols) { ranges.add(Range.closedOpen(range.lowerEndpoint(), range.lowerEndpoint())); } } else { List<Integer> sizes = new ArrayList<>(symbols.size()); int overallWeight = 0; for (T symbol : symbols) { overallWeight = overallWeight + weightsMap.get(symbol); } for (T symbol : symbols) { sizes.add((int) Math.floor((double) weightsMap.get(symbol) / (double) overallWeight * (double) (range.upperEndpoint() - range.lowerEndpoint()))); } ranges = Utils.slices(range, sizes); } return ranges; }