Fields Summary |
---|
private static final long | serialVersionUIDThe Constant serialVersionUID. |
public static final int | DEFAULT_CURSORThe Constant DEFAULT_CURSOR indicates the default cursor type. |
public static final int | CROSSHAIR_CURSORThe Constant CROSSHAIR_CURSOR cursor type. |
public static final int | TEXT_CURSORThe Constant TEXT_CURSOR cursor type. |
public static final int | WAIT_CURSORThe Constant WAIT_CURSOR cursor type. |
public static final int | SW_RESIZE_CURSORThe Constant SW_RESIZE_CURSOR cursor type. |
public static final int | SE_RESIZE_CURSORThe Constant SE_RESIZE_CURSOR cursor type. |
public static final int | NW_RESIZE_CURSORThe Constant NW_RESIZE_CURSOR cursor type. |
public static final int | NE_RESIZE_CURSORThe Constant NE_RESIZE_CURSOR cursor type. |
public static final int | N_RESIZE_CURSORThe Constant N_RESIZE_CURSOR cursor type. |
public static final int | S_RESIZE_CURSORThe Constant S_RESIZE_CURSOR cursor type. |
public static final int | W_RESIZE_CURSORThe Constant W_RESIZE_CURSOR cursor type. |
public static final int | E_RESIZE_CURSORThe Constant E_RESIZE_CURSOR cursor type. |
public static final int | HAND_CURSORThe Constant HAND_CURSOR cursor type. |
public static final int | MOVE_CURSORThe Constant MOVE_CURSOR cursor type. |
static Map | systemCustomCursorsA mapping from names to system custom cursors. |
static Properties | cursorPropsThe cursor props. |
static final String[] | predefinedNamesThe Constant predefinedNames. |
protected static Cursor[] | predefinedThe predefined set of cursors. |
public static final int | CUSTOM_CURSORThe Constant CUSTOM_CURSOR is associated with all custom cursor types.
(Those which are not predefined) |
protected String | nameThe name of the cursor. |
private final int | typeThe type of the cursor, chosen from the list of cursor type constants. |
private transient org.apache.harmony.awt.wtk.NativeCursor | nativeCursorThe native cursor. |
private Point | hotSpotThe exact point on the cursor image that indicates which point the cursor
is selecting (pointing to). The coordinates are given with respect the
origin of the Image (its upper left corner). |
private Image | imageThe image to draw on the screen representing the cursor. |
Methods Summary |
---|
static void | checkType(int type)Check type.
// can't use predefined array here because it may not have been
// initialized yet
if ((type < 0) || (type >= predefinedNames.length)) {
// awt.143=illegal cursor type
throw new IllegalArgumentException(Messages.getString("awt.143")); //$NON-NLS-1$
}
|
protected void | finalize()Finalize method overrides the finalize method from Object class.
if (nativeCursor != null) {
nativeCursor.destroyCursor();
}
|
public static java.awt.Cursor | getDefaultCursor()Gets the default cursor.
return getPredefinedCursor(DEFAULT_CURSOR);
|
public java.lang.String | getName()Gets the name of the cursor.
return name;
|
org.apache.harmony.awt.wtk.NativeCursor | getNativeCursor()Gets the native cursor.
if (nativeCursor != null) {
return nativeCursor;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (type != CUSTOM_CURSOR) {
nativeCursor = toolkit.createNativeCursor(type);
} else {
nativeCursor = toolkit.createCustomNativeCursor(image, hotSpot, name);
}
return nativeCursor;
|
public static java.awt.Cursor | getPredefinedCursor(int type)Gets the predefined cursor with the specified type.
checkType(type);
Cursor cursor = predefined[type];
if (cursor == null) {
cursor = new Cursor(type);
predefined[type] = cursor;
}
return cursor;
|
public static java.awt.Cursor | getSystemCustomCursor(java.lang.String name)Gets the specified system custom cursor.
Toolkit.checkHeadless();
return getSystemCustomCursorFromMap(name);
|
private static java.awt.Cursor | getSystemCustomCursorFromMap(java.lang.String name)Gets the specified system custom cursor from the map of system custom
cursors.
loadCursorProps();
if (systemCustomCursors == null) {
systemCustomCursors = new HashMap<String, Cursor>();
}
Cursor cursor = systemCustomCursors.get(name);
if (cursor != null) {
return cursor;
}
// awt.141=failed to parse hotspot property for cursor:
String exMsg = Messages.getString("awt.141") + name; //$NON-NLS-1$
String nm = "Cursor." + name; //$NON-NLS-1$
String nameStr = cursorProps.getProperty(nm + ".Name"); //$NON-NLS-1$
String hotSpotStr = cursorProps.getProperty(nm + ".HotSpot"); //$NON-NLS-1$
String fileStr = cursorProps.getProperty(nm + ".File"); //$NON-NLS-1$
int idx = hotSpotStr.indexOf(',");
if (idx < 0) {
throw new AWTException(exMsg);
}
int x, y;
try {
x = new Integer(hotSpotStr.substring(0, idx)).intValue();
y = new Integer(hotSpotStr.substring(idx + 1, hotSpotStr.length())).intValue();
} catch (NumberFormatException nfe) {
throw new AWTException(exMsg);
}
Image img = Toolkit.getDefaultToolkit().createImage(fileStr);
cursor = new Cursor(nameStr, img, new Point(x, y));
systemCustomCursors.put(name, cursor);
return cursor;
|
public int | getType()Gets the cursor type.
return type;
|
private static void | loadCursorProps()Load cursor props.
if (cursorProps != null) {
return;
}
String sep = File.separator;
String cursorsDir = "lib" + sep + "images" + sep + "cursors"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String cursorsAbsDir = System.getProperty("java.home") + sep + //$NON-NLS-1$
cursorsDir;
String cursorPropsFileName = "cursors.properties"; //$NON-NLS-1$
String cursorPropsFullFileName = (cursorsAbsDir + sep + cursorPropsFileName);
cursorProps = new Properties();
try {
cursorProps.load(new FileInputStream(new File(cursorPropsFullFileName)));
} catch (FileNotFoundException e) {
// awt.142=Exception: class {0} {1} occurred while loading: {2}
throw new AWTException(Messages.getString("awt.142",//$NON-NLS-1$
new Object[] {
e.getClass(), e.getMessage(), cursorPropsFullFileName
}));
} catch (IOException e) {
throw new AWTException(e.getMessage());
}
|
void | setNativeCursor(org.apache.harmony.awt.wtk.NativeCursor nativeCursor)Sets the native cursor.
this.nativeCursor = nativeCursor;
|
public java.lang.String | toString()Returns the String representation of the cursor.
return getClass().getName() + "[" + name + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|