Package javafx.geometry

Examples of javafx.geometry.Rectangle2D


     */
    private void sizeReasonably(Stage stage, Node parent) {
      Window window = JuFxUtils.getWindow(parent);
     
      // Get the preferred size of the stage
      Rectangle2D prefRect = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
      Rectangle2D parentBounds = window != null
        ? new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight())
        : null;

      Rectangle2D rect = this.getReasonableSize(prefRect, parentBounds);
     
      stage.setX(rect.getMinX());
      stage.setY(rect.getMinY());
      stage.setWidth(rect.getWidth());
      stage.setHeight(rect.getHeight());
    }
View Full Code Here


   * @param rect
   * @param point
   * @return
   */
  public static Rectangle2D center(Rectangle2D rect, Point2D point) {
    Rectangle2D r = new Rectangle2D(
        point.x - rect.getWidth() / 2,
        point.y - rect.getHeight() / 2,
        rect.getWidth(),
        rect.getHeight());
   
View Full Code Here

   */
  public static Rectangle2D moveToBounds(Rectangle2D rect1, Rectangle2D rect2) {
    double newX = GeoFx.moveToBounds(rect1.getMinX(), rect1.getMaxX(), rect2.getMinX(), rect2.getMaxX());
    double newY = GeoFx.moveToBounds(rect1.getMinY(), rect1.getMaxY(), rect2.getMinY(), rect2.getMaxY());
   
    return new Rectangle2D(newX, newY, rect1.getWidth(), rect1.getHeight());
  }
View Full Code Here

import com.sun.javafx.geom.Point2D;

public class GeoFxTest {
  @Test
  public void centerRectangle2D() {
    Rectangle2D r1 = new Rectangle2D(0, 0, 5, 10);
    Rectangle2D r2 = GeoFx.center(r1, new Point2D(10, 10));
   
    Assert.assertEquals(new Rectangle2D(7.5, 5, 5, 10), r2);
  }
View Full Code Here

    Assert.assertEquals(new Rectangle2D(7.5, 5, 5, 10), r2);
  }
 
  @Test
  public void centerPoint2D() {
    Rectangle2D r1 = new Rectangle2D(0, 0, 5, 10);
   
    Assert.assertEquals(new Point2D(2.5f, 5f), GeoFx.center(r1));
  }
View Full Code Here

    Assert.assertEquals(new Point2D(2.5f, 5f), GeoFx.center(r1));
  }
 
  @Test
  public void moveToBounds() {
    Rectangle2D rect = new Rectangle2D(0, 0, 1, 1);
   
    // Move right, up
    Rectangle2D r1 = new Rectangle2D(1, 1, 7, 9);
    Assert.assertEquals(new Rectangle2D(1, 1, 1, 1), GeoFx.moveToBounds(rect, r1));
   
    // Move left, down
    Rectangle2D r2 = new Rectangle2D(-2, -2, 2, 2);
    Assert.assertEquals(new Rectangle2D(-1, -1, 1, 1), GeoFx.moveToBounds(rect, r2));

    // Center
    Rectangle2D r3 = new Rectangle2D(0, 0, 0.5, 0.5);
    Assert.assertEquals(new Rectangle2D(-0.25, -0.25, 1, 1), GeoFx.moveToBounds(rect, r3));
   
    // No move
    Rectangle2D r4 = new Rectangle2D(-1, -1, 2, 2);
    Assert.assertEquals(rect, GeoFx.moveToBounds(rect, r4));
  }
View Full Code Here

    introScene = new Scene(new GameSelection(this), 640, 400);
    introScene.getStylesheets().add("net/sertik/genesia/default.css");

    stage.setScene(introScene);

    Rectangle2D screenVisualBounds = Screen.getPrimary().getVisualBounds();
    screenWidth = screenVisualBounds.getWidth();
    screenHeight = screenVisualBounds.getHeight();

    mainScene = new Scene(new Group(), screenWidth, screenHeight);

    stage.show();
View Full Code Here

        setVisible(false);
        getChildren().removeAll(blurView, colorGlass);

        SnapshotParameters parameters = new SnapshotParameters();
        Point2D startPointInScene = localToScene(0, 0);
        Rectangle2D toPaint = new Rectangle2D(startPointInScene.getX(), startPointInScene.getY(), getLayoutBounds().getWidth(), getLayoutBounds().getHeight());
        parameters.setViewport(toPaint);
        WritableImage image = new WritableImage((int) toPaint.getWidth(), (int) toPaint.getHeight());
        image = getScene().getRoot().snapshot(parameters, image);
        blurView.setImage(image);
        getChildren().addAll(blurView, colorGlass);
        colorGlass.toBack();
        blurView.toBack();
View Full Code Here

    //---------------------------------------------------------------------------------------------
    // PRIVATE METHODS.
    //---------------------------------------------------------------------------------------------

    private Image captureScreenToImage(Screen screen) {
        Rectangle2D region = screen.getBounds();
        return baseRobot.captureRegion(region);
    }
View Full Code Here

        Scene scene = new FxDecorateScene(root, stage);

        scene.getStylesheets().add("/styles/Styles.css");
        scene.getStylesheets().add("/styles/Undecorator.css");
        Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
        stage.setWidth(bounds.getWidth());
        stage.setHeight(bounds.getHeight());
        stage.setX(0);
        stage.setY(0);
        stage.setTitle("AsciidocFX");
        stage.getIcons().add(new Image(getClass().getResourceAsStream("/public/favicon.ico")));
View Full Code Here

TOP

Related Classes of javafx.geometry.Rectangle2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.