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


Java Cursor.W_RESIZE屬性代碼示例

本文整理匯總了Java中javafx.scene.Cursor.W_RESIZE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.W_RESIZE屬性的具體用法?Java Cursor.W_RESIZE怎麽用?Java Cursor.W_RESIZE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javafx.scene.Cursor的用法示例。


在下文中一共展示了Cursor.W_RESIZE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createResizeAnchors

private void createResizeAnchors() {
    resizeAnchors = new ArrayList<>();

    ResizeAnchor nwResizeAnchor = new ResizeAnchor(mainController, Cursor.NW_RESIZE, focusRectangle);
    ResizeAnchor neResizeAnchor = new ResizeAnchor(mainController, Cursor.NE_RESIZE, focusRectangle);
    ResizeAnchor seResizeAnchor = new ResizeAnchor(mainController, Cursor.SE_RESIZE, focusRectangle);
    ResizeAnchor swResizeAnchor = new ResizeAnchor(mainController, Cursor.SW_RESIZE, focusRectangle);

    ResizeAnchor nResizeAnchor = new ResizeAnchor(mainController, Cursor.N_RESIZE, focusRectangle);
    ResizeAnchor eResizeAnchor = new ResizeAnchor(mainController, Cursor.E_RESIZE, focusRectangle);
    ResizeAnchor sResizeAnchor = new ResizeAnchor(mainController, Cursor.S_RESIZE, focusRectangle);
    ResizeAnchor wResizeAnchor = new ResizeAnchor(mainController, Cursor.W_RESIZE, focusRectangle);

    resizeAnchors.add(nwResizeAnchor);
    resizeAnchors.add(neResizeAnchor);
    resizeAnchors.add(seResizeAnchor);
    resizeAnchors.add(swResizeAnchor);

    resizeAnchors.add(nResizeAnchor);
    resizeAnchors.add(eResizeAnchor);
    resizeAnchors.add(sResizeAnchor);
    resizeAnchors.add(wResizeAnchor);
}
 
開發者ID:pfolta,項目名稱:Shapify,代碼行數:23,代碼來源:FocusOutline.java

示例2: changeCursor

private Cursor changeCursor(boolean sizeLeft, boolean sizeRight, boolean sizeTop, boolean sizeBottom) {
    Cursor cursor = Cursor.DEFAULT;
    if (sizeLeft) {
        if (sizeTop) {
            cursor = Cursor.NW_RESIZE;
        }
        else if (sizeBottom) {
            cursor = Cursor.SW_RESIZE;
        }
        else {
            cursor = Cursor.W_RESIZE;
        }
    }
    else if (sizeRight) {
        if (sizeTop) {
            cursor = Cursor.NE_RESIZE;
        }
        else if (sizeBottom) {
            cursor = Cursor.SE_RESIZE;
        }
        else {
            cursor = Cursor.E_RESIZE;
        }
    }
    else if (sizeTop) {
        cursor = Cursor.N_RESIZE;
    }
    else if (sizeBottom) {
        cursor = Cursor.S_RESIZE;
    }

    return cursor;
}
 
開發者ID:alexbodogit,項目名稱:AnchorFX,代碼行數:33,代碼來源:StageFloatable.java

示例3: handle

@Override
public void handle(MouseEvent mouseEvent) {
    EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
    Scene scene = stage.getScene();

    double mouseEventX = mouseEvent.getSceneX(), 
           mouseEventY = mouseEvent.getSceneY(),
           sceneWidth = scene.getWidth(),
           sceneHeight = scene.getHeight();

    if (MouseEvent.MOUSE_MOVED.equals(mouseEventType) == true) {
        if (mouseEventX < border && mouseEventY < border) {
            cursorEvent = Cursor.NW_RESIZE;
        } else if (mouseEventX < border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SW_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY < border) {
            cursorEvent = Cursor.NE_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SE_RESIZE;
        } else if (mouseEventX < border) {
            cursorEvent = Cursor.W_RESIZE;
        } else if (mouseEventX > sceneWidth - border) {
            cursorEvent = Cursor.E_RESIZE;
        } else if (mouseEventY < border) {
            cursorEvent = Cursor.N_RESIZE;
        } else if (mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.S_RESIZE;
        } else {
            cursorEvent = Cursor.DEFAULT;
        }
        scene.setCursor(cursorEvent);
    } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType) == true) {
        startX = stage.getWidth() - mouseEventX;
        startY = stage.getHeight() - mouseEventY;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType) == true) {
        if (Cursor.DEFAULT.equals(cursorEvent) == false) {
            if (Cursor.W_RESIZE.equals(cursorEvent) == false && Cursor.E_RESIZE.equals(cursorEvent) == false) {
                double minHeight = stage.getMinHeight() > (border*2) ? stage.getMinHeight() : (border*2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.N_RESIZE.equals(cursorEvent) == true || Cursor.NE_RESIZE.equals(cursorEvent) == true) {
                    if (stage.getHeight() > minHeight || mouseEventY < 0) {
                        stage.setHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight());
                        stage.setY(mouseEvent.getScreenY());
                    }
                } else {
                    if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) {
                        stage.setHeight(mouseEventY + startY);
                    }
                }
            }

            if (Cursor.N_RESIZE.equals(cursorEvent) == false && Cursor.S_RESIZE.equals(cursorEvent) == false) {
                double minWidth = stage.getMinWidth() > (border*2) ? stage.getMinWidth() : (border*2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.W_RESIZE.equals(cursorEvent) == true || Cursor.SW_RESIZE.equals(cursorEvent) == true) {
                    if (stage.getWidth() > minWidth || mouseEventX < 0) {
                        stage.setWidth(stage.getX() - mouseEvent.getScreenX() + stage.getWidth());
                        stage.setX(mouseEvent.getScreenX());
                    }
                } else {
                    if (stage.getWidth() > minWidth || mouseEventX + startX - stage.getWidth() > 0) {
                        stage.setWidth(mouseEventX + startX);
                    }
                }
            }
        }

    }
}
 
