本文整理匯總了Java中java.awt.Cursor.W_RESIZE_CURSOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.W_RESIZE_CURSOR屬性的具體用法?Java Cursor.W_RESIZE_CURSOR怎麽用?Java Cursor.W_RESIZE_CURSOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.Cursor
的用法示例。
在下文中一共展示了Cursor.W_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;
}
示例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;
}
示例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();
}