當前位置: 首頁>>代碼示例>>Java>>正文


Java FloatBuffer.allocate方法代碼示例

本文整理匯總了Java中java.nio.FloatBuffer.allocate方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatBuffer.allocate方法的具體用法?Java FloatBuffer.allocate怎麽用?Java FloatBuffer.allocate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.FloatBuffer的用法示例。


在下文中一共展示了FloatBuffer.allocate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: JSBufferedSampleRecorder

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Constructs a JSBufferedSampleRecorder that expects audio in the given AudioFormat and 
 * which will save to a file with given name.
 * 
 * @param format the AudioFormat you want to record in
 * @param name the name of the file to save to (not including the extension)
 */
JSBufferedSampleRecorder(JSMinim sys,
                         String fileName, 
                         AudioFileFormat.Type fileType, 
                         AudioFormat fileFormat,
                         int bufferSize)
{
  name = fileName;
  type = fileType;
  format = fileFormat;
  buffers = new ArrayList<FloatBuffer>(20);
  left = FloatBuffer.allocate(bufferSize*10);
  if ( format.getChannels() == Minim.STEREO )
  {
    right = FloatBuffer.allocate(bufferSize*10);
  }
  else
  {
    right = null;
  }
  system = sys;
}
 
開發者ID:JacobRoth,項目名稱:romanov,代碼行數:29,代碼來源:JSBufferedSampleRecorder.java

示例2: clone

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Creates a new FloatBuffer with the same contents as the given
 * FloatBuffer. The new FloatBuffer is seperate from the old one and changes
 * are not reflected across. If you want to reflect changes, consider using
 * Buffer.duplicate().
 * 
 * @param buf
 *            the FloatBuffer to copy
 * @return the copy
 */
