Java Code Examples for com.google.common.collect.Range#span()
The following examples show how to use
com.google.common.collect.Range#span() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeakUtils.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Finds a combined m/z range that covers all given peaks */ public static Range<Double> findMZRange(Feature peaks[]) { Range<Double> mzRange = null; for (Feature p : peaks) { if (mzRange == null) { mzRange = p.getRawDataPointsMZRange(); } else { mzRange = mzRange.span(p.getRawDataPointsMZRange()); } } return mzRange; }
Example 2
Source File: PeakUtils.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
/** * Finds a combined m/z range that covers all given peaks */ public static Range<Double> findMZRange(Feature peaks[]) { Range<Double> mzRange = null; for (Feature p : peaks) { if (mzRange == null) { mzRange = p.getRawDataPointsMZRange(); } else { mzRange = mzRange.span(p.getRawDataPointsMZRange()); } } return mzRange; }
Example 3
Source File: RawDataFileImpl.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public @Nonnull Range<Double> getDataMZRange(int msLevel) { // check if we have this value already cached Range<Double> mzRange = dataMZRange.get(msLevel); if (mzRange != null) return mzRange; // find the value for (Scan scan : scans.values()) { // ignore scans of other ms levels if ((msLevel != 0) && (scan.getMSLevel() != msLevel)) continue; if (mzRange == null) mzRange = scan.getDataPointMZRange(); else mzRange = mzRange.span(scan.getDataPointMZRange()); } // cache the value, if we found any if (mzRange != null) dataMZRange.put(msLevel, mzRange); else mzRange = Range.singleton(0.0); return mzRange; }
Example 4
Source File: RawDataFileImpl.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public @Nonnull Range<Double> getDataRTRange(int msLevel) { // check if we have this value already cached Range<Double> rtRange = dataRTRange.get(msLevel); if (rtRange != null) return rtRange; // find the value for (Scan scan : scans.values()) { // ignore scans of other ms levels if ((msLevel != 0) && (scan.getMSLevel() != msLevel)) continue; if (rtRange == null) rtRange = Range.singleton(scan.getRetentionTime()); else rtRange = rtRange.span(Range.singleton(scan.getRetentionTime())); } // cache the value if (rtRange != null) dataRTRange.put(msLevel, rtRange); else rtRange = Range.singleton(0.0); return rtRange; }
Example 5
Source File: RawDataFileUtils.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public static @Nonnull Range<Double> findTotalRTRange(RawDataFile dataFiles[], int msLevel) { Range<Double> rtRange = null; for (RawDataFile file : dataFiles) { Range<Double> dfRange = file.getDataRTRange(msLevel); if (dfRange == null) continue; if (rtRange == null) rtRange = dfRange; else rtRange = rtRange.span(dfRange); } if (rtRange == null) rtRange = Range.singleton(0.0); return rtRange; }
Example 6
Source File: RawDataFileUtils.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public static @Nonnull Range<Double> findTotalMZRange(RawDataFile dataFiles[], int msLevel) { Range<Double> mzRange = null; for (RawDataFile file : dataFiles) { Range<Double> dfRange = file.getDataMZRange(msLevel); if (dfRange == null) continue; if (mzRange == null) mzRange = dfRange; else mzRange = mzRange.span(dfRange); } if (mzRange == null) mzRange = Range.singleton(0.0); return mzRange; }
Example 7
Source File: RangeUtil.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public static <C extends Comparable<?>> Range<C> merge(Range<C> a, Range<C> b) { if (a == null && b == null) { return null; } else if (a == null || b == null) { return a == null ? b : a; } else { return a.span(b); } }
Example 8
Source File: Ranges.java From science-journal with Apache License 2.0 | 5 votes |
static <T extends Comparable<T>> Range<T> span(Range<T> a, Range<T> b) { if (a == null) { return b; } if (b == null) { return a; } return a.span(b); }
Example 9
Source File: NamespaceBundlesTest.java From pulsar with Apache License 2.0 | 5 votes |
private void validateSplitBundlesRange(NamespaceBundle fullBundle, List<NamespaceBundle> splitBundles) { assertNotNull(fullBundle); assertNotNull(splitBundles); Range<Long> fullRange = fullBundle.getKeyRange(); Range<Long> span = splitBundles.get(0).getKeyRange(); for (NamespaceBundle bundle : splitBundles) { span = span.span(bundle.getKeyRange()); } assertEquals(span, fullRange); }
Example 10
Source File: RawDataFileImpl.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
@Override public @Nonnull Range<Double> getDataMZRange(int msLevel) { // check if we have this value already cached Range<Double> mzRange = dataMZRange.get(msLevel); if (mzRange != null) return mzRange; // find the value for (Scan scan : scans.values()) { // ignore scans of other ms levels if ((msLevel != 0) && (scan.getMSLevel() != msLevel)) continue; if (mzRange == null) mzRange = scan.getDataPointMZRange(); else mzRange = mzRange.span(scan.getDataPointMZRange()); } // cache the value, if we found any if (mzRange != null) dataMZRange.put(msLevel, mzRange); else mzRange = Range.singleton(0.0); return mzRange; }
Example 11
Source File: RawDataFileImpl.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
@Override public @Nonnull Range<Double> getDataRTRange(int msLevel) { // check if we have this value already cached Range<Double> rtRange = dataRTRange.get(msLevel); if (rtRange != null) return rtRange; // find the value for (Scan scan : scans.values()) { // ignore scans of other ms levels if ((msLevel != 0) && (scan.getMSLevel() != msLevel)) continue; if (rtRange == null) rtRange = Range.singleton(scan.getRetentionTime()); else rtRange = rtRange.span(Range.singleton(scan.getRetentionTime())); } // cache the value if (rtRange != null) dataRTRange.put(msLevel, rtRange); else rtRange = Range.singleton(0.0); return rtRange; }
Example 12
Source File: RawDataFileUtils.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public static @Nonnull Range<Double> findTotalRTRange(RawDataFile dataFiles[], int msLevel) { Range<Double> rtRange = null; for (RawDataFile file : dataFiles) { Range<Double> dfRange = file.getDataRTRange(msLevel); if (dfRange == null) continue; if (rtRange == null) rtRange = dfRange; else rtRange = rtRange.span(dfRange); } if (rtRange == null) rtRange = Range.singleton(0.0); return rtRange; }
Example 13
Source File: RawDataFileUtils.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public static @Nonnull Range<Double> findTotalMZRange(RawDataFile dataFiles[], int msLevel) { Range<Double> mzRange = null; for (RawDataFile file : dataFiles) { Range<Double> dfRange = file.getDataMZRange(msLevel); if (dfRange == null) continue; if (mzRange == null) mzRange = dfRange; else mzRange = mzRange.span(dfRange); } if (mzRange == null) mzRange = Range.singleton(0.0); return mzRange; }
Example 14
Source File: RTRangeComponent.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
@Override public void actionPerformed(ActionEvent event) { Object src = event.getSource(); if (src == setAutoButton) { RawDataFile currentFiles[] = MZmineCore.getProjectManager().getCurrentProject().getDataFiles(); try { ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this); RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog .getComponentForParameter(new RawDataFilesParameter()); // If the current setup dialog has no raw data file selector, it // is probably in the parent dialog, so let's check it if (rdc == null) { setupDialog = (ParameterSetupDialog) setupDialog.getParent(); if (setupDialog != null) { rdc = (RawDataFilesComponent) setupDialog .getComponentForParameter(new RawDataFilesParameter()); } } if (rdc != null) { RawDataFile matchingFiles[] = rdc.getValue().getMatchingRawDataFiles(); if (matchingFiles.length > 0) currentFiles = matchingFiles; } } catch (Exception e) { e.printStackTrace(); } Range<Double> rtRange = null; for (RawDataFile file : currentFiles) { Range<Double> fileRange = file.getDataRTRange(); if (rtRange == null) rtRange = fileRange; else rtRange = rtRange.span(fileRange); } setValue(rtRange); } }
Example 15
Source File: SchedulerImpl.java From ganttproject with GNU General Public License v3.0 | 4 votes |
private void schedule(Node node) { Logger logger = GPLogger.getLogger(this); GPLogger.debug(logger, "Scheduling node %s", node); Range<Date> startRange = Range.all(); Range<Date> endRange = Range.all(); Range<Date> weakStartRange = Range.all(); Range<Date> weakEndRange = Range.all(); List<Date> subtaskRanges = Lists.newArrayList(); List<DependencyEdge> incoming = node.getIncoming(); GPLogger.debug(logger, ".. #incoming edges=%d", incoming.size()); for (DependencyEdge edge : incoming) { if (!edge.refresh()) { continue; } if (edge instanceof ImplicitSubSuperTaskDependency) { subtaskRanges.add(edge.getStartRange().upperEndpoint()); subtaskRanges.add(edge.getEndRange().lowerEndpoint()); } else { if (edge.isWeak()) { weakStartRange = weakStartRange.intersection(edge.getStartRange()); weakEndRange = weakEndRange.intersection(edge.getEndRange()); } else { startRange = startRange.intersection(edge.getStartRange()); endRange = endRange.intersection(edge.getEndRange()); } } if (startRange.isEmpty() || endRange.isEmpty()) { GPLogger.logToLogger("both start and end ranges were calculated as empty for task=" + node.getTask() + ". Skipping it"); } } GPLogger.debug(logger, "..Ranges: start=%s end=%s weakStart=%s weakEnd=%s", startRange, endRange, weakStartRange, weakEndRange); Range<Date> subtasksSpan = subtaskRanges.isEmpty() ? Range.closed(node.getTask().getStart().getTime(), node.getTask().getEnd().getTime()) : Range.encloseAll(subtaskRanges); Range<Date> subtreeStartUpwards = subtasksSpan.span(Range.downTo(node.getTask().getStart().getTime(), BoundType.CLOSED)); Range<Date> subtreeEndDownwards = subtasksSpan.span(Range.upTo(node.getTask().getEnd().getTime(), BoundType.CLOSED)); GPLogger.debug(logger, "..Subtasks span=%s", subtasksSpan); if (!startRange.equals(Range.all())) { startRange = startRange.intersection(weakStartRange); } else if (!weakStartRange.equals(Range.all())) { startRange = weakStartRange.intersection(subtreeStartUpwards); } if (!endRange.equals(Range.all())) { endRange = endRange.intersection(weakEndRange); } else if (!weakEndRange.equals(Range.all())) { endRange = weakEndRange.intersection(subtreeEndDownwards); } if (node.getTask().getThirdDateConstraint() == TaskImpl.EARLIESTBEGIN && node.getTask().getThird() != null) { startRange = startRange.intersection(Range.downTo(node.getTask().getThird().getTime(), BoundType.CLOSED)); GPLogger.debug(logger, ".. applying earliest start=%s. Now start range=%s", node.getTask().getThird(), startRange); } if (!subtaskRanges.isEmpty()) { startRange = startRange.intersection(subtasksSpan); endRange = endRange.intersection(subtasksSpan); } GPLogger.debug(logger, ".. finally, start range=%s", startRange); if (startRange.hasLowerBound()) { modifyTaskStart(node.getTask(), startRange.lowerEndpoint()); } if (endRange.hasUpperBound()) { GPCalendarCalc cal = node.getTask().getManager().getCalendar(); Date endDate = endRange.upperEndpoint(); TimeUnit timeUnit = node.getTask().getDuration().getTimeUnit(); if (DayMask.WORKING == (cal.getDayMask(endDate) & DayMask.WORKING)) { // in case if calculated end date falls on first day after holidays (say, on Monday) // we'll want to modify it a little bit, so that it falls on that holidays start // If we don't do this, it will be done automatically the next time task activities are recalculated, // and thus task end date will keep changing Date closestWorkingEndDate = cal.findClosest( endDate, timeUnit, GPCalendarCalc.MoveDirection.BACKWARD, GPCalendar.DayType.WORKING); Date closestNonWorkingEndDate = cal.findClosest( endDate, timeUnit, GPCalendarCalc.MoveDirection.BACKWARD, GPCalendar.DayType.NON_WORKING, closestWorkingEndDate); // If there is a non-working date between current task end and closest working date // then we're really just after holidays if (closestNonWorkingEndDate != null && closestWorkingEndDate.before(closestNonWorkingEndDate)) { // we need to adjust-right closest working date to position to the very beginning of the holidays interval Date nonWorkingPeriodStart = timeUnit.adjustRight(closestWorkingEndDate); if (nonWorkingPeriodStart.after(node.getTask().getStart().getTime())) { endDate = nonWorkingPeriodStart; } } } modifyTaskEnd(node.getTask(), endDate); } }