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


Java Cursor.S_RESIZE_CURSOR屬性代碼示例

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


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

示例1: getCursorType

private int getCursorType (Rectangle b, Point p) {
    int leftDist = p.x - b.x;
    int rightDist = (b.x + b.width) - p.x;
    int topDist = p.y - b.y;
    int bottomDist = (b.y + b.height) - p.y;

    boolean isNearTop = topDist >= 0 && topDist <= insets.top;
    boolean isNearBottom = bottomDist >= 0 && bottomDist <= insets.bottom;
    boolean isNearLeft = leftDist >= 0 && leftDist <= insets.left;
    boolean isNearRight = rightDist >= 0 && rightDist <= insets.right;

    boolean isInTopPart = topDist >= 0 && topDist <= insets.top + 10;
    boolean isInBottomPart = bottomDist >= 0 && bottomDist <= insets.bottom + 10;
    boolean isInLeftPart = leftDist >= 0 && leftDist <= insets.left + 10;
    boolean isInRightPart = rightDist >= 0 && rightDist <= insets.right + 10;

    if (isNearTop && isInLeftPart || isInTopPart && isNearLeft) {
        return Cursor.NW_RESIZE_CURSOR;
    }
    if (isNearTop && isInRightPart || isInTopPart && isNearRight) {
        return Cursor.NE_RESIZE_CURSOR;
    }
    if (isNearBottom && isInLeftPart || isInBottomPart && isNearLeft) {
        return Cursor.SW_RESIZE_CURSOR;
    }
    if (isNearBottom && isInRightPart || isInBottomPart && isNearRight) {
        return Cursor.SE_RESIZE_CURSOR;
    }
    if (isNearTop) {
        return Cursor.N_RESIZE_CURSOR;
    }
    if (isNearLeft) {
        return Cursor.W_RESIZE_CURSOR;
    }
    if (isNearRight) {
        return Cursor.E_RESIZE_CURSOR;
    }
    if (isNearBottom) {
        return Cursor.S_RESIZE_CURSOR;
    }
    return Cursor.DEFAULT_CURSOR;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:42,代碼來源:DecorationUtils.java

示例2: computeNewBounds

private Rectangle computeNewBounds (Window w, Point dragLoc) {
    if (startDragLoc == null) {
        throw new IllegalArgumentException("Can't compute bounds when startDragLoc is null");  //NOI18N
    }
    int xDiff = dragLoc.x - startDragLoc.x;
    int yDiff = dragLoc.y - startDragLoc.y;
    resizedBounds.setBounds(startWinBounds);

    switch (cursorType) {
        case Cursor.E_RESIZE_CURSOR:
            resizedBounds.width = startWinBounds.width + (dragLoc.x - startDragLoc.x);
            break;

        case Cursor.W_RESIZE_CURSOR:
            resizedBounds.width = startWinBounds.width - xDiff;
            resizedBounds.x = startWinBounds.x + xDiff;
            break;

        case Cursor.N_RESIZE_CURSOR:
            resizedBounds.height = startWinBounds.height - yDiff;
            resizedBounds.y = startWinBounds.y + yDiff;
            break;

        case Cursor.S_RESIZE_CURSOR:
            resizedBounds.height = startWinBounds.height + (dragLoc.y - startDragLoc.y);
            break;

        case Cursor.NE_RESIZE_CURSOR:
            resize(resizedBounds, 0, yDiff, xDiff, -yDiff, minSize);
            break;

        case Cursor.NW_RESIZE_CURSOR:
            resize(resizedBounds, xDiff, yDiff, -xDiff, -yDiff, minSize);
            break;

        case Cursor.SE_RESIZE_CURSOR:
            resize(resizedBounds, 0, 0, xDiff, yDiff, minSize);
            break;

        case Cursor.SW_RESIZE_CURSOR:
            resize(resizedBounds, xDiff, 0, -xDiff, yDiff, minSize);
            break;

        default:
            System.out.println("unknown cursor type : " + cursorType);
            //throw new IllegalArgumentException("Unknown/illegal cursor type: " + cursorType);  //NOI18N
            break;
    }
    return resizedBounds;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:50,代碼來源:DecorationUtils.java

示例3: mouseMoved

public void mouseMoved(Point point) {
    synchronized (mouseLock) {
        if (mousePressedPosition != null)
            mouseDragPosition = point;

        Bounds bounds = getSelected(point);
        int cursorType;
        if (bounds == null)
            cursorType = Cursor.DEFAULT_CURSOR;
        else {
            cursorType = Cursor.MOVE_CURSOR;
        }
        if (selection.getBounds().length == 1) {

            boolean resizableX = selection.isResizeableX(diagram);
            boolean resizableY = selection.isResizeableY(diagram);

            if ((resizableX) && (isRightMove(point)))
                cursorType = Cursor.E_RESIZE_CURSOR;
            else if ((resizableX) && (isLeftMove(point)))
                cursorType = Cursor.W_RESIZE_CURSOR;
            else if ((resizableY) && (isTopMove(point)))
                cursorType = Cursor.N_RESIZE_CURSOR;
            else if ((resizableY) && (isBottomMove(point)))
                cursorType = Cursor.S_RESIZE_CURSOR;
            else if ((resizableY) && (resizableX)
                    && (isRightBottomMove(point)))
                cursorType = Cursor.SE_RESIZE_CURSOR;
            else if ((resizableY) && (resizableX)
                    && (isLeftBottomMove(point)))
                cursorType = Cursor.SW_RESIZE_CURSOR;
            else if ((resizableY) && (resizableX)
                    && (isTopRightMove(point)))
                cursorType = Cursor.NE_RESIZE_CURSOR;
            else if ((resizableY) && (resizableX) && (isTopLeftMove(point)))
                cursorType = Cursor.NW_RESIZE_CURSOR;

        }

        if (this.cursorType != cursorType) {
            this.cursorType = cursorType;
            this.setCursor(new Cursor(cursorType));
        }

    }
    repaint();
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:47,代碼來源:GEFComponent.java


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