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