List of usage examples for java.util.function IntFunction apply
R apply(int value);
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjFloatPredicate.java
/** * Returns a composed {@link TriIntPredicate} that first applies the {@code before} functions to * its input, and then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * This method is just convenience, to provide the ability to execute an operation which accepts {@code int} input, * before this primitive predicate is executed. * * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriIntPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is a able to handle primitive values. In this case this is {@code * int}./*from w w w . j a va2 s.com*/ */ @Nonnull default TriIntPredicate composeFromInt(@Nonnull final IntFunction<? extends T> before1, @Nonnull final IntFunction<? extends U> before2, @Nonnull final IntToFloatFunction before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (value1, value2, value3) -> test(before1.apply(value1), before2.apply(value2), before3.applyAsFloat(value3)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjLongPredicate.java
/** * Returns a composed {@link TriIntPredicate} that first applies the {@code before} functions to * its input, and then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * This method is just convenience, to provide the ability to execute an operation which accepts {@code int} input, * before this primitive predicate is executed. * * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriIntPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is a able to handle primitive values. In this case this is {@code * int}.//ww w .ja va 2 s . c o m */ @Nonnull default TriIntPredicate composeFromInt(@Nonnull final IntFunction<? extends T> before1, @Nonnull final IntFunction<? extends U> before2, @Nonnull final IntToLongFunction before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (value1, value2, value3) -> test(before1.apply(value1), before2.apply(value2), before3.applyAsLong(value3)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjShortPredicate.java
/** * Returns a composed {@link TriIntPredicate} that first applies the {@code before} functions to * its input, and then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * This method is just convenience, to provide the ability to execute an operation which accepts {@code int} input, * before this primitive predicate is executed. * * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriIntPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is a able to handle primitive values. In this case this is {@code * int}.// ww w . j a va 2 s . c o m */ @Nonnull default TriIntPredicate composeFromInt(@Nonnull final IntFunction<? extends T> before1, @Nonnull final IntFunction<? extends U> before2, @Nonnull final IntToShortFunction before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (value1, value2, value3) -> test(before1.apply(value1), before2.apply(value2), before3.applyAsShort(value3)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjDoublePredicate.java
/** * Returns a composed {@link TriIntPredicate} that first applies the {@code before} functions to * its input, and then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * This method is just convenience, to provide the ability to execute an operation which accepts {@code int} input, * before this primitive predicate is executed. * * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriIntPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is a able to handle primitive values. In this case this is {@code * int}.//from w ww . ja va 2 s .c om */ @Nonnull default TriIntPredicate composeFromInt(@Nonnull final IntFunction<? extends T> before1, @Nonnull final IntFunction<? extends U> before2, @Nonnull final IntToDoubleFunction before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (value1, value2, value3) -> test(before1.apply(value1), before2.apply(value2), before3.applyAsDouble(value3)); }
From source file:blusunrize.immersiveengineering.client.render.IEShaderLayerCompositeTexture.java
@Override public void loadTexture(IResourceManager resourceManager) { this.deleteGlTexture(); IResource iresource = null;//w w w.j av a2 s. com BufferedImage bufferedimage; BufferedImage scaledImage; label255: { try { iresource = resourceManager.getResource(this.canvasTexture); BufferedImage canvasImage = TextureUtil.readBufferedImage(iresource.getInputStream()); int imageType = canvasImage.getType(); if (imageType == 0) imageType = 6; int canvasWidth = canvasImage.getWidth(); int canvasHeight = canvasImage.getHeight(); bufferedimage = new BufferedImage(canvasWidth, canvasHeight, imageType); int layer = 0; while (true) { if (layer >= 17 || layer >= this.layers.length) break label255; IResource iresource1 = null; try { String texPath = this.layers[layer].getTexture().getPath(); if (!texPath.startsWith("textures/")) texPath = "textures/" + texPath; if (!texPath.endsWith(".png")) texPath += ".png"; String texture = this.layers[layer].getTexture().getNamespace() + ":" + texPath; int colour = this.layers[layer].getColour(); iresource1 = resourceManager.getResource(new ResourceLocation(texture)); BufferedImage texureImage = TextureUtil.readBufferedImage(iresource1.getInputStream()); scaledImage = new BufferedImage(canvasWidth, canvasHeight, imageType); float[] mod = { (colour >> 16 & 255) / 255f, (colour >> 8 & 255) / 255f, (colour & 255) / 255f, (colour >> 24 & 255) / 255f }; IntFunction<Integer> uInterpolate = uIn -> uIn; IntFunction<Integer> vInterpolate = vIn -> vIn; int bufImg2Size = Math.min(texureImage.getWidth(), texureImage.getHeight()); int uMin = 0; int vMin = 0; int uMax = canvasWidth; int vMax = canvasHeight; final double[] texBounds = this.layers[layer].getTextureBounds(); if (texBounds != null) { final double uOffset = texBounds[0] * canvasWidth; final double vOffset = texBounds[1] * canvasHeight; final double uScale = bufImg2Size / ((texBounds[2] - texBounds[0]) * canvasWidth); final double vScale = bufImg2Size / ((texBounds[3] - texBounds[1]) * canvasHeight); uInterpolate = uIn -> (int) Math.round((uIn - uOffset) * uScale); vInterpolate = vIn -> (int) Math.round((vIn - vOffset) * vScale); uMin = (int) uOffset; vMin = (int) vOffset; uMax = (int) (texBounds[2] * canvasWidth); vMax = (int) (texBounds[3] * canvasHeight); } try { for (int v = vMin; v < vMax; ++v) for (int u = uMin; u < uMax; ++u) { int interU = uInterpolate.apply(u) % bufImg2Size; int interV = vInterpolate.apply(v) % bufImg2Size; int iRGB = texureImage.getRGB(interU, interV); float[] rgb = { (iRGB >> 16 & 255) / 255f, (iRGB >> 8 & 255) / 255f, (iRGB & 255) / 255f, (iRGB >> 24 & 255) / 255f }; if ((iRGB & -16777216) != 0) { int iNoise = canvasImage.getRGB(u, v); float[] noise = { (iNoise >> 16 & 255) / 255f, (iNoise >> 8 & 255) / 255f, (iNoise & 255) / 255f, (iNoise >> 24 & 255) / 255f }; for (int m = 0; m < 4; m++) rgb[m] = rgb[m] * mod[m] * noise[m]; int[] irgb = { (int) (rgb[0] * 255), (int) (rgb[1] * 255), (int) (rgb[2] * 255), (int) (rgb[3] * 255) }; int i2 = (irgb[0] << 16) + (irgb[1] << 8) + (irgb[2]) + (irgb[3] << 24); scaledImage.setRGB(u, v, i2); } } } catch (Exception e) { e.printStackTrace(); } bufferedimage.getGraphics().drawImage(scaledImage, 0, 0, null); } finally { IOUtils.closeQuietly(iresource1); } ++layer; } } catch (IOException ioexception) { IELogger.error("Couldn't load layered image", ioexception); } finally { IOUtils.closeQuietly(iresource); } return; } TextureUtil.uploadTextureImage(this.getGlTextureId(), bufferedimage); }
From source file:net.sourceforge.pmd.util.fxdesigner.SourceEditorController.java
private IntFunction<javafx.scene.Node> lineNumberFactory() { IntFunction<javafx.scene.Node> base = LineNumberFactory.get(codeEditorArea); Val<Integer> activePar = Val.wrap(codeEditorArea.currentParagraphProperty()); return idx -> { javafx.scene.Node label = base.apply(idx); activePar.conditionOnShowing(label).values().subscribe( p -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("has-caret"), idx == p)); // adds a pseudo class if part of the focus node appears on this line currentFocusNode.conditionOnShowing(label).values() .subscribe(n -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("is-focus-node"), n != null && idx + 1 <= n.getEndLine() && idx + 1 >= n.getBeginLine())); return label; };//from w w w. j ava 2 s .c o m }
From source file:org.briljantframework.array.AbstractArray.java
@Override public IntArray asInt(ToIntFunction<? super T> to, IntFunction<T> from) { return new AsIntArray(getArrayFactory(), getOffset(), getShape(), getStride(), getMajorStrideIndex()) { @Override/*from ww w . j a v a 2 s . c o m*/ protected void setElement(int i, int value) { AbstractArray.this.setElement(i, from.apply(value)); } @Override protected int getElement(int i) { return to.applyAsInt(AbstractArray.this.getElement(i)); } @Override protected int elementSize() { return AbstractArray.this.elementSize(); } }; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public ComplexArray assign(IntArray array, IntFunction<Complex> operator) { array = ShapeUtils.broadcastIfSensible(this, array); Check.size(this, array); for (int i = 0; i < size(); i++) { set(i, operator.apply(array.get(i))); }//from w w w. ja v a 2 s . c o m return this; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public ComplexArray mapToComplex(IntFunction<Complex> function) { ComplexArray matrix = factory.newComplexArray(); for (int i = 0; i < size(); i++) { matrix.set(i, function.apply(get(i))); }/*from w w w. j av a 2 s .co m*/ return matrix; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public <U> Array<U> mapToObj(IntFunction<? extends U> function) { Array<U> array = getArrayFactory().newArray(getShape()); for (int i = 0; i < size(); i++) { array.set(i, function.apply(get(i))); }//from www . j a v a2s. c o m return array; }