開發者ID:linchaolong,項目名稱:ApkToolPlus,代碼行數:67,代碼來源:ResizeHelper.java

示例4: setupMouseEvents

private void setupMouseEvents() {
    eventsHandler = event -> {

        if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
            mousePositionStart = new Point2D(event.getScreenX(), event.getScreenY());
            startWidth = getWidth();
            startX = getX();

            startHeight = getHeight();
            startY = getY();
        }

        if (event.getEventType() == MouseEvent.MOUSE_MOVED) {

            boolean sizeRight = valueInRange(event.getX(), stackPanelContainer.getWidth() - stackPanelContainer.getPadding().getLeft(), stackPanelContainer.getWidth());
            boolean sizeLeft = valueInRange(event.getX(), 0, stackPanelContainer.getPadding().getRight());
            boolean sizeTop = valueInRange(event.getY(), 0, stackPanelContainer.getPadding().getTop());
            boolean sizeBottom = valueInRange(event.getY(), stackPanelContainer.getHeight() - stackPanelContainer.getPadding().getBottom(), stackPanelContainer.getHeight());

            Cursor cursor = changeCursor(sizeLeft, sizeRight, sizeTop, sizeBottom);

            getScene().setCursor(cursor);
        }

        if (event.getEventType() == MouseEvent.MOUSE_DRAGGED && (getScene().getCursor() != null && getScene().getCursor() != Cursor.DEFAULT)) {

            if (getScene().getCursor() == Cursor.E_RESIZE || getScene().getCursor() == Cursor.SE_RESIZE || getScene().getCursor() == Cursor.NE_RESIZE) {
                if (event.getScreenX() - getX() + FLOATING_NODE_DROPSHADOW_RADIUS > FLOATING_NODE_MINIMUM_WIDTH) {
                    setWidth(event.getScreenX() - getX() + FLOATING_NODE_DROPSHADOW_RADIUS);
                }
            }
            else if (getScene().getCursor() == Cursor.S_RESIZE || getScene().getCursor() == Cursor.SE_RESIZE || getScene().getCursor() == Cursor.SW_RESIZE) {
                if (event.getScreenY() - getY() + FLOATING_NODE_DROPSHADOW_RADIUS > FLOATING_NODE_MINIMUM_HEIGHT) {
                    setHeight(event.getScreenY() - getY() + FLOATING_NODE_DROPSHADOW_RADIUS);
                }
            }
            else if (getScene().getCursor() == Cursor.W_RESIZE || getScene().getCursor() == Cursor.NW_RESIZE || getScene().getCursor() == Cursor.SW_RESIZE) {

                double newX = event.getScreenX() - FLOATING_NODE_DROPSHADOW_RADIUS;
                double newWidth = startX - newX + startWidth;

                if (newWidth > FLOATING_NODE_MINIMUM_WIDTH) {
                    setX(newX);
                    setWidth(newWidth);
                }

            }
            else if (getScene().getCursor() == Cursor.N_RESIZE || getScene().getCursor() == Cursor.NW_RESIZE || getScene().getCursor() == Cursor.NE_RESIZE) {

                double newY = event.getScreenY() - FLOATING_NODE_DROPSHADOW_RADIUS;
                double newHeight = startY - newY + startHeight;

                if (newHeight > FLOATING_NODE_MINIMUM_HEIGHT) {
                    setY(newY);
                    setHeight(newHeight);
                }

            }

        }
        /*
        else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
            // TODO: handle this event?
        }
        */
    };

    stackPanelContainer.addEventFilter(MouseEvent.MOUSE_PRESSED, eventsHandler);
    stackPanelContainer.addEventFilter(MouseEvent.MOUSE_MOVED, eventsHandler);
    stackPanelContainer.addEventFilter(MouseEvent.MOUSE_DRAGGED, eventsHandler);
    stackPanelContainer.addEventFilter(MouseEvent.MOUSE_RELEASED, eventsHandler);
}
 
開發者ID:alexbodogit,項目名稱:AnchorFX,代碼行數:72,代碼來源:StageFloatable.java


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