本文整理汇总了Java中javafx.scene.canvas.Canvas.setMouseTransparent方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.setMouseTransparent方法的具体用法?Java Canvas.setMouseTransparent怎么用?Java Canvas.setMouseTransparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.setMouseTransparent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCanvas
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
/**
* 初始化背景绘画节点
*/
protected void initCanvas() {
canvas = new Canvas();
//在Canvas高宽改变的时候,重新绘制
canvas.heightProperty().addListener(observable -> {
clearConner();
drawConner();
});
canvas.widthProperty().addListener(observable -> {
clearConner();
drawConner();
});
//canvas的高宽于box的高宽绑定在一起
canvas.widthProperty().bind(Width);
canvas.heightProperty().bind(Height);
getChildren().add(canvas);
//无论Canvas接收到什么鼠标事件都传递给Box处理
canvas.setMouseTransparent(true);
}
示例2: initGraphics
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
private void initGraphics() {
if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
Double.compare(getHeight(), 0.0) <= 0) {
if (getPrefWidth() > 0 && getPrefHeight() > 0) {
setPrefSize(getPrefWidth(), getPrefHeight());
} else {
setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
}
}
segmentPane = new Pane();
chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
chartCanvas.setMouseTransparent(true);
chartCtx = chartCanvas.getGraphicsContext2D();
pane = new Pane(segmentPane, chartCanvas);
pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY)));
pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth))));
getChildren().setAll(pane);
prepareData();
}
示例3: addGrid
import javafx.scene.canvas.Canvas; //导入方法依赖的package包/类
/**
* Add a grid to the canvas, send it to the back
*/
public void addGrid() {
double w = getBoundsInLocal().getWidth();
double h = getBoundsInLocal().getHeight();
// add grid
Canvas grid = new Canvas(w, h);
// don't catch mouse events
grid.setMouseTransparent(true);
GraphicsContext gc = grid.getGraphicsContext2D();
gc.setStroke(Color.GRAY);
gc.setLineWidth(1);
// draw grid lines
double offset = 50;
for (double i = offset; i < w; i += offset) {
gc.strokeLine(i, 0, i, h);
gc.strokeLine(0, i, w, i);
}
getChildren().add(grid);
grid.toBack();
}