Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090170

Cannot automatically re-size stage in accordance with image's aspect ratio.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 7u45
    • javafx
    • Windows 7
      Mac OS X 10.7.5 Lion

       
      Cannot dynamically resize stage(change width automatically when height is changed and vice versa) with an imageview inside a scene.

      // Stage Code.
                 
                  stage.setResizable(true);
                  Scene scene = new Scene(page);
                  stage.setScene(scene);
                  stage.initStyle(StageStyle.UTILITY);
                  stage.sizeToScene();
                  double aspectRatio=selectedImage.getWidth()/selectedImage.getHeight();
                  stage.minWidthProperty().bind(scene.heightProperty().multiply(aspectRatio));
                  stage.minHeightProperty().bind(scene.widthProperty().divide(aspectRatio));

      // ImageView code.

              Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();

              double[] returnHgtWdt = ISMUtil.maintainAspectRatioOfImage(image.getWidth(), image.getHeight(), primaryScreenBounds.getWidth(), primaryScreenBounds.getHeight()-50);

              setHeightWidthValue(returnHgtWdt[0], returnHgtWdt[1]);
              imageView.setPreserveRatio(true);
              imageView.setImage(image);
              imageView.fitHeightProperty().bind(stage.heightProperty());
              imageView.fitWidthProperty().bind(stage.widthProperty());

            ckyang Chien Yang (Inactive)
            mgargjfx Mohit Garg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: