当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuffer.asDoubleBuffer方法代码示例

本文整理汇总了Java中java.nio.ByteBuffer.asDoubleBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuffer.asDoubleBuffer方法的具体用法?Java ByteBuffer.asDoubleBuffer怎么用?Java ByteBuffer.asDoubleBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.asDoubleBuffer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTransformationMatrix

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private void setTransformationMatrix(VirtualObject geometryInfo, double[] transformationMatrix)
		throws DatabaseException {
	ByteBuffer byteBuffer = ByteBuffer.allocate(16 * 8);
	byteBuffer.order(ByteOrder.nativeOrder());
	DoubleBuffer asDoubleBuffer = byteBuffer.asDoubleBuffer();
	for (double d : transformationMatrix) {
		asDoubleBuffer.put(d);
	}
	geometryInfo.setAttribute(GeometryPackage.eINSTANCE.getGeometryInfo_Transformation(), byteBuffer.array());
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:11,代码来源:StreamingGeometryGenerator.java

示例2: printMatrix

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private void printMatrix(PrintWriter out, GeometryInfo geometryInfo) {
	ByteBuffer transformation = ByteBuffer.wrap(geometryInfo.getTransformation());
	transformation.order(ByteOrder.LITTLE_ENDIAN);
	DoubleBuffer doubleBuffer = transformation.asDoubleBuffer();
	// Prepare to create the transform matrix.
	double[] matrix = new double[16];
	// Add the first 16 values of the buffer.
	for (int i = 0; i < matrix.length; i++)
		matrix[i] = doubleBuffer.get();
	// Switch from column-major (x.x ... x.y ... x.z ... 0 ...) to row-major orientation (x.x x.y x.z 0 ...)?
	matrix = Matrix.changeOrientation(matrix);
	// List all 16 elements of the matrix as a single space-delimited String object.
	out.println("    <matrix>" + doubleArrayToSpaceDelimitedString(matrix) + "</matrix>");
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:15,代码来源:ColladaSerializer.java

示例3: setTransformationMatrix

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private void setTransformationMatrix(GeometryInfo geometryInfo, double[] transformationMatrix) {
	ByteBuffer byteBuffer = ByteBuffer.allocate(16 * 8);
	byteBuffer.order(ByteOrder.nativeOrder());
	DoubleBuffer asDoubleBuffer = byteBuffer.asDoubleBuffer();
	for (double f : transformationMatrix) {
		asDoubleBuffer.put(f);
	}
	geometryInfo.setTransformation(byteBuffer.array());
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:10,代码来源:GeometryGenerator.java

示例4: doubleToByteArray

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static byte[] doubleToByteArray(Double inDouble) {
	byte[] bArray = new byte[8];
	ByteBuffer bBuffer = ByteBuffer.wrap(bArray);
	DoubleBuffer lBuffer = bBuffer.asDoubleBuffer();
	lBuffer.put(inDouble);
	return bArray;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:8,代码来源:BinUtils.java

示例5: bufferToDoubleArray

import java.nio.ByteBuffer; //导入方法依赖的package包/类
private static double[] bufferToDoubleArray(ByteBuffer buffer) {
	buffer.order(ByteOrder.nativeOrder());
	DoubleBuffer doubles = buffer.asDoubleBuffer();

	if (doubles.hasArray()) {
		return doubles.array();
	} else {
		double[] resultArray = new double[doubles.capacity()];
		doubles.get(resultArray);
		return resultArray;
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:13,代码来源:ThriftBmiBridge.java

示例6: asDoubleBuffer

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static DoubleBuffer asDoubleBuffer(ByteBuffer buf) {
    DoubleBuffer buffer = buf.asDoubleBuffer();
    Buffer viewedBuffer = bufferViews.get(buf);
    if (viewedBuffer != null) {
        bufferViews.put(buffer, viewedBuffer);
    } else {
        bufferViews.put(buffer, buf);
    }
    return buffer;
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:RT.java

示例7: testGetDouble

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Test
public void testGetDouble() {
  ByteBuffer bb = ByteBuffer.allocate(40);
  DoubleBuffer db = bb.asDoubleBuffer();
  db.put(1.1d);
  db.put(2.2d);
  db.put(3.3d);
  db.put(4.4d);
  db.put(5.5d);
  byte[] bytes = bb.array();
  ByteSource bs = createByteSource(bytes);
  double d = bs.getDouble();
  assertEquals(1.1d, d, 0.0001);
  assertEquals(8, bs.position());
  d = bs.getDouble();
  assertEquals(2.2d, d, 0.0001);
  assertEquals(16, bs.position());
  bs.position(4 * 8);
  d = bs.getDouble();
  assertEquals(5.5d, d, 0.0001);
  assertEquals(40, bs.position());
  try {
    bs.getDouble();
    fail("expected BufferUnderflowException");
  } catch (BufferUnderflowException expected) {
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:28,代码来源:ByteSourceJUnitTest.java

示例8: testGetDoubleInt

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Test
public void testGetDoubleInt() {
  ByteBuffer bb = ByteBuffer.allocate(40);
  DoubleBuffer db = bb.asDoubleBuffer();
  db.put(1.1d);
  db.put(2.2d);
  db.put(3.3d);
  db.put(4.4d);
  db.put(5.5d);
  byte[] bytes = bb.array();
  ByteSource bs = createByteSource(bytes);
  bs.position(3);
  double d = bs.getDouble(0);
  assertEquals(1.1d, d, 0.0001);
  assertEquals(3, bs.position());
  d = bs.getDouble(8);
  assertEquals(2.2d, d, 0.0001);
  assertEquals(3, bs.position());
  d = bs.getDouble(4 * 8);
  assertEquals(5.5d, d, 0.0001);
  assertEquals(3, bs.position());
  try {
    bs.getDouble((4 * 8) + 1);
    fail("expected IndexOutOfBoundsException");
  } catch (IndexOutOfBoundsException expected) {
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:28,代码来源:ByteSourceJUnitTest.java

示例9: asView

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Buffer asView(ByteBuffer b, PrimitiveType t) {
    switch (t) {
        case BYTE: return b;
        case CHAR: return b.asCharBuffer();
        case SHORT: return b.asShortBuffer();
        case INT: return b.asIntBuffer();
        case LONG: return b.asLongBuffer();
        case FLOAT: return b.asFloatBuffer();
        case DOUBLE: return b.asDoubleBuffer();
    }
    throw new InternalError("Should not reach here");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ByteBufferTest.java

示例10: createNativeDoubleBuffer

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static DoubleBuffer createNativeDoubleBuffer(int numberOfElements) {
    ByteBuffer res = ByteBuffer.allocateDirect(numberOfElements * 8);
    res.order(ByteOrder.nativeOrder());
    return res.asDoubleBuffer();
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:6,代码来源:WflowPythonToJavaAdapter.java

示例11: createArrayData

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public Float64ArrayData createArrayData(final ByteBuffer nb, final int start, final int length) {
    return new Float64ArrayData(nb.asDoubleBuffer(), start, length);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:NativeFloat64Array.java


注:本文中的java.nio.ByteBuffer.asDoubleBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。