public static FloatBuffer clone(FloatBuffer buf) {
    if (buf == null) {
        return null;
    }
    buf.rewind();

    FloatBuffer copy;
    if (isDirect(buf)) {
        copy = createFloatBuffer(buf.limit());
    } else {
        copy = FloatBuffer.allocate(buf.limit());
    }
    copy.put(buf);

    return copy;
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:27,代碼來源:BufferUtils.java

示例3: toFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public FloatBuffer toFloatBuffer()
{
    FloatBuffer rValue = FloatBuffer.allocate(16);
    rValue.put( 0, m00);
    rValue.put( 1, m01);
    rValue.put( 2, m02);
    rValue.put( 3, m03);
    rValue.put( 4, m10);
    rValue.put( 5, m11);
    rValue.put( 6, m12);
    rValue.put( 7, m13);
    rValue.put( 8, m20);
    rValue.put( 9, m21);
    rValue.put(10, m22);
    rValue.put(11, m23);
    rValue.put(12, m30);
    rValue.put(13, m31);
    rValue.put(14, m32);
    rValue.put(15, m33);
    return rValue;
    
}
 
開發者ID:jfcameron,項目名稱:G2Dj,代碼行數:23,代碼來源:Mat4x4.java

示例4: resetPixmapGrayLevel

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Sets full pixmap to some gray level. An internal buffer is created if
 * needed so that gray level can be set back quickly using System.arraycopy.
 *
 * @param value the gray level.
 */
private void resetPixmapGrayLevel(float value) {
    checkPixmapAllocation();
    final int n = 3 * sizeX * sizeY;
    boolean madebuffer = false;
    if ((grayBuffer == null) || (grayBuffer.capacity() != n)) {
        grayBuffer = FloatBuffer.allocate(n); // Buffers.newDirectFloatBuffer(n);
        madebuffer = true;
    }
    if (madebuffer || (value != grayValue)) {
        grayBuffer.rewind();
        for (int i = 0; i < n; i++) {
            grayBuffer.put(value);
        }
        grayBuffer.rewind();
    }
    System.arraycopy(grayBuffer.array(), 0, pixmap.array(), 0, n);
    pixmap.rewind();
    pixmap.limit(n);
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:26,代碼來源:ImageDisplay.java

示例5: resetPixmapGrayLevel

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
     * Resets the pixmap values to a gray level
     *
     * @param value 0-1 gray value.
     */
    protected void resetPixmapGrayLevel(float value) {
        checkPixmapAllocation();
        if (chip.getNumPixels() == 0) {
            log.warning("chip has zero pixels; is the constuctor of Chip2DRenderer called before size of the AEChip is set?");
            return;
        }
        final int n = 3 * chip.getNumPixels();
        boolean madebuffer = false;
        if ((grayBuffer == null) || (grayBuffer.capacity() != n)) {
            grayBuffer = FloatBuffer.allocate(n); // Buffers.newDirectFloatBuffer(n);
            madebuffer = true;
        }
        if (madebuffer || (value != grayValue)) {
            grayBuffer.rewind();
            for (int i = 0; i < n; i++) {
                grayBuffer.put(value);
            }
            grayBuffer.rewind();
        }
        System.arraycopy(grayBuffer.array(), 0, pixmap.array(), 0, n);
        pixmap.rewind();
        pixmap.limit(n);
//        pixmapGrayValue = grayValue;
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:30,代碼來源:Chip2DRenderer.java

示例6: checkPixmapAllocation

import java.nio.FloatBuffer; //導入方法依賴的package包/類
@Override
    protected void checkPixmapAllocation() {
        
        if ((sizeX != chip.getSizeX()) || (sizeY != chip.getSizeY())) {
            sizeX = chip.getSizeX();
            sizeY = chip.getSizeY();            
        }
        
        textureWidth = AEFrameChipRenderer.ceilingPow2(sizeX);
        textureHeight = AEFrameChipRenderer.ceilingPow2(sizeY);
//        System.out.println(textureWidth);
//        System.out.println(textureHeight);
        final int n = 4 * textureWidth * textureHeight;
//        System.out.println(n);
        if ((pixmap == null) || (pixmap.capacity() < n) || (pixBuffer.capacity() < n) || (onMap.capacity() < n) || (offMap.capacity() < n)
                || (annotateMap.capacity() < n)) {
            pixmap = FloatBuffer.allocate(n); // BufferUtil.newFloatBuffer(n);
            pixBuffer = FloatBuffer.allocate(n);
            onMap = FloatBuffer.allocate(n);
            offMap = FloatBuffer.allocate(n);
            annotateMap = FloatBuffer.allocate(n);
        }
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:24,代碼來源:MultiViewerFromMultiCamera.java

示例7: asFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public FloatBuffer asFloatBuffer()
{
	FloatBuffer buffer = FloatBuffer.allocate(4 * 4);

	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			buffer.put(data[i][j]);

	buffer.flip();
	return buffer;
}
 
開發者ID:timtomtim7,項目名稱:SparseBukkitAPI,代碼行數:12,代碼來源:Matrix4f.java

示例8: asFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public FloatBuffer asFloatBuffer()
	{
//		FloatBuffer buffer = BufferUtils.createFloatBuffer(4 * 4);
		FloatBuffer buffer = FloatBuffer.allocate(4*4);

		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				buffer.put(data[i][j]);

		buffer.flip();
		return buffer;
	}
 
開發者ID:timtomtim7,項目名稱:SparseBukkitAPI,代碼行數:13,代碼來源:Matrix4f.java

示例9: samples

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void samples(float[] samp)
{
  if ( recording )
  {
    left.put(samp);
    if ( !left.hasRemaining() )
    {
      buffers.add(left);
      left = FloatBuffer.allocate(left.capacity());
    }
  }
}
 
開發者ID:JacobRoth,項目名稱:romanov,代碼行數:13,代碼來源:JSBufferedSampleRecorder.java

示例10: getWorldCoorFromMouse

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public double[] getWorldCoorFromMouse(int mouseX, int mouseY){
	// get mouse coordinates and project them onto the 3D space
	int[] viewport = new int[4];
	//double[] modelview = new double[16];
	double[] projection = new double[16];
	float winX, winY;
	FloatBuffer winZ = FloatBuffer.allocate(4);
	double wcoord[] = new double[4];// wx, wy, wz;// returned xyz coords

	//gl.glGetDoublev( GL.GL_MODELVIEW_MATRIX, modelview, 0 );
	gl.glGetDoublev( GL.GL_PROJECTION_MATRIX, projection, 0 );
	gl.glGetIntegerv( GL.GL_VIEWPORT, viewport, 0 );

	//TODO: more precision in XYZ lookup by using doubles instead of floats?

	winX = (float)mouseX;
	winY = (float)viewport[3] - (float)mouseY;		

	gl.glReadPixels( mouseX, (int)winY, 1, 1, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, winZ );
	glu.gluUnProject((double)winX, (double)winY, (double)(winZ.get()), mouseModelview, 0, projection, 0, viewport, 0, wcoord, 0);

	//System.out.println("World coords: (" + wcoord[0] + ", " + wcoord[1] + ", " + wcoord[2] + ")");

	//
	// Map coord's to snap if snap is enabled
	//
	if(AvoGlobal.snapEnabled && AvoGlobal.menuet.getCurrentToolMode() == Menuet.MENUET_MODE_SKETCH){
		wcoord[0] = Math.floor((wcoord[0]+AvoGlobal.snapSize/2.0)/AvoGlobal.snapSize)*AvoGlobal.snapSize;
		wcoord[1] = Math.floor((wcoord[1]+AvoGlobal.snapSize/2.0)/AvoGlobal.snapSize)*AvoGlobal.snapSize;
		wcoord[2] = Math.floor((wcoord[2]+AvoGlobal.snapSize/2.0)/AvoGlobal.snapSize)*AvoGlobal.snapSize;
	}

	if(AvoGlobal.menuet.getCurrentToolMode() == Menuet.MENUET_MODE_SKETCH && wcoord[2] < 0.25 && wcoord[2] > -0.25){
		wcoord[2] = 0.0; // tie z-value to zero if close enough to located on the drawing plane.
	}

	AvoGlobal.glCursor3DPos = wcoord;
	AvoGlobal.glViewEventHandler.notifyCursorMoved();
	return wcoord;
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:41,代碼來源:GLView.java

示例11: resetPixmapGrayLevel

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/** Overridden to make gray buffer special for bDVS array */
        @Override
        protected void resetPixmapGrayLevel(float value) {
            checkPixmapAllocation();
            final int n = 2 * chip.getNumPixels();
            boolean madebuffer = false;
            if ((grayBuffer == null) || (grayBuffer.capacity() != n)) {
                grayBuffer = FloatBuffer.allocate(n); // BufferUtil.newFloatBuffer(n);
                madebuffer = true;
            }
            if (madebuffer || (value != grayValue)) {
                grayBuffer.rewind();
                for (int y = 0; y < sizeY; y++) {
                    for (int x = 0; x < sizeX; x++) {
//                        if(displayLogIntensityChangeEvents){
//                            grayBuffer.put(0);
//                            grayBuffer.put(0);
//                            grayBuffer.put(0);
//                        } else {
                            grayBuffer.put(grayValue);
                            grayBuffer.put(grayValue);
//                            grayBuffer.put(grayValue);
//                        }
                    }
                }
                grayBuffer.rewind();
            }
            System.arraycopy(grayBuffer.array(), 0, pixmap.array(), 0, n);
            pixmap.rewind();
            pixmap.limit(n);
//        pixmapGrayValue = grayValue;
        }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:33,代碼來源:NBFG256.java

示例12: checkPixmapAllocation

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/** Subclasses should call checkPixmapAllocation to
 * make sure the pixmap FloatBuffer is allocated before accessing it.
 *
 */
public void checkPixmapAllocation() {
	final int n = 3 * sizeX * sizeY;
	if ((pixmap == null) || (pixmap.capacity() != n)) {
		pixmap = FloatBuffer.allocate(n); // Buffers.newDirectFloatBuffer(n);
	}
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:11,代碼來源:ImageDisplay.java

示例13: checkPixmapAllocation

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Subclasses should call checkPixmapAllocation to make sure the pixmap
 * FloatBuffer is allocated before accessing it.
 *
 */
protected void checkPixmapAllocation() {
    final int n = 3 * chip.getNumPixels();
    if ((pixmap == null) || (pixmap.capacity() < n)) {
        pixmap = FloatBuffer.allocate(n); // Buffers.newDirectFloatBuffer(n);
    }
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:12,代碼來源:Chip2DRenderer.java

示例14: generateFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
@Generates private FloatBuffer generateFloatBuffer() {
  return FloatBuffer.allocate(generateInt());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:4,代碼來源:FreshValueGenerator.java

示例15: testTensorToImgDirect

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/** Tests the img<Type>Direct(Tensor) functions */
@Test
public void testTensorToImgDirect() {
	final long[] shape = new long[] { 20, 10, 3 };
	final int[] mapping = new int[] { 0, 1, 2 };
	final int n = shape.length;
	final int size = 600;

	// Get some points to mark
	List<Point> points = createTestPoints(n);

	// Create Tensors of different type and convert them to images
	ByteBuffer dataByte = ByteBuffer.allocateDirect(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataByte.put(i, (byte) (int) v));
	Tensor tensorByte = Tensor.create(DataType.UINT8, shape, dataByte);
	Img<ByteType> imgByte = Tensors.imgByteDirect(tensorByte);

	DoubleBuffer dataDouble = DoubleBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataDouble.put(i, v));
	Tensor tensorDouble = Tensor.create(shape, dataDouble);
	Img<DoubleType> imgDouble = Tensors.imgDoubleDirect(tensorDouble);

	FloatBuffer dataFloat = FloatBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataFloat.put(i, v));
	Tensor tensorFloat = Tensor.create(shape, dataFloat);
	Img<FloatType> imgFloat = Tensors.imgFloatDirect(tensorFloat);

	IntBuffer dataInt = IntBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataInt.put(i, v));
	Tensor tensorInt = Tensor.create(shape, dataInt);
	Img<IntType> imgInt = Tensors.imgIntDirect(tensorInt);

	LongBuffer dataLong = LongBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataLong.put(i, v));
	Tensor tensorLong = Tensor.create(shape, dataLong);
	Img<LongType> imgLong = Tensors.imgLongDirect(tensorLong);

	// Check all created images
	checkImage(imgByte, n, shape, points);
	checkImage(imgDouble, n, shape, points);
	checkImage(imgFloat, n, shape, points);
	checkImage(imgInt, n, shape, points);
	checkImage(imgLong, n, shape, points);
}
 
開發者ID:imagej,項目名稱:imagej-tensorflow,代碼行數:45,代碼來源:TensorsTest.java


注:本文中的java.nio.FloatBuffer.allocate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。