List of usage examples for java.util SortedSet first
E first();
From source file:uk.org.taverna.platform.report.StatusReport.java
/** * Get an invocation with a given name./* w w w.j a v a2 s . c o m*/ * @param invocationName * @return */ public Invocation getInvocation(String invocationName) { NavigableSet<Invocation> invocs = getInvocations(); // A Comparable Invocation with the desired name SortedSet<Invocation> tailSet = invocs.tailSet(new Invocation(invocationName)); if (!tailSet.isEmpty()) return tailSet.first(); return null; }
From source file:org.tonguetied.keywordmanagement.KeywordRepositoryImpl.java
/** * Create the search criteria for a {@link Translation}. * // www. j a v a2s . c o m * @param translations the translation to add to the criteria * @param ignoreCase flag indicating if case should be ignored during search * @param matchMode flag indicating the type of string pattern matching * @return the additional search parameters for the {@link Translation} * fields */ private Conjunction createTranslationConditions(SortedSet<Translation> translations, final boolean ignoreCase, final MatchMode matchMode) { Conjunction conjunction = null; if (translations != null && !translations.isEmpty()) { final Translation translation = translations.first(); Example criterionTranslation = Example.create(translation); criterionTranslation.enableLike(matchMode); if (ignoreCase) { criterionTranslation.ignoreCase(); } conjunction = conjunction(); conjunction.add(criterionTranslation); addBundleCriteria(conjunction, translation.getBundle()); addCountryCriteria(conjunction, translation.getCountry()); addLanguageCriteria(conjunction, translation.getLanguage()); } return conjunction; }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
private <T extends StatisticsInfo> void assertInfoSet(Statistics stats, SortedSet<T> info) { assertEquals(info.size(), stats.getSequenceNumber()); assertEquals(info.last().getSequenceNumber() + 1, stats.getSequenceNumber()); assertEquals(info.first().getTimestamp(), stats.getStartDate()); assertEquals(info.last().getTimestamp(), stats.getEndDate()); int i = 0;//from ww w . j a v a2 s .co m for (T next : info) { assertEquals(i, next.getSequenceNumber()); ++i; } }
From source file:org.isatools.tablib.export.graph2tab.LayersBuilder.java
/** * The minimal order on the left side of the node. That is: * <ul>/*w w w. j a v a2s . c o m*/ * <li>l0 = min ( nl.getOrder() != -1 and for all nl in m:layer(m) = layer(n) - 1)</li> * <li>if no node with order != -1 exist on the immediate left, layer(n) - 2,3,4... are evaluated the same way, * the final result is -1 if we reach the leftmost side of the graph</li> * </ul> * * This means that we seek for the node having a significant order that is closer to the current node, if no such * node exists, we signal that by returning -1 (proper decisions are taken in {@link #computeTypedLayers()} in * such cases, see there). * */ private int minOrderLeft(int layer) { while (--layer >= 0) { SortedSet<Node> lNodes = layer2Nodes.get(layer); if (!lNodes.isEmpty()) { int lno = lNodes.first().getOrder(); // Ignore "doesn't matter" nodes if (lno > -1) return lno; } } return -1; }
From source file:com.projity.contrib.calendar.ContribIntervals.java
public boolean add(Object o) { DateSpan toAdd = (DateSpan) o;//from www . ja v a2s. c om SortedSet set = headSet(o); if (set.size() > 0) { DateSpan interval = (DateSpan) set.last(); if (interval.getEnd() >= toAdd.getStart()) toAdd = mergeIntervals(toAdd, interval); } set = tailSet(o); if (set.size() > 0) { DateSpan interval = (DateSpan) set.first(); if (toAdd.getEnd() >= interval.getStart()) toAdd = mergeIntervals(toAdd, interval); } return super.add(toAdd); }
From source file:org.kalypso.model.wspm.ui.profil.wizard.createDivider.CreateDividerOperation.java
private Integer[] findOutermost(final Integer[] intersectionPoints) { Assert.isTrue(intersectionPoints.length > 1); final Integer[] result = new Integer[2]; final SortedSet<Integer> markerIndices = new TreeSet<>(Arrays.asList(intersectionPoints)); result[0] = markerIndices.first(); result[1] = markerIndices.last();//from w ww . ja va 2 s . c om return result; }
From source file:org.orekit.SolarInputs97to05.java
private void findClosestLine(AbsoluteDate date) throws OrekitException { if ((date.durationFrom(firstDate) < 0) || (date.durationFrom(lastDate) > Constants.JULIAN_DAY)) { throw new OrekitException(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, date, firstDate, lastDate); }/*from ww w. ja v a2s .c o m*/ // don't search if the cached selection is fine if ((currentParam != null) && (date.durationFrom(currentParam.date) >= 0) && (date.durationFrom(currentParam.date) < Constants.JULIAN_DAY)) { return; } LineParameters before = new LineParameters(date.shiftedBy(-Constants.JULIAN_DAY), null, 0, 0, 0, 0, 0, 0); // search starting from entries a few steps before the target date SortedSet<TimeStamped> tailSet = data.tailSet(before); if (tailSet != null) { currentParam = (LineParameters) tailSet.first(); if (currentParam.date.durationFrom(date) == -Constants.JULIAN_DAY) { currentParam = (LineParameters) data.tailSet(date).first(); } } else { throw new OrekitException(new DummyLocalizable("unable to find data for date {0}"), date); } }
From source file:com.octopepper.mediapickerinstagram.commons.cameraview.api14.Camera1.java
@SuppressWarnings("SuspiciousNameCombination") private Size chooseOptimalSize(SortedSet<Size> sizes) { if (!mPreview.isReady()) { // Not yet laid out return sizes.first(); // Return the smallest size }//from w ww . ja v a2 s . c o m int desiredWidth; int desiredHeight; final int surfaceWidth = mPreview.getWidth(); final int surfaceHeight = mPreview.getHeight(); if (mDisplayOrientation == 90 || mDisplayOrientation == 270) { desiredWidth = surfaceHeight; desiredHeight = surfaceWidth; } else { desiredWidth = surfaceWidth; desiredHeight = surfaceHeight; } Size result = null; for (Size size : sizes) { // Iterate from small to large if (desiredWidth <= size.getWidth() && desiredHeight <= size.getHeight()) { return size; } result = size; } return result; }
From source file:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java
/** * Gets the revision date text field.// w w w . ja v a 2s .c o m * * @return the revision date text field */ private JXDatePicker getRevisionDateTextField() { if (revisionDateTextField == null) { revisionDateTextField = new JXDatePicker(new Date()); revisionDateTextField.setFormats("yyyy-MM-dd"); final JXMonthView monthView = revisionDateTextField.getMonthView(); monthView.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent actionEvent) { if (getUserObject() instanceof SubversionExportTask) { final SubversionExportTask subversionExportTask = (SubversionExportTask) getUserObject(); final SortedSet<Date> selection = monthView.getSelection(); subversionExportTask.setRevisionDate(selection.size() == 0 ? null : selection.first()); } } }); } return revisionDateTextField; }
From source file:org.kalypso.model.wspm.ui.profil.wizard.createDivider.CreateDividerOperation.java
private Integer[] mixExistingWithIntersectionPoint(final IProfile profil, final Integer intersectionIndex) { final Integer[] markerPoints = existingMarkersAsIndices(profil); final SortedSet<Integer> markerIndices = new TreeSet<>(Arrays.asList(markerPoints)); // depends on the side of the profile! final IProfileRecord lowestPoint = ProfileVisitors.findLowestPoint(profil); if (Objects.isNull(lowestPoint)) return new Integer[] { intersectionIndex }; final Collection<Integer> result = new ArrayList<>(2); result.add(intersectionIndex);// w w w. j a v a 2 s .c o m if (intersectionIndex > lowestPoint.getIndex()) { // use leftmost of all left markers final SortedSet<Integer> leftSet = markerIndices.headSet(lowestPoint.getIndex()); if (!leftSet.isEmpty()) { result.add(leftSet.first()); } } else { // use leftmost of all left markers final SortedSet<Integer> rightSet = markerIndices.tailSet(lowestPoint.getIndex()); if (!rightSet.isEmpty()) { result.add(rightSet.last()); } } return result.toArray(new Integer[result.size()]); }