List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:com.act.lcms.MS2.java
private double extractMZ(double mzWanted, List<Pair<Double, Double>> intensities) { double intensityFound = 0; int numWithinPrecision = 0; double mzLowRange = mzWanted - MS1_MZ_TOLERANCE; double mzHighRange = mzWanted + MS1_MZ_TOLERANCE; // we expect there to be pretty much only one intensity value in the precision // range we are looking at. But if a lot of masses show up then complain for (Pair<Double, Double> mz_int : intensities) { double mz = mz_int.getLeft(); double intensity = mz_int.getRight(); if (mz >= mzLowRange && mz <= mzHighRange) { intensityFound += intensity; numWithinPrecision++;/*from w w w .ja v a 2 s . c o m*/ } } if (numWithinPrecision > MAX_MZ_IN_WINDOW) { System.out.format("Only expected %d, but found %d in the mz range [%f, %f]\n", MAX_MZ_IN_WINDOW, numWithinPrecision, mzLowRange, mzHighRange); } return intensityFound; }
From source file:de.tntinteractive.portalsammler.gui.MainDialog.java
private void poll(final Gui gui) { this.pollButton.setEnabled(false); final Settings settings = this.getStore().getSettings().deepClone(); final ProgressMonitor progress = new ProgressMonitor(this, "Sammle Daten aus den Quell-Portalen...", "...", 0, settings.getSize());/*from w w w . j av a 2 s . co m*/ progress.setMillisToDecideToPopup(0); progress.setMillisToPopup(0); progress.setProgress(0); final SwingWorker<String, String> task = new SwingWorker<String, String>() { @Override protected String doInBackground() throws Exception { final StringBuilder summary = new StringBuilder(); int cnt = 0; for (final String id : settings.getAllSettingIds()) { if (this.isCancelled()) { break; } cnt++; this.publish(cnt + ": " + id); final Pair<Integer, Integer> counts = MainDialog.this.pollSingleSource(settings, id); summary.append(id).append(": "); if (counts != null) { summary.append(counts.getLeft()).append(" neu, ").append(counts.getRight()) .append(" schon bekannt\n"); } else { summary.append("Fehler!\n"); } this.setProgress(cnt); } MainDialog.this.getStore().writeMetadata(); return summary.toString(); } @Override protected void process(final List<String> ids) { progress.setNote(ids.get(ids.size() - 1)); } @Override public void done() { MainDialog.this.pollButton.setEnabled(true); MainDialog.this.table.refreshContents(); try { final String summary = this.get(); JOptionPane.showMessageDialog(MainDialog.this, summary, "Abruf-Zusammenfassung", JOptionPane.INFORMATION_MESSAGE); } catch (final Exception e) { gui.showError(e); } } }; task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { progress.setProgress((Integer) evt.getNewValue()); } if (progress.isCanceled()) { task.cancel(true); } } }); task.execute(); }
From source file:de.hasait.clap.impl.CLAPClassNode.java
@Override public void printUsage(final Map<CLAPUsageCategoryImpl, StringBuilder> pCategories, final CLAPUsageCategoryImpl pCurrentCategory, final StringBuilder pResult) { final Pair<CLAPUsageCategoryImpl, StringBuilder> pair = handleUsageCategory(pCategories, pCurrentCategory, pResult);/*from ww w . j a va2s.c om*/ if (pair != null) { final CLAPUsageCategoryImpl currentCategory = pair.getLeft(); final StringBuilder result = pair.getRight(); internalPrintUsage(pCategories, currentCategory, result, " "); //$NON-NLS-1$ } }
From source file:cn.liutils.vis.animation.CubicSplineCurve.java
private double kval(int index) { Pair<Double, Double> pt1 = null, pt2 = null, pt3 = null; boolean flag = false; if (index == 0) { pt1 = pts.get(0);/*w ww. j a v a2 s. c o m*/ pt2 = pts.get(1); flag = true; } if (index == pts.size() - 1) { pt1 = pts.get(pts.size() - 2); pt2 = pts.get(index); flag = true; } if (flag) return (pt2.getRight() - pt1.getRight()) / (pt2.getLeft() - pt1.getLeft()); pt1 = pts.get(index - 1); pt2 = pts.get(index); pt3 = pts.get(index + 1); return ((pt2.getRight() - pt1.getRight()) / (pt2.getLeft() - pt1.getLeft()) + (pt3.getRight() - pt2.getRight()) / (pt3.getLeft() - pt2.getLeft())) / 2; }
From source file:at.gridtec.lambda4j.function.bi.to.ToByteBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//* ww w . j a v a 2 s . c o m*/ default byte applyAsByte(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsByte(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToCharBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//* w w w.j a v a 2 s .co m*/ default char applyAsChar(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsChar(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToFloatBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//*from ww w . ja v a 2 s.co m*/ default float applyAsFloat(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsFloat(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToShortBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair */// w ww . ja va2 s . c om default short applyAsShort(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsShort(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToIntBiFunction2.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//* ww w . j a va 2 s . com*/ default int applyAsInt(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsInt(tuple.getLeft(), tuple.getRight()); }
From source file:com.wolvereness.overmapped.OverMapped.java
private void writeToFile(final MultiProcessor executor, final Map<String, ByteClass> byteClasses, final List<Pair<ZipEntry, byte[]>> fileEntries, final BiMap<String, String> nameMaps, final BiMap<Signature, Signature> signatureMaps, final Map<Signature, Integer> flags) throws IOException, FileNotFoundException, InterruptedException, ExecutionException { final Collection<Future<Pair<ZipEntry, byte[]>>> classWrites = newArrayList(); for (final ByteClass clazz : byteClasses.values()) { classWrites.add(// ww w. j av a 2 s .c o m executor.submit(clazz.callable(signatureMaps, nameMaps, byteClasses, flags, correctEnums))); } FileOutputStream fileOut = null; JarOutputStream jar = null; try { jar = new JarOutputStream(fileOut = new FileOutputStream(output)); for (final Pair<ZipEntry, byte[]> fileEntry : fileEntries) { jar.putNextEntry(fileEntry.getLeft()); jar.write(fileEntry.getRight()); } for (final Future<Pair<ZipEntry, byte[]>> fileEntryFuture : classWrites) { final Pair<ZipEntry, byte[]> fileEntry = fileEntryFuture.get(); jar.putNextEntry(fileEntry.getLeft()); jar.write(fileEntry.getRight()); } } finally { if (jar != null) { try { jar.close(); } catch (final IOException ex) { } } if (fileOut != null) { try { fileOut.close(); } catch (final IOException ex) { } } } }