javafx.geometry.Rectangle2D r = new javafx.geometry.Rectangle2D(0, 0, 1, 1); ObservableList<Screen> screens = Screen.getScreensForRectangle(r); if (screens != null && screens.size() > 0) { javafx.geometry.Rectangle2D rc = screens.get(0).getBounds(); }
); ImageView background = new ImageView(backgroundImage); Rectangle2D viewport = new Rectangle2D(0, 0, W, H); background.setViewport(viewport);
imageView.setViewport( new Rectangle2D(500, 320, 420, 300) );
@FXML private Button btn1; Image img = new Image("/images/2013-07-14_14-40-17_89.jpg"); ImageView iv = new ImageView(); iv.setImage(img); Rectangle2D viewportRect = new Rectangle2D(100, 250, 50, 50); iv.setViewport(viewportRect); btn1.setGraphic(iv);
/** * @return app bounds as set by GameSettings * @apiNote equivalent to new Rectangle2D(0, 0, getWidth(), getHeight()) */ public final Rectangle2D getAppBounds() { return new Rectangle2D(0, 0, getWidth(), getHeight()); }
Image image = new Image("flower.png"); ImageView view = new ImageView(); view.setImage(image); Rectangle2D viewportRect = new Rectangle2D(40, 35, 110, 110); view.setViewport(viewportRect);
/** * Creates a new rectangle with the specified {@code upperLeft} corner and the specified {@code width} and * {@code height}. * * @param upperLeft * one corner * @param width * the new rectangle's width * @param height * the new rectangle's height * @return the {@link Rectangle2D} which is defined by the specified upper left corner and width and height */ public static Rectangle2D forUpperLeftCornerAndSize(Point2D upperLeft, double width, double height) { return new Rectangle2D(upperLeft.getX(), upperLeft.getY(), width, height); }
public boolean animateBoundsChange(Node node, int x, int y, int width, int height) { if (!isNodeAnimated(node)) return false; getAnimator().animate(node, new Rectangle2D(x, y, width, height)); return true; }
protected void handleAsList(List<?> list) { if (list.isEmpty()) { super.setValueInternal(null); return; } switch (list.size()) { case 4: double x = parseValue(list.get(0)); double y = parseValue(list.get(1)); double w = parseValue(list.get(2)); double h = parseValue(list.get(3)); super.setValueInternal(new Rectangle2D(x, y, w, h)); break; default: throw illegalValue(list, Rectangle2D.class); } }
/** * Returns a rectangle with the same coordinates as the specified bounds. * * @param bounds * the {@link Bounds} for which the rectangle will be created * @return a {@link Rectangle2D} with the same minX-, minY-, maxX- and maxY-coordiantes as the specified bounds */ public static Rectangle2D fromBounds(Bounds bounds) { return new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); }
private Rectangle2D getComponentArea( Region childRegion ) { double xStart = getXShift( childRegion, referenceNode ); double yStart = getYShift( childRegion, referenceNode ); return new Rectangle2D( xStart, yStart, childRegion.getWidth(), childRegion.getHeight() ); } }
/** * get SceneBounds * * @param screenPercent * @return the scene bounds */ public Rectangle2D getSceneBounds(int screenPercent, int xDiv, int yDiv) { double sceneWidth = getScreenWidth() * screenPercent / 100.0; double sceneHeight = getScreenHeight() * screenPercent / 100.0; double x = (getScreenWidth() - sceneWidth) / xDiv; double y = (getScreenHeight() - sceneHeight) / yDiv; Rectangle2D sceneBounds = new Rectangle2D(x, y, sceneWidth, sceneHeight); return sceneBounds; }
protected void handleAsMap(Map<?, ?> map) { if (map.isEmpty()) { super.setValueInternal(null); return; } double x = getMapValue(map, "x", 0); double y = getMapValue(map, "y", 0); double w = getMapValue(map, "width", 0); double h = getMapValue(map, "height", 0); super.setValueInternal(new Rectangle2D(x, y, w, h)); }
private static Rectangle2D getBounds(Node node) { Bounds lBounds = node.getLayoutBounds(); return new Rectangle2D( node.getLayoutX(), node.getLayoutY(), lBounds.getWidth(), lBounds.getHeight() ); }
/** * * @return the bounds of the current selection according to the {@link #selectionAreaBoundaryProperty() * selectionAreaBoundary}. */ private Rectangle2D getSelectionBounds() { Boundary boundary = getSelectionAreaBoundary(); switch (boundary) { case CONTROL: return new Rectangle2D(0, 0, getWidth(), getHeight()); case NODE: return Rectangles2D.fromBounds(getNode().getBoundsInParent()); default: throw new IllegalArgumentException("The boundary '" + boundary + "' is not fully implemented yet."); //$NON-NLS-1$ //$NON-NLS-2$ } }
/** * Returns the plot area in the reference's coordinate space. */ public Rectangle2D getPlotArea() { Axis<?> xAxis = chart.getXAxis(); Axis<?> yAxis = chart.getYAxis(); double xStart = getXShift( xAxis, referenceNode ); double yStart = getYShift( yAxis, referenceNode ); //If the direct method to get the width (which is based on its Node dimensions) is not found to //be appropriate, an alternative method is commented. // double width = xAxis.getDisplayPosition( xAxis.toRealValue( xAxis.getUpperBound() ) ); double width = xAxis.getWidth(); // double height = yAxis.getDisplayPosition( yAxis.toRealValue( yAxis.getLowerBound() ) ); double height = yAxis.getHeight(); return new Rectangle2D( xStart, yStart, width, height ); }
public static Image fitInDimensionAndCutEdges(Image image, double width, double heigth) { Dimension2D newImageDimension = UiUtilities.shouldFitIn(image.getWidth(), image.getHeight(), width, heigth); Image resizedImage = fastResize(image, newImageDimension); return clipImage(resizedImage, new Rectangle2D((resizedImage.getWidth() - width) / 2, (resizedImage.getHeight() - heigth) / 2, width, heigth)); } }
/** * Resizes the current {@link SnapshotView#selectionProperty() selection} from the control's to the node's * bounds */ private void resizeSelectionFromControlToNode() { if (getNode() == null) { setSelection(null); } else { // transform the selection from the control's to the node's bounds Rectangle2D controlBounds = new Rectangle2D(0, 0, getWidth(), getHeight()); Rectangle2D nodeBounds = Rectangles2D.fromBounds(getNode().getBoundsInParent()); resizeSelectionToNewBounds(controlBounds, nodeBounds); } }
/** * Resizes the current {@link SnapshotView#selectionProperty() selection} from the node's to the control's * bounds. */ private void resizeSelectionFromNodeToControl() { if (getNode() == null) { setSelection(null); } else { // transform the selection from the control's to the node's bounds Rectangle2D controlBounds = new Rectangle2D(0, 0, getWidth(), getHeight()); Rectangle2D nodeBounds = Rectangles2D.fromBounds(getNode().getBoundsInParent()); resizeSelectionToNewBounds(nodeBounds, controlBounds); } }
Pane testImage2(Pane pane) { Pane inner = new Pane(); inner.prefWidthProperty().bind(pane.widthProperty()); inner.prefHeightProperty().bind(pane.heightProperty()); pane.getChildren().add(inner); SVGPath texture = new SVGPath(); texture.setStroke(Color.GREEN); texture.setStrokeWidth(2.5); texture.setFill(Color.TRANSPARENT); texture.setContent("M 10 10 C 40 10 10 70 70 20"); SnapshotParameters params = new SnapshotParameters(); params.setViewport(new Rectangle2D(-5, -5, 70, 50)); Image image = texture.snapshot(params, null); Paint paint = new ImagePattern(image, 5,5, 20, 20, false); inner.setBackground(new Background(new BackgroundFill(paint, new CornerRadii(0), new Insets(inset)))); return pane; }