當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.setMouseTransparent方法代碼示例

本文整理匯總了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);
}
 
開發者ID:xfangfang,項目名稱:PhotoScript,代碼行數:24,代碼來源:DragBox.java

示例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();
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:26,代碼來源:SunburstChart.java

示例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();
}
 
開發者ID:INAETICS,項目名稱:Drones-Simulator,代碼行數:30,代碼來源:PannableCanvas.java


注:本文中的javafx.scene.canvas.Canvas.setMouseTransparent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。