Package java.nio

Examples of java.nio.IntBuffer


        //Limits
        refreshLimits();

        //Switch to OpenGL select mode
        int capacity = 1 * 4 * leaves.getCount();      //Each object take in maximium : 4 * name stack depth
        IntBuffer hitsBuffer = BufferUtil.newIntBuffer(capacity);
        gl.glSelectBuffer(hitsBuffer.capacity(), hitsBuffer);
        gl.glRenderMode(GL.GL_SELECT);
        gl.glInitNames();
        gl.glPushName(0);
        gl.glDisable(GL.GL_CULL_FACE);      //Disable flags
        //Draw the nodes cube in the select buffer
        for (Octant n : leaves) {
            n.resetUpdatePositionFlag();        //Profit from the loop to do this, because this method is always after updating position
            gl.glLoadName(n.getNumber());
            n.displayOctant(gl);
        }
        int nbRecords = gl.glRenderMode(GL.GL_RENDER);
        if (vizController.getVizModel().isCulling()) {
            gl.glEnable(GL.GL_CULL_FACE);
            gl.glCullFace(GL.GL_BACK);
        }
        visibleLeaves.clear();

        //Get the hits and add the nodes' objects to the array
        int depth = Integer.MAX_VALUE;
        int minDepth = -1;
        for (int i = 0; i < nbRecords; i++) {
            int hit = hitsBuffer.get(i * 4 + 3);     //-1 Because of the glPushName(0)
            int minZ = hitsBuffer.get(i * 4 + 1);
            if (minZ < depth) {
                depth = minZ;
                minDepth = hit;
            }

View Full Code Here


                    if (center != null) {
                        mousePosition[0] += center[0];
                        mousePosition[1] += center[1];
                    }
                    int capacity = 1 * 4 * objectCount;      //Each object take in maximium : 4 * name stack depth
                    IntBuffer hitsBuffer = BufferUtil.newIntBuffer(capacity);

                    gl.glSelectBuffer(hitsBuffer.capacity(), hitsBuffer);
                    gl.glRenderMode(GL.GL_SELECT);

                    gl.glInitNames();
                    gl.glPushName(0);

                    gl.glMatrixMode(GL.GL_PROJECTION);
                    gl.glPushMatrix();
                    gl.glLoadIdentity();

                    glu.gluPickMatrix(mousePosition[0], mousePosition[1], pickRectangle[0], pickRectangle[1], graphDrawable.getViewport());
                    gl.glMultMatrixd(graphDrawable.getProjectionMatrix());

                    gl.glMatrixMode(GL.GL_MODELVIEW);

                    int hitName = 1;
                    ModelImpl[] array = new ModelImpl[objectCount];
                    for (Iterator<ModelImpl> itr = octree.getSelectedObjectIterator(modelClass.getClassId()); itr.hasNext();) {
                        ModelImpl obj = itr.next();
                        obj.setAutoSelect(false);

                        array[hitName - 1] = obj;
                        gl.glLoadName(hitName);
                        obj.display(gl, glu, vizModel);
                        hitName++;

                    }

                    //Restoring the original projection matrix
                    gl.glMatrixMode(GL.GL_PROJECTION);
                    gl.glPopMatrix();
                    gl.glMatrixMode(GL.GL_MODELVIEW);
                    gl.glFlush();

                    //Returning to normal rendering mode
                    int nbRecords = gl.glRenderMode(GL.GL_RENDER);

                    //Get the hits and put the node under selection in the selectionArray
                    for (int j = 0; j < nbRecords; j++) {
                        int hit = hitsBuffer.get(j * 4 + 3) - 1;     //-1 Because of the glPushName(0)
                        ModelImpl obj = array[hit];
                        obj.setAutoSelect(true);
                    }
                }
            }
View Full Code Here

                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (short)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_32S: {
                IntBuffer sb = src.getByteBuffer().asIntBuffer();
                IntBuffer db = dst.getByteBuffer().asIntBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (int)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_64F: {
                DoubleBuffer sb = src.getByteBuffer().asDoubleBuffer();
                DoubleBuffer db = dst.getByteBuffer().asDoubleBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            default: assert(false);
        }
View Full Code Here

        ByteBuffer buf = null;
        Type type = fs.getType();
        if (type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
          IntBuffer intbuf = buf.asIntBuffer();
          intbuf.put(this.getHeap().heap, arrayStart, arraySize);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
 
View Full Code Here

        // We replace the removed part with a #, so we need to remove 1 extra char
        bytesToRemove++;

        int[] codePoints;
        try {
            IntBuffer intBuffer = ByteBuffer.wrap(pathComponent.getBytes("UTF-32BE")).asIntBuffer();
            codePoints = new int[intBuffer.limit()];
            intBuffer.get(codePoints);
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }

        int midPoint = codePoints.length/2;
View Full Code Here

    assert stream instanceof ByteArrayOutputStream;
    return ((ByteArrayOutputStream) stream).toByteArray();
  }

  public final int[] toIntArray() {
    IntBuffer source = ByteBuffer.wrap(toByteArray()).asIntBuffer();
    return IntBuffer.allocate(source.limit()).put(source).array();
  }
View Full Code Here

      0x0000,            0x8000,            0x0001,            0x0000,
      0x0000,            0xfffe,            0x8000,            0x0000,
      0x0000,            0x0001,            0xfffe,            0x0000
    };
    ByteBuffer bytesWrapped = byteFormat.wrapBytes(bytes);
    IntBuffer intsWrapped = IntBuffer.wrap(ints);
    float U = Math.scalb(1.0f, -15);
    float[][] values = {
      /* channel 0 */ { 0.0f,     U * 0.5f,    1.0f - U,    -1.0f + U },
      /* channel 1 */ { 0.0f,    -1.0f + U,    U * 0.5f,     1.0f - U },
    };
View Full Code Here

      /* channel 1 */ 0x8000,            0xfffe,              0x0001,
      /* channel 2 */ 0x0001,            0x8000,              0xfffe,
      /* channel 3 */ 0x0000,            0x0000,              0x0000,
    };
    ByteBuffer bytesWrapped = byteFormat.wrapBytes(bytes);
    IntBuffer intsWrapped = IntBuffer.wrap(ints);
    float U = Math.scalb(1.0f, -15);
    float[][] values = {
      /* channel 1 */ { 0.0f,    -1.0f + 0,    -U * 1.5f,      U * 1.5f },
      /* channel 2 */ { 0.0f,     U * 1.5f,    -1.0f + 0,     -U * 1.5f },
    };
View Full Code Here

   * Increases the capacity of the <tt>IntBuffer</tt> instance, if
   * necessary, to ensure that it can hold at least the number of elements.
   */
  private void ensureIntBufferCapacity(final int target) {
    if (node.capacity() < target) {
      final IntBuffer buffer = IntBuffer.allocate(target);
      node.flip();
      buffer.put(node);
      node = buffer;
    }
  }
View Full Code Here

        }
        buf.put((char) c);
    }

    private void addSeparator() {
        IntBuffer buf = cellBeginPositions;
        if (buf.remaining() == 0) {
            IntBuffer newBuf = IntBuffer.allocate(buf.capacity() * 2);
            newBuf.clear();
            buf.flip();
            newBuf.put(buf);
            buf = newBuf;
            cellBeginPositions = newBuf;
        }
        buf.put(lineBuffer.position());
    }
View Full Code Here

TOP

Related Classes of java.nio.IntBuffer

Copyright © 2018 www.massapicom. 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.