Java Code Examples for javafx.scene.Scene#getHeight()
The following examples show how to use
javafx.scene.Scene#getHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Overlay.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
protected void layout() { if (owner == null) owner = MainView.getRootContainer(); Scene rootScene = owner.getScene(); if (rootScene != null) { Window window = rootScene.getWindow(); double titleBarHeight = window.getHeight() - rootScene.getHeight(); if (Utilities.isWindows()) titleBarHeight -= 9; stage.setX(Math.round(window.getX() + (owner.getWidth() - stage.getWidth()) / 2)); if (type.animationType == AnimationType.SlideDownFromCenterTop) stage.setY(Math.round(window.getY() + titleBarHeight)); else stage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - stage.getHeight()) / 2)); } }
Example 2
Source File: Dm3270Context.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public void takeSnapShot(OutputStream output) { JavaFxRunnable worker = new JavaFxRunnable() { public void myWork() throws Exception { Scene scene = console.getConsoleScene(); WritableImage writableImage = new WritableImage((int)scene.getWidth(), (int)scene.getHeight()); scene.snapshot(writableImage); try { ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png", output); } catch (IOException ex) { log.error( "Snapshot failed with: ", ex ); } } }; Platform.runLater( worker ); worker.doWait(); }
Example 3
Source File: FX.java From FxDock with Apache License 2.0 | 5 votes |
/** returns window decoration insets */ public static Insets getDecorationInsets(Window w) { Scene s = w.getScene(); double left = s.getX(); double top = s.getY(); double right = w.getWidth() - s.getWidth() - left; double bottom = w.getHeight() - s.getHeight() - top; return new Insets(top, right, bottom, left); }
Example 4
Source File: DockTools.java From FxDock with Apache License 2.0 | 5 votes |
public static Insets getWindowInsets(Window w) { Scene s = w.getScene(); double left = s.getX(); double top = s.getY(); double right = w.getWidth() - s.getWidth() - left; double bottom = w.getHeight() - s.getHeight() - top; return new Insets(top, right, bottom, left); }
Example 5
Source File: ResizeHelper.java From Path-of-Leveling with MIT License | 4 votes |
@Override public void handle(MouseEvent mouseEvent) { EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType(); Scene scene = stage.getScene(); double mouseEventX = mouseEvent.getSceneX(); double mouseEventY = mouseEvent.getSceneY(); double sceneWidth = scene.getWidth(); double sceneHeight = scene.getHeight(); if (MouseEvent.MOUSE_MOVED.equals(mouseEventType)) { 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_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)) { scene.setCursor(Cursor.DEFAULT); } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) { startX = stage.getWidth() - mouseEventX; startY = stage.getHeight() - mouseEventY; } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) { if (!Cursor.DEFAULT.equals(cursorEvent)) { if (!Cursor.W_RESIZE.equals(cursorEvent) && !Cursor.E_RESIZE.equals(cursorEvent)) { double minHeight = stage.getMinHeight() > (border * 2) ? stage.getMinHeight() : (border * 2); double maxHeight = stage.getMaxHeight(); if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.N_RESIZE.equals(cursorEvent) || Cursor.NE_RESIZE.equals(cursorEvent)) { double newHeight = stage.getHeight() - (mouseEvent.getScreenY() - stage.getY()); if (newHeight >= minHeight && newHeight <= maxHeight) { stage.setHeight(newHeight); stage.setY(mouseEvent.getScreenY()); } else { newHeight = Math.min(Math.max(newHeight, minHeight), maxHeight); // y1 + h1 = y2 + h2 // y1 = y2 + h2 - h1 stage.setY(stage.getY() + stage.getHeight() - newHeight); stage.setHeight(newHeight); } } else { stage.setHeight(Math.min(Math.max(mouseEventY + startY, minHeight), maxHeight)); } } if (!Cursor.N_RESIZE.equals(cursorEvent) && !Cursor.S_RESIZE.equals(cursorEvent)) { double minWidth = stage.getMinWidth() > (border * 2) ? stage.getMinWidth() : (border * 2); double maxWidth = stage.getMaxWidth(); if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.W_RESIZE.equals(cursorEvent) || Cursor.SW_RESIZE.equals(cursorEvent)) { double newWidth = stage.getWidth() - (mouseEvent.getScreenX() - stage.getX()); if (newWidth >= minWidth && newWidth <= maxWidth) { stage.setWidth(newWidth); stage.setX(mouseEvent.getScreenX()); } else { newWidth = Math.min(Math.max(newWidth, minWidth), maxWidth); // x1 + w1 = x2 + w2 // x1 = x2 + w2 - w1 stage.setX(stage.getX() + stage.getWidth() - newWidth); stage.setWidth(newWidth); } } else { stage.setWidth(Math.min(Math.max(mouseEventX + startX, minWidth), maxWidth)); } } } } if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) { startScreenX = mouseEvent.getScreenX(); startScreenY = mouseEvent.getScreenY(); } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) { if (Cursor.DEFAULT.equals(cursorEvent) && !stage.isMaximized()) { stage.setX(stage.getX() + mouseEvent.getScreenX() - startScreenX); startScreenX = mouseEvent.getScreenX(); stage.setY(stage.getY() + mouseEvent.getScreenY() - startScreenY); startScreenY = mouseEvent.getScreenY(); } } }
Example 6
Source File: ResizeHelper.java From CustomStage with Apache License 2.0 | 4 votes |
@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)) { 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_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)) { scene.setCursor(Cursor.DEFAULT); } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) { startX = stage.getWidth() - mouseEventX; startY = stage.getHeight() - mouseEventY; } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) { if (!Cursor.DEFAULT.equals(cursorEvent)) { if (!Cursor.W_RESIZE.equals(cursorEvent) && !Cursor.E_RESIZE.equals(cursorEvent)) { double minHeight = stage.getMinHeight() > (border * 2) ? stage.getMinHeight() : (border * 2); if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.N_RESIZE.equals(cursorEvent) || Cursor.NE_RESIZE.equals(cursorEvent)) { if (stage.getHeight() > minHeight || mouseEventY < 0) { setStageHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight()); stage.setY(mouseEvent.getScreenY()); } } else { if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) { setStageHeight(mouseEventY + startY); } } } if (!Cursor.N_RESIZE.equals(cursorEvent) && !Cursor.S_RESIZE.equals(cursorEvent)) { double minWidth = stage.getMinWidth() > (border * 2) ? stage.getMinWidth() : (border * 2); if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.W_RESIZE.equals(cursorEvent) || Cursor.SW_RESIZE.equals(cursorEvent)) { if (stage.getWidth() > minWidth || mouseEventX < 0) { setStageWidth(stage.getX() - mouseEvent.getScreenX() + stage.getWidth()); stage.setX(mouseEvent.getScreenX()); } } else { if (stage.getWidth() > minWidth || mouseEventX + startX - stage.getWidth() > 0) { setStageWidth(mouseEventX + startX); } } } } } }
Example 7
Source File: ResizeHelper.java From ApkToolPlus with Apache License 2.0 | 4 votes |
@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); } } } } } }
Example 8
Source File: ResizeHelper.java From JavaFX-Chat with GNU General Public License v3.0 | 4 votes |
@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)) { 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_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)){ scene.setCursor(Cursor.DEFAULT); } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) { startX = stage.getWidth() - mouseEventX; startY = stage.getHeight() - mouseEventY; } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) { 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); } } } } } }