public class CursorUtils
extends java.lang.Object
Cursor Utilities.
Currently the main utility provided is a mechanism to get the image of a cursor, which is not currently possible without native code.
The current implementation is only a stub; 24x24 X11 cursors are always returned independent of the underlying platform.
Animated cursors are TBD. Currently only their first frame is loaded.
Also see:
http://www.gimpstuff.org/content/show.php/X11+Mouse+Cursor+%28XMC%29+plug-in?content=94503 http://gericom.wordpress.com/repository/ http://cli-apps.org/content/show.php/xcur2png?content=86010 http://stackoverflow.com/questions/739870/extract-cursor-image-in-java
Modifier and Type | Class and Description |
---|---|
static class |
CursorUtils.CursorImage
The image of a cursor.
|
static class |
CursorUtils.CursorInfo
info for a cursor
|
static class |
CursorUtils.DefaultCursorInfo
info for a cursor with image stored as resource
|
static class |
CursorUtils.PredefinedCursorInfo
info for a Java predefined cursor
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.Map<CursorUtils.CursorInfo,CursorUtils.CursorImage> |
cursorImages
registered cursor images
|
protected static java.util.Map<java.awt.Cursor,CursorUtils.CursorInfo> |
cursorInfoCache
cache for
getCursorInfo(Cursor, int, int) |
protected static boolean |
loadedPredefinedCursorImages
whether
setPredefinedCursorImages() has been auto-run yet |
private static java.lang.String |
svnid |
static java.awt.Dimension |
X11_DEFAULT_CURSOR_SIZE
default for
getCurrentCursorSize() |
static CursorUtils.DefaultCursorInfo[] |
X11_DEFAULT_CURSORS
default for
setPredefinedCursorImages() |
Constructor and Description |
---|
CursorUtils() |
Modifier and Type | Method and Description |
---|---|
static java.awt.Dimension |
getCurrentCursorSize()
Get the current cursor size.
|
static CursorUtils.CursorImage |
getCursorImage(java.awt.Cursor cursor)
get the image for a cursor, using
getCurrentCursorSize() |
static CursorUtils.CursorImage |
getCursorImage(java.awt.Cursor cursor,
int width,
int height)
get the image for a cursor
|
static CursorUtils.CursorImage |
getCursorImage(CursorUtils.CursorInfo info)
get the image for a cursor
|
static CursorUtils.CursorInfo |
getCursorInfo(java.awt.Cursor cursor)
Covers
getCursorInfo(Cursor, int, int) , uses getCurrentCursorSize() . |
static CursorUtils.CursorInfo |
getCursorInfo(java.awt.Cursor cursor,
int width,
int height)
Get a
CursorUtils.CursorInfo object describing
cursor as best as possible. |
static CursorUtils.CursorImage |
loadDefaultCursor(CursorUtils.DefaultCursorInfo info)
Load a cursor image from resource.
|
static CursorUtils.CursorImage |
setCursorImage(java.awt.Cursor cursor,
java.awt.Image image,
int xHot,
int yHot)
Register image for cursor.
|
static void |
setPredefinedCursorImages()
Set images for all the Java predefined cursors.
|
static byte[] |
toABGR(java.awt.Image image)
Convert image into a raw ABGR raster.
|
private static final java.lang.String svnid
public static final CursorUtils.DefaultCursorInfo[] X11_DEFAULT_CURSORS
setPredefinedCursorImages()
public static final java.awt.Dimension X11_DEFAULT_CURSOR_SIZE
getCurrentCursorSize()
protected static final java.util.Map<CursorUtils.CursorInfo,CursorUtils.CursorImage> cursorImages
protected static final java.util.Map<java.awt.Cursor,CursorUtils.CursorInfo> cursorInfoCache
getCursorInfo(Cursor, int, int)
protected static boolean loadedPredefinedCursorImages
setPredefinedCursorImages()
has been auto-run yetpublic static CursorUtils.CursorImage getCursorImage(java.awt.Cursor cursor, int width, int height) throws java.io.IOException
java.io.IOException
public static CursorUtils.CursorImage getCursorImage(java.awt.Cursor cursor) throws java.io.IOException
getCurrentCursorSize()
java.io.IOException
public static CursorUtils.CursorImage getCursorImage(CursorUtils.CursorInfo info) throws java.io.IOException
java.io.IOException
public static CursorUtils.CursorInfo getCursorInfo(java.awt.Cursor cursor, int width, int height)
Get a CursorUtils.CursorInfo
object describing
cursor as best as possible.
public static CursorUtils.CursorInfo getCursorInfo(java.awt.Cursor cursor)
Covers getCursorInfo(Cursor, int, int)
, uses getCurrentCursorSize()
.
public static CursorUtils.CursorImage setCursorImage(java.awt.Cursor cursor, java.awt.Image image, int xHot, int yHot)
Register image for cursor.
Only registered images will be later retrievable with the getCursorImage(...)
APIs, but note that setPredefinedCursorImages()
will be automatically called the first time an
image cannot be retrieved. Thus, it is typically only necessary to
explicitly call this method when using a custom cursor (Toolkit.createCustomCursor(...)
).
public static byte[] toABGR(java.awt.Image image)
Convert image into a raw ABGR raster.
The raster starts at the upper left corner of the image, scans first to the right, and then down.
public static void setPredefinedCursorImages() throws java.io.IOException
Set images for all the Java predefined cursors.
Current impl is a stub that loads X11_DEFAULT_CURSORS
. A full
implementation would have to call native code. An intermediate
implementation would load default cursors depending on the system property
java.awt.graphicsenv
.
java.io.IOException
public static CursorUtils.CursorImage loadDefaultCursor(CursorUtils.DefaultCursorInfo info) throws java.io.IOException
Load a cursor image from resource.
java.io.IOException
public static java.awt.Dimension getCurrentCursorSize()
Get the current cursor size.
Current impl is a stub that always returns X11_DEFAULT_CURSOR_SIZE
. A full implimentation would have to call
native code. An intermediate implementation would return the default
cursor size depending on the system property java.awt.graphicsenv
.