| 1213 | |
| 1214 | |
| 1215 | public void setCursor(int kind) { |
| 1216 | if (!cursorNames.containsKey(kind)) { |
| 1217 | PGraphics.showWarning("Unknown cursor type: " + kind); |
| 1218 | return; |
| 1219 | } |
| 1220 | CursorInfo cursor = cursors.get(kind); |
| 1221 | if (cursor == null) { |
| 1222 | String name = cursorNames.get(kind); |
| 1223 | if (name != null) { |
| 1224 | URL url = getClass().getResource("cursors/" + name + ".png"); |
| 1225 | if (url != null) { |
| 1226 | ImageIcon icon = new ImageIcon(url); |
| 1227 | PImage img = new PImageAWT(icon.getImage()); |
| 1228 | // Most cursors just use the center as the hotspot... |
| 1229 | int x = img.width / 2; |
| 1230 | int y = img.height / 2; |
| 1231 | // ...others are more specific |
| 1232 | if (kind == PConstants.ARROW) { |
| 1233 | x = 10; |
| 1234 | y = 7; |
| 1235 | } else if (kind == PConstants.HAND) { |
| 1236 | x = 12; |
| 1237 | y = 8; |
| 1238 | } else if (kind == PConstants.TEXT) { |
| 1239 | x = 16; |
| 1240 | y = 22; |
| 1241 | } |
| 1242 | cursor = new CursorInfo(img, x, y); |
| 1243 | cursors.put(kind, cursor); |
| 1244 | } |
| 1245 | } |
| 1246 | } |
| 1247 | if (cursor != null) { |
| 1248 | cursor.set(); |
| 1249 | } else { |
| 1250 | PGraphics.showWarning("Cannot load cursor type: " + kind); |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | |
| 1255 | public void setCursor(PImage image, int hotspotX, int hotspotY) { |