Exemplo n.º 1
0
 private static void getGlobalClientRect(long hwnd, Rect rect) {
   rect_buffer.put(0, 0).put(1, 0);
   clientToScreen(hwnd, rect_buffer);
   int offset_x = rect_buffer.get(0);
   int offset_y = rect_buffer.get(1);
   getClientRect(hwnd, rect_buffer);
   rect.copyFromBuffer(rect_buffer);
   rect.offset(offset_x, offset_y);
 }
  private void readPalette() {
    RandomAccessFile rIn = null;
    ByteBuffer buf = null;
    int i;
    try {
      if (paletteFile != null) {
        // see if the file exists, if not, set it to the default palette.
        File file = new File(paletteFile);

        numPaletteEntries = (int) (file.length() / 4);

        buf = ByteBuffer.allocate(numPaletteEntries * 4);

        rIn = new RandomAccessFile(paletteFile, "r");

        FileChannel inChannel = rIn.getChannel();

        inChannel.position(0);
        inChannel.read(buf);

        // Check the byte order.
        buf.order(ByteOrder.LITTLE_ENDIAN);

        buf.rewind();
        IntBuffer ib = buf.asIntBuffer();
        paletteData = new int[numPaletteEntries];
        ib.get(paletteData);
        ib = null;
      }

    } catch (Exception e) {
      System.err.println("Caught exception: " + e.toString());
      System.err.println(e.getStackTrace());
    } finally {
      if (rIn != null) {
        try {
          rIn.close();
        } catch (Exception e) {
        }
      }
    }
  }
Exemplo n.º 3
0
 static Object doCreateCursor(
     int width,
     int height,
     int xHotspot,
     int yHotspot,
     int numImages,
     IntBuffer images,
     IntBuffer delays)
     throws LWJGLException {
   return nCreateCursor(
       width,
       height,
       xHotspot,
       yHotspot,
       numImages,
       images,
       images.position(),
       delays,
       delays != null ? delays.position() : -1);
 }
Exemplo n.º 4
0
 public void copyFromBuffer(IntBuffer buffer) {
   top = buffer.get(0);
   bottom = buffer.get(1);
   left = buffer.get(2);
   right = buffer.get(3);
 }
Exemplo n.º 5
0
 public void copyToBuffer(IntBuffer buffer) {
   buffer.put(0, top).put(1, bottom).put(2, left).put(3, right);
 }