本文整理匯總了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();
}