Package java.nio

Examples of java.nio.FloatBuffer.position()


        for (int i = 0; i < 16; i++) {
            BufferUtils.setInBuffer(color, colors, i);
        }
        final float alpha = drawOriginConnector ? 0.4f : 0.0f;
        for (int i = 16; i < 24; i++) {
            colors.position(i * 4);
            colors.put(color.getRed());
            colors.put(color.getGreen());
            colors.put(color.getBlue());
            colors.put(alpha);
        }
View Full Code Here


    }

    @Test
    public void testAddAllNoBackingArray0() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 10).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf());
        assertEquals(8, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray0() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 10).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf());
        assertEquals(8, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray1() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf((float) 5));
        assertEquals(9, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray2() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf((float) 5, (float) 5));
        assertEquals(10, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray3() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        try {
            notBackedByArray.addAll(FloatArray.unsafeValueOf((float) 5, (float) 5, (float) 5));
            fail();
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray1() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf(5));
        assertEquals(9, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4, 5}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray2() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        notBackedByArray.addAll(FloatArray.unsafeValueOf(5, 5));
        assertEquals(10, notBackedByArray.length());
        assertArrayEquals(new float[]{1, 1, 2, 1, 2, 3, 3, 4, 5, 5}, notBackedByArray.toArray(), 0);
View Full Code Here

    }

    @Test
    public void testAddAllNoBackingArray3() throws Exception {
        FloatBuffer buffer = ByteBuffer.allocateDirect(Float.SIZE / Byte.SIZE * 11).asFloatBuffer();
        buffer.position(1).limit(9);
        BoundedFloatArray notBackedByArray = BoundedFloatArray.valueOf(buffer);
        notBackedByArray.setAll(array);
        try {
            notBackedByArray.addAll(FloatArray.unsafeValueOf(5, 5, 5));
            fail();
View Full Code Here

        }
        int newOffset = elements.position() + offset;
        int newLength = elements.remaining() - offset;
        subArrayCheck(newOffset, newLength);
        FloatBuffer copy = elements.duplicate();
        copy.position(newOffset);
        return new SubMutableFloatBufferArrayImpl(this, copy);
    }

    /**
     * <p>Returns a new sub array object for the specified {@code length}. Note that {@code length} must be smaller than
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.