/** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
/** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
/** * Creates a double array from the provided {@link DoubleBuffer}. * * @param buffer {@link DoubleBuffer} the data source. * @return double array containing the data of the buffer. */ public static double[] getDoubleArrayFromBuffer(DoubleBuffer buffer) { double[] array = null; if (buffer.hasArray()) { array = buffer.array(); } else { buffer.rewind(); array = new double[buffer.capacity()]; buffer.get(array); } return array; }
public TemporaryGeometryData(long oid, ObjectNode additionalData, int nrPrimitives, long size, double[] mibu, double[] mabu, IntBuffer indices, DoubleBuffer vertices, boolean hasTransparancy, int nrColors) { this.oid = oid; this.additionalData = additionalData; this.nrPrimitives = nrPrimitives; this.size = size; this.mibu = mibu; this.mabu = mabu; this.indices = indices; this.vertices = vertices; this.hasTransparancy = hasTransparancy; this.nrVertices = vertices.capacity(); this.nrColors = nrColors; }
public int getNrVertices() { return vertices.asDoubleBuffer().capacity(); }
public void testGet_io() throws IOException { assertEquals(-1, ArbitraryInstances.get(InputStream.class).read()); assertEquals(-1, ArbitraryInstances.get(ByteArrayInputStream.class).read()); assertEquals(-1, ArbitraryInstances.get(Readable.class).read(CharBuffer.allocate(1))); assertEquals(-1, ArbitraryInstances.get(Reader.class).read()); assertEquals(-1, ArbitraryInstances.get(StringReader.class).read()); assertEquals(0, ArbitraryInstances.get(Buffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(CharBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(ByteBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(ShortBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(IntBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(LongBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(FloatBuffer.class).capacity()); assertEquals(0, ArbitraryInstances.get(DoubleBuffer.class).capacity()); ArbitraryInstances.get(PrintStream.class).println("test"); ArbitraryInstances.get(PrintWriter.class).println("test"); assertNotNull(ArbitraryInstances.get(File.class)); assertFreshInstanceReturned( ByteArrayOutputStream.class, OutputStream.class, Writer.class, StringWriter.class, PrintStream.class, PrintWriter.class); assertEquals(ByteSource.empty(), ArbitraryInstances.get(ByteSource.class)); assertEquals(CharSource.empty(), ArbitraryInstances.get(CharSource.class)); assertNotNull(ArbitraryInstances.get(ByteSink.class)); assertNotNull(ArbitraryInstances.get(CharSink.class)); }
private ByteBuffer quantizeVertices(DoubleBuffer vertices, double[] quantizationMatrix, float multiplierToMm) { ByteBuffer quantizedBuffer = ByteBuffer.wrap(new byte[vertices.capacity() * 2]); quantizedBuffer.order(ByteOrder.LITTLE_ENDIAN); double[] vertex = new double[4]; float[] result = new float[4]; vertex[3] = 1; int nrVertices = vertices.capacity(); for (int i=0; i<nrVertices; i+=3) { vertex[0] = vertices.get(i); vertex[1] = vertices.get(i+1); vertex[2] = vertices.get(i+2); if (multiplierToMm != 1f) { vertex[0] = vertex[0] * multiplierToMm; vertex[1] = vertex[1] * multiplierToMm; vertex[2] = vertex[2] * multiplierToMm; } Matrix.multiplyMV(result, 0, quantizationMatrix, 0, vertex, 0); quantizedBuffer.putShort((short)result[0]); quantizedBuffer.putShort((short)result[1]); quantizedBuffer.putShort((short)result[2]); } return quantizedBuffer; }
@Override public int getNumberOfAssignedValue() { return data.capacity(); }
protected DoubleBufferHandler() { byteBuf.clear(); viewBuf = byteBuf.asDoubleBuffer(); arrayBuf = new double[ viewBuf.capacity() ]; }
/** * @param byteBuffer * @param out * @throws IOException */ private static void writeBuffer( DoubleBuffer buffer, DataOutputStream out ) throws IOException { for ( int i = 0; i < buffer.capacity(); ++i ) { out.writeDouble( buffer.get( i ) ); } }
public static final double[] convertBase64ToArray(String base64Str) { final byte[] decode = Base64.getDecoder().decode(base64Str.getBytes()); final DoubleBuffer doubleBuffer = ByteBuffer.wrap(decode).asDoubleBuffer(); final double[] dims = new double[doubleBuffer.capacity()]; doubleBuffer.get(dims); return dims; }
public static double[] convertToDouble(GenericData.Fixed fixed) { // Convert Fixed (which wraps a byte[]) to a double[] ByteBuffer bytes = ByteBuffer.wrap(fixed.bytes()); // https://stackoverflow.com/questions/3770289/converting-array-of-primitives-to-array-of-containers-in-java // TODO use ArrayUtils? DoubleBuffer asDoubleBuffer = bytes.asDoubleBuffer(); double[] array = new double[asDoubleBuffer.capacity()]; asDoubleBuffer.get(array); return array; }
/** * Write a buffer of double values of the specified length to the pointed memory location shifted by a byte offset */ public Pointer<T> setDoublesAtOffset(long byteOffset, DoubleBuffer values) { return setDoublesAtOffset(byteOffset, values, 0, values.capacity()); }
/** * Write a buffer of double values of the specified length to the pointed memory location */ public Pointer<T> setDoubles(DoubleBuffer values) { return setDoublesAtOffset(0, values, 0, values.capacity()); }
public static double[] convertToDouble(GenericData.Fixed fixed) { // Convert Fixed (which wraps a byte[]) to a double[] ByteBuffer bytes = ByteBuffer.wrap(fixed.bytes()); // https://stackoverflow.com/questions/3770289/converting-array-of-primitives-to-array-of-containers-in-java // TODO use ArrayUtils? DoubleBuffer asDoubleBuffer = bytes.asDoubleBuffer(); double[] array = new double[asDoubleBuffer.capacity()]; asDoubleBuffer.get(array); return array; }
ByteBuffer vertices = geometry.getVertices(); DoubleBuffer verticesAsDouble = vertices.order(ByteOrder.LITTLE_ENDIAN).asDoubleBuffer(); geometryData.set("nrVertices", verticesAsDouble.capacity()); geometryData.setAttribute(GeometryPackage.eINSTANCE.getGeometryData_Vertices(), createBuffer(queryContext, vertices)); ByteBuffer normals = geometry.getNormals(); FloatBuffer materialsAsFloat = geometry.getMaterials().order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer(); boolean hasMaterial = false; colors = ByteBuffer.allocate((verticesAsDouble.capacity() / 3) * 4); double[] triangle = new double[9]; for (int i = 0; i < materialIndices.capacity(); ++i) { geometryInfo.setAttribute(GeometryPackage.eINSTANCE.getGeometryInfo_NrVertices(), verticesAsDouble.capacity()); geometryInfo.setReference(GeometryPackage.eINSTANCE.getGeometryInfo_Data(), geometryData.getOid(), 0); geometryInfo.setAttribute(GeometryPackage.eINSTANCE.getGeometryInfo_HasTransparency(), hasTransparency);
@Override public BufferMatrix exactClone() { int ec=buffer.capacity(); double[] newArray=new double[ec]; buffer.get(newArray); buffer.clear(); return BufferMatrix.wrap(newArray,rows,cols); }
@Override public BufferMatrix exactClone() { int ec=buffer.capacity(); double[] newArray=new double[ec]; buffer.get(newArray); buffer.clear(); return BufferMatrix.wrap(newArray,rows,cols); }
private void ensureCapacity() { int size = (int) Math.round((throughputProvider.getThroughput() * durationProvider.getDuration() + 1) * 3); if (events != null && events.capacity() >= size) { return; } events = DoubleBuffer.allocate(size); }