本文整理汇总了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);
}
示例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;
}
示例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);
}
}
}
}
}
}
示例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);
}