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

boundsInLocal not correct when a clip is set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx1.2
    • Fix Version/s: fx1.2
    • Component/s: javafx
    • Labels:
      None

      Description

      The following code sets a clip on a Rectangle. When the mouse is clicked in the Rectangle, the boundsInLocal, boundsInParent and layoutBounds values are printed:
      --------------------------------------------------------------------------
      import javafx.stage.Stage;
      import javafx.scene.Scene;

      import javafx.scene.layout.VBox;

      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;

      import javafx.scene.effect.DropShadow;

      Stage {
          title : "Bounds"
          scene: Scene {
              width: 200 height: 200
              content: [
                  VBox {
                      var r:Rectangle;
                      spacing: 10
                      content: [
                          r = Rectangle {
                              width: 100 height: 120 fill: Color.YELLOW
                              effect: DropShadow { width: 20 height: 20 }
                              clip: Rectangle {
                                       x: 20 y: 20 width: 40 height: 60
                                    }
                              //translateX: 20
                              onMousePressed: function(evt) {
                                  println("boundsInLocal: {r.boundsInLocal}");
                                  println("boundsInParent: {r.boundsInParent}");
                                  println("layoutBounds: {r.layoutBounds}");
                              }
                          }
                          Rectangle { width: 20 height: 30 fill: Color.GREEN }
                      ]
                  }
              ]
          }
      }

      ------------------------------------------------------------
      The result is the following:

      boundsInLocal: BoundingBox [minX = 0.0, minY=0.0, maxX=100.0, maxY=120.0,
      width=100.0, height=120.0]
      boundsInParent: BoundingBox [minX = 0.0, minY=0.0, maxX=100.0, maxY=120.0,
      width=100.0, height=120.0]
      layoutBounds: BoundingBox [minX = 0.0, minY=0.0, maxX=100.0, maxY=120.0,
      width=100.0, height=120.0]

      That seems wrong, because the clip should have reduced the local bounds of
      the Rectangle.

      Now uncomment the translateX: 20 line and repeat:

      boundsInLocal: BoundingBox [minX = 20.0, minY=20.0, maxX=60.0, maxY=80.0,
      width=40.0, height=60.0]
      boundsInParent: BoundingBox [minX = 40.0, minY=20.0, maxX=80.0, maxY=80.0,
      width=40.0, height=60.0]
      layoutBounds: BoundingBox [minX = 0.0, minY=0.0, maxX=100.0, maxY=120.0,
      width=100.0, height=120.0]

      That looks correct to me. It seems that if the origin is NOTmoved, the
      local bounds and the parent bounds are wrong.


        Attachments

          Activity

            People

            Assignee:
            kcr Kevin Rushforth
            Reporter:
            ktopleyjfx Kim Topley (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: