本文整理汇总了Java中javafx.scene.canvas.Canvas.setOnMouseExited方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.setOnMouseExited方法的具体用法?Java Canvas.setOnMouseExited怎么用?Java Canvas.setOnMouseExited使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.setOnMouseExited方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructCanvas
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
private void constructCanvas() {
boardCanvas = new Canvas();
if ( interactive ) {
boardCanvas.setOnMouseMoved(this::canvasHover);
boardCanvas.setOnMouseClicked(this::canvasClicked);
boardCanvas.setOnMouseExited(this::canvasExit);
}
boardPane.getChildren().add(boardCanvas);
gameDrawer = buildGameDrawer();
gameDrawer.draw(getGameHandler().getBoard());
}
示例2: setCanvas
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
/**
* Sets the {@link Canvas} for use by the visualizer.
* <p>
* When the user clicks on the canvas, if the x and y coordinates intersect with a base then the offset is updated
* to the given base. If the mouse is hovered over a base the hovered base id is updated.
*
* @param canvas {@link Canvas} for use by the visualizer
*/
public void setCanvas(final Canvas canvas) {
this.canvas = canvas;
this.graphicsContext = canvas.getGraphicsContext2D();
canvas.widthProperty().addListener((observable, oldValue, newValue) -> draw());
canvas.setOnMouseClicked(event -> {
Optional.of(rTree).ifPresent(tree -> tree.find(event.getX(), event.getY(), offsetProperty::set));
// Do a second search as base nodes have been shifted.
Optional.of(rTree).ifPresent(tree -> tree.find(event.getX(), event.getY(), hoveredBaseIdProperty::set));
});
canvas.setOnMouseMoved(event -> Optional.of(rTree)
.ifPresent(tree -> tree.find(event.getX(), event.getY(), hoveredBaseIdProperty::set)));
canvas.setOnMouseExited(event -> hoveredBaseIdProperty.set(-1));
}
示例3: setCanvas
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
/**
* Set {@link Canvas} which the {@link GraphVisualizer} use to draw.
*
* @param canvas canvas to be used to {@link GraphVisualizer}
*/
public void setCanvas(final Canvas canvas) {
this.canvas = canvas;
this.graphicsContext = canvas.getGraphicsContext2D();
this.segmentDrawingToolkit.setGraphicsContext(graphicsContext);
this.snpDrawingToolkit.setGraphicsContext(graphicsContext);
this.edgeDrawingToolkit.setGraphicsContext(graphicsContext);
this.graphAnnotationVisualizer.setGraphicsContext(graphicsContext);
canvas.setOnMouseClicked(event -> {
selectedSegmentProperty.setValue(null);
if (rTree == null) {
return;
}
rTree.find(event.getX(), event.getY(), this::setSelectedSegment);
});
canvas.setOnMouseMoved(event -> {
if (graphDimensionsCalculator.getLastScrollTime() > System.currentTimeMillis() - 100) {
return;
}
hoveredSegmentProperty.set(null);
if (rTree == null) {
return;
}
rTree.find(event.getX(), event.getY(), this::setHoveredSegmentProperty);
});
canvas.setOnMouseExited(event -> hoveredSegmentProperty.set(null));
graphDimensionsCalculator.setCanvasSize(canvas.getWidth(), canvas.getHeight());
canvas.widthProperty().addListener((observable, oldValue, newValue) -> {
graphDimensionsCalculator.setCanvasSize(newValue.doubleValue(), canvas.getHeight());
graphAnnotationVisualizer.setCanvasWidth(newValue.doubleValue());
});
canvas.heightProperty().addListener((observable, oldValue, newValue) -> {
graphDimensionsCalculator.setCanvasSize(canvas.getWidth(), newValue.doubleValue());
segmentDrawingToolkit.setCanvasHeight(newValue.doubleValue());
snpDrawingToolkit.setCanvasHeight(newValue.doubleValue());
});
graphAnnotationVisualizer.setCanvasWidth(canvas.getWidth());
segmentDrawingToolkit.setCanvasHeight(canvas.getHeight());
snpDrawingToolkit.setCanvasHeight(canvas.getHeight());
}