(int kind)
| 1232 | |
| 1233 | |
| 1234 | public void setCursor(int kind) { |
| 1235 | if (!cursorNames.containsKey(kind)) { |
| 1236 | PGraphics.showWarning("Unknown cursor type: " + kind); |
| 1237 | return; |
| 1238 | } |
| 1239 | CursorInfo cursor = cursors.get(kind); |
| 1240 | if (cursor == null) { |
| 1241 | String name = cursorNames.get(kind); |
| 1242 | if (name != null) { |
| 1243 | ImageIcon icon = |
| 1244 | new ImageIcon(getClass().getResource("cursors/" + name + ".png")); |
| 1245 | PImage img = new PImage(icon.getImage()); |
| 1246 | // Most cursors just use the center as the hotspot... |
| 1247 | int x = img.width / 2; |
| 1248 | int y = img.height / 2; |
| 1249 | // ...others are more specific |
| 1250 | if (kind == PConstants.ARROW) { |
| 1251 | x = 10; y = 7; |
| 1252 | } else if (kind == PConstants.HAND) { |
| 1253 | x = 12; y = 8; |
| 1254 | } else if (kind == PConstants.TEXT) { |
| 1255 | x = 16; y = 22; |
| 1256 | } |
| 1257 | cursor = new CursorInfo(img, x, y); |
| 1258 | cursors.put(kind, cursor); |
| 1259 | } |
| 1260 | } |
| 1261 | if (cursor != null) { |
| 1262 | cursor.set(); |
| 1263 | } else { |
| 1264 | PGraphics.showWarning("Cannot load cursor type: " + kind); |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | |
| 1269 | public void setCursor(PImage image, int hotspotX, int hotspotY) { |
nothing calls this directly
no test coverage detected