try { Rectangle2D bounds = Screen.getScreens().get(0).getBounds(); width = bounds.getWidth() / 2.5; height = bounds.getHeight() / 1.35; }catch (Exception e){ }
maximizedBox = new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
private void defaultStageStatus() { Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds(); stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2); stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 4); stage.setMaximized(true); }
public HelpPopup(Region content) { getStyleClass().setAll("pdfsam-help-popup"); setAutoHide(true); setHideOnEscape(true); setAutoFix(true); this.content = content; this.content.setMaxWidth(Screen.getPrimary().getVisualBounds().getWidth() / 3); }
public static double getScreenWidth() { return Screen.getPrimary().getVisualBounds().getWidth(); }
/** * Creates a new change strategy which moves the specified rectangle within the specified bounds defined by the * rectangle from {@code (0, 0)} to {@code (maxX, maxY)}. * * @param previous * the previous rectangle this move is based on * @param maxX * the maximal x-coordinate of the right edge of the created rectangles; must be greater than or equal to * the previous rectangle's width * @param maxY * the maximal y-coordinate of the lower edge of the created rectangles; must be greater than or equal to * the previous rectangle's height */ public MoveChangeStrategy(Rectangle2D previous, double maxX, double maxY) { super(previous, false, 0); if (maxX < previous.getWidth()) { throw new IllegalArgumentException( "The specified maximal x-coordinate must be greater than or equal to the previous rectangle's width."); //$NON-NLS-1$ } if (maxY < previous.getHeight()) { throw new IllegalArgumentException( "The specified maximal y-coordinate must be greater than or equal to the previous rectangle's height."); //$NON-NLS-1$ } bounds = new Rectangle2D(0, 0, maxX, maxY); }
/** * Indicates whether the specified selection has the correct ratio (which depends on whether the ratio is even * {@link #selectionRatioFixedProperty() fixed}). * * @param selection * the selection to check as a {@link Rectangle2D} * @return {@code true} if the selection has the correct ratio. */ private boolean hasCorrectRatio(Rectangle2D selection) { if (!isSelectionRatioFixed()) { return true; } double ratio = selection.getWidth() / selection.getHeight(); // compute the divergence relative to the fixed selection ratio double ratioDivergence = Math.abs(1 - ratio / getFixedSelectionRatio()); return ratioDivergence <= MAX_SELECTION_RATIO_DIVERGENCE; }
public static Image clipImage(Image image, Rectangle2D clip) { WritableImage clippedImage = new WritableImage((int) clip.getWidth(), (int) clip.getHeight()); int[] rgbaValues = getRGB(image, (int) clip.getMinX(), (int) clip.getMinY(), (int) clip.getWidth(), (int) clip.getHeight()); setRGB(clippedImage, rgbaValues); return clippedImage; }
/** * Calculates the location of a window so that it will be centered on the screen. * * @param window the window * @return the location (top left corner) */ public Point2D determineCenteredLocation(Window window) { Rectangle2D screenSize = Screen.getPrimary().getVisualBounds(); // align sizes (for computation below) double windowWidth = window.getWidth(); double windowHeight = window.getHeight(); if (window.getWidth() > screenSize.getWidth()) { windowWidth = screenSize.getWidth(); } if (windowHeight > screenSize.getHeight()) { windowHeight = screenSize.getHeight(); } return new Point2D((screenSize.getWidth() - windowWidth) / 2.0, (screenSize.getHeight() - windowHeight) / 2.0); }
@Override public String getAsText() { if (null == getValue()) return null; Rectangle2D r = (Rectangle2D) getValue(); return r.getMinX() + ", " + r.getMinY() + ", " + r.getWidth() + ", " + r.getHeight(); }
/** * Indicates whether the specified selection has only finite values (e.g. width and height). * * @param selection * the selection as a {@link Rectangle2D} * @return {@code true} if the selection has only finite values. */ private static boolean valuesFinite(Rectangle2D selection) { return Double.isFinite(selection.getMinX()) && Double.isFinite(selection.getMinY()) && Double.isFinite(selection.getWidth()) && Double.isFinite(selection.getHeight()); }
public Node createReplacement(Node node) { Rectangle2D b = getBounds(node); Node replNode = new ImageView(node.snapshot(new SnapshotParameters(), null)); replacedNodeMap.put(node, replNode); replNode.setUserData(node); replNode.setManaged(false); replNode.setId(ANIM_REPLACE_ID); replNode.resizeRelocate(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight()); return replNode; }
/** * Restore the window to original size */ protected void restore() { if (!isLightweight()) { if (this.backupWindowBounds != null) { Stage stage = getStage(); stage.setX(this.backupWindowBounds.getMinX()); stage.setY(this.backupWindowBounds.getMinY()); stage.setWidth(this.backupWindowBounds.getWidth()); stage.setHeight(this.backupWindowBounds.getHeight()); stage.setMaximized(false); this.backupWindowBounds = null; } } }
/** * Restore the window to original size */ protected void restore() { if (!isLightweight()) { if (this.backupWindowBounds != null) { Stage stage = getStage(); stage.setX(this.backupWindowBounds.getMinX()); stage.setY(this.backupWindowBounds.getMinY()); stage.setWidth(this.backupWindowBounds.getWidth()); stage.setHeight(this.backupWindowBounds.getHeight()); stage.setMaximized(false); this.backupWindowBounds = null; } } }
/** * Updates the position and size of {@link #selectedArea} (and by binding that of {@link #unselectedArea}) to a * changed selection. */ private void updateSelection() { boolean showSelection = getSkinnable().hasSelection() && getSkinnable().isSelectionActive(); if (showSelection) { // the selection can be properly displayed Rectangle2D selection = getSkinnable().getSelection(); setSelection(selection.getMinX(), selection.getMinY(), selection.getWidth(), selection.getHeight()); } else { // in this case the selection areas are invisible, // so the only thing left to do is to make sure their coordinates are not all over the place // (this is not strictly necessary but makes the skin's state cleaner) setSelection(0, 0, 0, 0); } }
@Override public void start(Stage stage) { super.start(stage); stage.setTitle(title); Rectangle2D sceneBounds=super.getSceneBounds(screenPercent,divX,divY); setScene(new Scene(region, sceneBounds.getWidth(), sceneBounds.getHeight())); stage.setScene(getScene()); stage.setX(sceneBounds.getMinX()); stage.setY(sceneBounds.getMinY()); stage.show(); }
private void _resize(final double width, final double height) { Window window = container.getScene().getWindow(); // size difference between root node and window depends on OS and Decorations double diffY = window.getHeight() - container.getHeight(); double diffX = window.getWidth() - container.getWidth(); webView.setMaxWidth(width); webView.setMaxHeight(height); webView.setMinWidth(width); webView.setMinHeight(height); javafx.geometry.Rectangle2D screenBounds = Screen.getPrimary().getBounds(); double scaleX = screenBounds.getWidth() / ( width + diffX ); double scaleY = screenBounds.getHeight() / ( height + diffY ); // calculate scale factor if too big for device, the .1 adds some padding double scale = Math.min(Math.min(scaleX, scaleY), 1.1) - .1; webView.setScaleX(scale); webView.setScaleY(scale); container.getScene().setRoot(new Group()); ((Stage)window).setScene(new Scene(container, width * scale, height * scale)); }
/** * setup the GUI * * @param stage */ private void setup(Stage stage) { stage.setTitle(title); Rectangle2D sceneBounds = super.getSceneBounds(screenPercent, divX, divY); dropTarget = new DropTarget(); setScene( new Scene(dropTarget, sceneBounds.getWidth(), sceneBounds.getHeight())); stage.setScene(getScene()); scene.setFill(Color.LIGHTGRAY); stage.setX(super.getScreenWidth() - sceneBounds.getMinX()); stage.setY(super.getScreenHeight() - sceneBounds.getMinY()); stage.show(); }
/** * Maximize the window */ protected void maximize() { // We are bound to the stage if (!isLightweight()) { Stage stage = getStage(); final double stageY = stage.getY(); final Screen screen = Screen.getScreensForRectangle(stage.getX(), stageY, 1, 1).get(0); this.backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); final double newStageY = screen.getVisualBounds().getMinY(); stage.setX(screen.getVisualBounds().getMinX()); stage.setY(newStageY); stage.setWidth(screen.getVisualBounds().getWidth()); stage.setHeight(screen.getVisualBounds().getHeight()); getStyleClass().add("window-maximized"); //$NON-NLS-1$ // stage.setMaximized(true); this.maximized.set(true); } else { // We are embedded into a container do nothing } }
/** * Maximize and ajust the window to screen size. */ public void maximize() { Stage stage = undecorator.getStage(); ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); Screen screen = screensForRectangle.get(0); Rectangle2D visualBounds = screen.getVisualBounds(); // save bounds before maximizing in order to restore later savedBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); undecorator.setShadow(false); // effectivly maximize stage.setX(visualBounds.getMinX()); stage.setY(visualBounds.getMinY()); stage.setWidth(visualBounds.getWidth()); stage.setHeight(visualBounds.getHeight()); maximized = true; }