当前位置: 首页>>代码示例>>Java>>正文


Java ImageCursor类代码示例

本文整理汇总了Java中javafx.scene.ImageCursor的典型用法代码示例。如果您正苦于以下问题:Java ImageCursor类的具体用法?Java ImageCursor怎么用?Java ImageCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ImageCursor类属于javafx.scene包,在下文中一共展示了ImageCursor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDrawMode

import javafx.scene.ImageCursor; //导入依赖的package包/类
@Override
public void setDrawMode(DrawMode drawMode) {
    this.drawMode = drawMode;
    switch (drawMode) {
        case TileEraser:
            ImageCursor cursor = new ImageCursor(new Image("images/eraser.png"));
            drawCanvas.setCursor(cursor);
            break;
        case Select:
            drawCanvas.setCursor(Cursor.CROSSHAIR);
            break;
        case ScriptPencil:
            drawCanvas.setCursor(Cursor.CLOSED_HAND);
            break;
        case ScriptEraser:
            drawCanvas.setCursor(Cursor.OPEN_HAND);
            break;
        default:
            setCurrentTile(getCurrentTile());
            break;
    }
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:23,代码来源:MapEditor.java

示例2: apply

import javafx.scene.ImageCursor; //导入依赖的package包/类
/** @param scene JavaFX Scene where cursor is monitored
 *  @param display SWT Display where the scene's cursor is set
 */
public static void apply(final Scene scene, final Display display)
{
    // Track JFX cursor, update SWT cursor
    final ChangeListener<Cursor> cursor_listener = (prop, old, newCursor) ->
    {
        // Standard cursors and null are handled by FXCanvas.
        // Image-based cursors need to be translated into SWT cursor
        // with code based on GEF FXCanvasEx,
        // https://github.com/eclipse/gef4/blob/master/org.eclipse.gef4.fx.swt/src/org/eclipse/gef4/fx/swt/canvas/FXCanvasEx.java
        if (! (newCursor instanceof ImageCursor))
            return;

        // Custom cursor, convert image
        final ImageCursor cursor = (ImageCursor) newCursor;
        final ImageData imageData = ImageConverter.convertToSWT(cursor.getImage());
        final double hotspotX = cursor.getHotspotX();
        final double hotspotY = cursor.getHotspotY();
        org.eclipse.swt.graphics.Cursor swtCursor = new org.eclipse.swt.graphics.Cursor(
                display, imageData, (int) hotspotX, (int) hotspotY);
        // Set platform cursor on CursorFrame so that it can be
        // retrieved by FXCanvas' HostContainer
        // which ultimately sets the cursor on the FXCanvas
        try
        {
            final Method currentCursorFrameAccessor =
                Cursor.class.getDeclaredMethod("getCurrentFrame", new Class[] {});
            currentCursorFrameAccessor.setAccessible(true);
            final CursorFrame currentCursorFrame = (CursorFrame) currentCursorFrameAccessor.invoke(newCursor, new Object[] {});
            currentCursorFrame.setPlatforCursor(org.eclipse.swt.graphics.Cursor.class, swtCursor);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot update SWT cursor from JFX cursor", ex);
        }
    };
    scene.cursorProperty().addListener(cursor_listener);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:41,代码来源:JFXCursorFix.java

示例3: provideCursorObjectEnumPropertyLine

import javafx.scene.ImageCursor; //导入依赖的package包/类
public static Cursor provideCursorObjectEnumPropertyLine(ObjectProperty property, PropertiesTable tb, Object owningObject) {
    ImageCursor c1 = new ImageCursor(new Image("https://svn.java.net/svn/fxtest-golden~images-svn/ControlsTests/JavaProgBarInd80x80.gif"));
    List possibleTooltips = new ArrayList();
    possibleTooltips.add(null);
    possibleTooltips.add(c1);
    tb.addObjectEnumPropertyLine(property, possibleTooltips, owningObject);
    return c1;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:9,代码来源:PropertyTablesFactory.java

示例4: start

import javafx.scene.ImageCursor; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    //stage = new Stage(StageStyle.DECORATED);
    stage = SceneBuilder.setFullScreen(stage);
    stage.setScene(new Scene(SceneBuilder.setFxmlLoader(Url.START_UP,new StartUpController(stage))));
           //cursor
    Image image = new Image(Url.CURSOR);  //pass in the image path
    stage.getScene().setCursor(new ImageCursor(image));
    setUserAgentStylesheet(STYLESHEET_MODENA);
    
    stage.show();
}
 
开发者ID:SaeedMasoumi,项目名称:stupidwarriors,代码行数:13,代码来源:StartUp.java

示例5: setCurrentTile

import javafx.scene.ImageCursor; //导入依赖的package包/类
/**
 * @param currentTile the currentTile to set
 * @return Same tile (necessary for callback support)
 */
public Tile setCurrentTile(Tile currentTile) {
    if (drawMode == DrawMode.TileEraser) {
        drawMode = DrawMode.Pencil1px;
    }
    this.currentTile = currentTile;
    ImageCursor cursor = new ImageCursor(TileUtils.getImage(currentTile, getCurrentPlatform()), 2, 2);
    drawCanvas.setCursor(cursor);
    return currentTile;
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:14,代码来源:MapEditor.java

示例6: loadCursor

import javafx.scene.ImageCursor; //导入依赖的package包/类
public static Cursor loadCursor()
{
    return new ImageCursor(loadImage("img\\cursor.png"));
}
 
开发者ID:nuclearthinking,项目名称:rpg,代码行数:5,代码来源:ManagerResources.java

示例7: ChangeMouseOnPass

import javafx.scene.ImageCursor; //导入依赖的package包/类
public ChangeMouseOnPass(T node, Image onEnter, Image onExit, boolean keepOldHandlers) {
	this(node, onEnter==null ? null : new ImageCursor(onEnter), onExit==null ? null : new ImageCursor(onExit), keepOldHandlers);
}
 
开发者ID:ngspipes,项目名称:JavaFXUtils,代码行数:4,代码来源:ChangeMouseOnPass.java

示例8: ChangeMouseOnPress

import javafx.scene.ImageCursor; //导入依赖的package包/类
public ChangeMouseOnPress(T node, Image onPress, Image onRelease, boolean keepOldHandlers) {
	this(node, onPress==null ? null : new ImageCursor(onPress), onRelease==null ? null : new ImageCursor(onRelease), keepOldHandlers);
}
 
开发者ID:ngspipes,项目名称:JavaFXUtils,代码行数:4,代码来源:ChangeMouseOnPress.java

示例9: start

import javafx.scene.ImageCursor; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
	stage.setResizable(false);
	Group root  = new Group();
	root.getStyleClass().add("mainStage");
	Scene scene = new Scene(root, 832, 290, Color.BISQUE);
	scene.getStylesheets().add("styles/sample.css");
	
	
    TilePane tp = new TilePane();
	tp.setPrefColumns(5);
	tp.setVgap(30);
	tp.setHgap(15);
	tp.setPadding(new Insets(10));
	
	tp.getChildren().add( new MyButton("CLOSED_HAND", Cursor.CLOSED_HAND));
	tp.getChildren().add( new MyButton("CROSSHAIR", Cursor.CROSSHAIR));
	tp.getChildren().add( new MyButton("DEFAULT", Cursor.DEFAULT));
	tp.getChildren().add( new MyButton("DISAPPEAR", Cursor.DISAPPEAR));
	tp.getChildren().add( new MyButton("E_RESIZE", Cursor.E_RESIZE));
	tp.getChildren().add( new MyButton("H_RESIZE", Cursor.H_RESIZE));
	tp.getChildren().add( new MyButton("HAND", Cursor.HAND));
	tp.getChildren().add( new MyButton("MOVE", Cursor.MOVE));
	tp.getChildren().add( new MyButton("N_RESIZE", Cursor.N_RESIZE));
	tp.getChildren().add( new MyButton("NE_RESIZE", Cursor.NE_RESIZE));
	tp.getChildren().add( new MyButton("NONE", Cursor.NONE));
	tp.getChildren().add( new MyButton("NW_RESIZE", Cursor.NW_RESIZE));
	tp.getChildren().add( new MyButton("OPEN_HAND", Cursor.OPEN_HAND));
	tp.getChildren().add( new MyButton("S_RESIZE", Cursor.S_RESIZE));
	tp.getChildren().add( new MyButton("SE_RESIZE", Cursor.SE_RESIZE));
	tp.getChildren().add( new MyButton("SW_RESIZE", Cursor.SW_RESIZE));
	tp.getChildren().add( new MyButton("TEXT", Cursor.TEXT));
	tp.getChildren().add( new MyButton("V_RESIZE", Cursor.V_RESIZE));
	tp.getChildren().add( new MyButton("W_RESIZE", Cursor.W_RESIZE));
	tp.getChildren().add( new MyButton("WAIT", Cursor.WAIT));
	
	Image img = new Image(getClass().getResourceAsStream("/images/close.png"));
	ImageCursor CURSOR_SEEK = new ImageCursor(img);
	tp.getChildren().add( new MyButton("CUSTOM CURSOR", CURSOR_SEEK));
	
	
    root.getChildren().addAll(tp);
    stage.setTitle("JavaFx Cursors Demo");
	stage.setScene(scene);
	stage.show();
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:47,代码来源:CursorsDemo.java

示例10: setCursor

import javafx.scene.ImageCursor; //导入依赖的package包/类
/**
 * Sets global game cursor using given name to find
 * the image cursor within assets/ui/cursors/.
 * Hotspot is location of the pointer end on the image.
 *
 * @param imageName name of image file
 * @param hotspot hotspot location
 */
public final void setCursor(String imageName, Point2D hotspot) {
    root.setCursor(new ImageCursor(FXGL.getAssetLoader().loadCursorImage(imageName),
            hotspot.getX(), hotspot.getY()));
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:13,代码来源:FXGLScene.java


注:本文中的javafx.scene.ImageCursor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。