當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。