javafx.scene.ImageCursor Java Examples
The following examples show how to use
javafx.scene.ImageCursor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FXCanvasEx.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public void changed(ObservableValue<? extends Cursor> observable, Cursor oldCursor, Cursor newCursor) { if (newCursor instanceof ImageCursor) { // custom cursor, convert image ImageData imageData = SWTFXUtils.fromFXImage( ((ImageCursor) newCursor).getImage(), null); double hotspotX = ((ImageCursor) newCursor).getHotspotX(); double hotspotY = ((ImageCursor) newCursor).getHotspotY(); org.eclipse.swt.graphics.Cursor swtCursor = new org.eclipse.swt.graphics.Cursor( getDisplay(), imageData, (int) hotspotX, (int) hotspotY); try { Method currentCursorFrameAccessor = Cursor.class .getDeclaredMethod("getCurrentFrame", new Class[] {}); currentCursorFrameAccessor.setAccessible(true); Object currentCursorFrame = currentCursorFrameAccessor .invoke(newCursor, new Object[] {}); // there is a spelling-mistake in the internal API // (setPlatformCursor -> setPlatforCursor) Method platformCursorProvider = currentCursorFrame .getClass().getMethod("setPlatforCursor", new Class[] { Class.class, Object.class }); platformCursorProvider.setAccessible(true); platformCursorProvider.invoke(currentCursorFrame, org.eclipse.swt.graphics.Cursor.class, swtCursor); } catch (Exception e) { System.err.println( "Failed to set platform cursor on the current cursor frame."); e.printStackTrace(); } } }
Example #2
Source File: RectangleItem.java From OpenLabeler with Apache License 2.0 | 4 votes |
private static ImageCursor createImageCursor(String path) { Image image = new Image(path, true); return new ImageCursor(image, image.getWidth() / 2, image.getHeight() / 2); }
Example #3
Source File: RotateSelectedOnHandleDragHandler.java From gef with Eclipse Public License 2.0 | 2 votes |
/** * Returns the {@link Cursor} that is shown to indicate that this policy * will perform a rotation. * * @return The {@link Cursor} that is shown to indicate that this policy * will perform a rotation. */ protected ImageCursor createRotateCursor() { return new ImageCursor(new Image(RotateSelectedOnHandleDragHandler.class .getResource("/rotate_obj.gif").toExternalForm())); }