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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 7u45
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
    • Environment:

      Windows 7
      Mac OS X 10.7.5 Lion

      Description

       
      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());

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported: