类javafx.scene.ImageCursor源码实例Demo

下面列出了怎么用javafx.scene.ImageCursor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gef   文件: FXCanvasEx.java
@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();
		}
	}
}
 
源代码2 项目: OpenLabeler   文件: RectangleItem.java
private static ImageCursor createImageCursor(String path) {
   Image image = new Image(path, true);
   return new ImageCursor(image, image.getWidth() / 2, image.getHeight() / 2);
}
 
源代码3 项目: gef   文件: RotateSelectedOnHandleDragHandler.java
/**
 * 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()));
}
 
 类所在包
 同包方法