org.jrabbit.base.graphics.misc
Class CursorLoader

java.lang.Object
  extended by org.jrabbit.base.graphics.misc.CursorLoader

public class CursorLoader
extends java.lang.Object

Convenience class for creating cursors from images. At the moment, this only supports loading static cursors. Additionally, cursors are limited to particular hardware, and many machines only support single-bit alpha. Keep this in mind when creating your cursors.

Author:
Chris Molini

Constructor Summary
CursorLoader()
           
 
Method Summary
private static java.awt.Point adjustHotspot(java.awt.Point point, int width, int height)
          Because of some complexities with Cursors, a hotspot must be adjusted to be contained within and flipped to the indicated dimension.
private static java.nio.IntBuffer cursorImage(org.newdawn.slick.opengl.Texture texture, int width, int height)
          Loads the cursor data into an IntBuffer from the supplied texture.
static org.lwjgl.input.Cursor load(Loader loader, java.awt.Point hotspot)
          Loads a cursor from the indicated loader.
static org.lwjgl.input.Cursor load(java.lang.String filepath)
          Loads a cursor from the indicated filepath with the hotspot at the top left corner of the image.
static org.lwjgl.input.Cursor load(java.lang.String filepath, java.awt.Point hotspot)
          Loads a cursor from the indicated filepath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CursorLoader

public CursorLoader()
Method Detail

load

public static org.lwjgl.input.Cursor load(java.lang.String filepath)
Loads a cursor from the indicated filepath with the hotspot at the top left corner of the image.

Parameters:
filepath - The location of the desired source image.
Returns:
A cursor created from the indicated image.

load

public static org.lwjgl.input.Cursor load(java.lang.String filepath,
                                          java.awt.Point hotspot)
Loads a cursor from the indicated filepath.

Parameters:
filepath - The location of the source image.
hotspot - The point on the cursor that will be the "point" of the mouse.
Returns:
A Cursor created from the indicated data.

load

public static org.lwjgl.input.Cursor load(Loader loader,
                                          java.awt.Point hotspot)
Loads a cursor from the indicated loader.

Parameters:
filepath - A loader pointing to the desired image.
hotspot - The point on the cursor that will be the "point" of the mouse.
Returns:
A Cursor created from the indicated data.

adjustHotspot

private static java.awt.Point adjustHotspot(java.awt.Point point,
                                            int width,
                                            int height)
Because of some complexities with Cursors, a hotspot must be adjusted to be contained within and flipped to the indicated dimension.

Parameters:
point - The initial hotspot position.
width - The width of the cursor.
height - The height of the cursor.
Returns:
A processed Point that has "safe" values.

cursorImage

private static java.nio.IntBuffer cursorImage(org.newdawn.slick.opengl.Texture texture,
                                              int width,
                                              int height)
Loads the cursor data into an IntBuffer from the supplied texture.

Parameters:
texture - The texture to copy into the cursor.
width - The width of the cursor.
height - The height of the cursor.
Returns:
An IntBuffer containing the pixel data of the cursor.