List of usage examples for com.google.common.base Preconditions checkPositionIndex
public static int checkPositionIndex(int index, int size)
From source file:eu.matejkormuth.rpgdavid.text.TextTable.java
/** * Inserts specified content at specified line aligning content to right. If * is content too long, it will be tructated. * //from w w w. j a va 2s .c o m * @param line * line to insert at * @param content * content to insert */ public void renderRightAlignedText(final int line, final String content) { Preconditions.checkPositionIndex(line, this.lines.length); Preconditions.checkArgument(content.length() < this.internalWidth); this.renderText(line, this.internalWidth - content.length(), content); }
From source file:org.apache.hama.graph.AggregationRunner.java
public final Writable getLastAggregatedValue(int index) { return globalAggregatorResult[Preconditions.checkPositionIndex(index, globalAggregatorResult.length)]; }
From source file:eu.matejkormuth.rpgdavid.text.TextTable.java
/** * Inserts specified content at specified line aligning content to left. If * is content too long, it will be tructated. Same as calling * <code>renderText(line, 2, content)</code>. * /*w ww . j av a2 s. com*/ * @param line * line to insert at * @param content * content to insert */ public void renderLeftAlignedText(final int line, final String content) { Preconditions.checkPositionIndex(line, this.lines.length); Preconditions.checkArgument(content.length() < this.internalWidth); this.renderText(line, 2, content); }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the area of this feature.// w w w. j a v a2s . c o m * * @return a double. * @param rtValues * an array of * {@link io.github.msdk.datamodel.rawdata.ChromatographyInfo} * objects. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Double getArea(@Nonnull ChromatographyInfo rtValues[], @Nonnull float[] intensityValues, @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(rtValues); Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, rtValues.length); Preconditions.checkPositionIndex(size, intensityValues.length); if (size == 0) return null; double area = 0, rtDifference = 0, intensityStart = 0, intensityEnd = 0; for (int i = 0; i < size - 1; i++) { rtDifference = rtValues[i + 1].getRetentionTime() - rtValues[i].getRetentionTime(); intensityStart = intensityValues[i]; intensityEnd = intensityValues[i + 1]; area += (rtDifference * (intensityStart + intensityEnd) / 2); } return area; }
From source file:org.apache.hama.graph.AggregationRunner.java
public final IntWritable getNumLastAggregatedVertices(int index) { return globalAggregatorIncrement[Preconditions.checkPositionIndex(index, globalAggregatorIncrement.length)]; }
From source file:eu.matejkormuth.rpgdavid.text.TextTable.java
/** * Renders horizontal spacer line on specified line. * /* w ww .ja v a2 s .c om*/ * @param line * line to render at */ public void renderSpacerLine(final int line) { Preconditions.checkPositionIndex(line, this.lines.length); for (int i = 0; i < this.internalWidth + 1; i++) { if (i == 0) { this.renderText(line, i, ""); } else if (i == this.internalWidth + 2) { this.renderText(line, i, ""); } else { this.renderText(line, i, HORIZONTAL_SIDE); } } }
From source file:eu.matejkormuth.rpgdavid.text.TextTable.java
/** * Renders clear line (line with side borders, full width) on specified * line.// ww w .j a v a2 s .co m * * @param line * line to render at */ public void renderClearLine(final int line) { Preconditions.checkPositionIndex(line, this.lines.length); for (int i = 0; i < this.internalWidth + 1; i++) { if (i == 0) { this.renderText(line, i, VERTICAL_SIDE); } else if (i == this.internalWidth + 2) { this.renderText(line, i, VERTICAL_SIDE); } else { this.renderText(line, i, SPACE); } } }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the full width at half maximum (FWHM) of this feature. * * @return a {@link java.lang.Double} object. * @param rtValues/*from ww w.j a v a 2s.c o m*/ * an array of * {@link io.github.msdk.datamodel.rawdata.ChromatographyInfo} * objects. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Double getFwhm(@Nonnull ChromatographyInfo rtValues[], @Nonnull float[] intensityValues, @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(rtValues); Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, rtValues.length); Preconditions.checkPositionIndex(size, intensityValues.length); if (size == 0) return null; Float height = getMaxHeight(intensityValues, size); Float rt = getRt(rtValues, intensityValues, size); if (height == null || rt == null) return null; double rtVals[] = findRTs(height / 2, rt, rtValues, intensityValues, size); Double fwhm = rtVals[1] - rtVals[0]; if (fwhm < 0) { fwhm = null; } return fwhm; }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the tailing factor of this feature. * * @return a {@link java.lang.Double} object. * @param rtValues// ww w.j a v a 2 s . co m * an array of * {@link io.github.msdk.datamodel.rawdata.ChromatographyInfo} * objects. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Double getTailingFactor(@Nonnull ChromatographyInfo rtValues[], @Nonnull float[] intensityValues, @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(rtValues); Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, rtValues.length); Preconditions.checkPositionIndex(size, intensityValues.length); if (size == 0) return null; Float height = getMaxHeight(intensityValues, size); Float rt = getRt(rtValues, intensityValues, size); if (height == null || rt == null) return null; double rtVals[] = findRTs(height * 0.05, rt, rtValues, intensityValues, size); if (rtVals[1] == 0) rtVals[1] = getRtEnd(rtValues, size); Double tf = (rtVals[1] - rtVals[0]) / (2 * (rt - rtVals[0])); if (tf < 0) { tf = null; } return tf; }
From source file:net.automatalib.commons.util.array.RichArray.java
@Override public ListIterator<T> listIterator(int index) { Preconditions.checkPositionIndex(index, length); return new ArrayIterator<>(contents, start + index, end()); }