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

Node.getBoundsInParent returns incorrect bound when node transform has rotation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 9
    • 8u40
    • javafx

      Node.getBoundsInParent returns some very expected results when node has rotation applied. Here's a code snippet I created to reproduce the problem.

      The values of boundsBefore and boundsAfter should be the same but the height and width for boundsAfter is a much larger value while boundsAfter.depth remains 20. This seems related to the rotated axis, Z.

      Sample code (using Cube3D sample from netbean):

      public class Cube3D extends Application {

          @Override public void start(Stage primaryStage) throws Exception {

              Group root = new Group();
              root.setDepthTest(DepthTest.ENABLE);
              primaryStage.setResizable(false);
              primaryStage.setScene(new Scene(root, 400, 400, true));
              
              PerspectiveCamera camera = new PerspectiveCamera(true);
              camera.setFarClip(200);
              camera.getTransforms().addAll(new Rotate(-30, Rotate.X_AXIS), new Translate(0, 0, -100));
              primaryStage.getScene().setCamera(camera);
              
              Sphere sphere = new Sphere(10, 1000);
              sphere.setMaterial(new PhongMaterial(Color.ORANGE));
              root.getChildren().add(sphere);
              
              Bounds boundsBefore = sphere.getBoundsInParent();
              sphere.getTransforms().add(new Rotate(45, Rotate.Z_AXIS));
              Bounds boundsAfter = sphere.getBoundsInParent();

              primaryStage.show();
          }
      }


            kcr Kevin Rushforth
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: