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

Picking needs to take geometry-altering effects into account

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • fx1.2
    • javafx
    • None

      PIcking needs to take into account effects that alter the geometry of an object, such as the perspective effect. The following test program draws a black, filled rectangle that has a perspective effect applied. The red stroked rectangle shows the local bounds and the green stroked rectangle shows the original layout bounds. Both are correct. Picking is currently done on the original, unaltered geometry, which is not what an application would expect.

      import javafx.scene.*;
      import javafx.scene.effect.*;
      import javafx.scene.shape.*;
      import javafx.scene.input.*;
      import javafx.scene.paint.*;
      import java.lang.Math;

      var width = 200;
      var height = 200;
      var radius = width/2;
      var back = height/10;
      var t = 3.14 / 8;;

      var rect = Rectangle {
          x:10 y:10 width:100 height:100
          effect: PerspectiveTransform {
              ulx: radius - Math.sin(t)*radius uly: 0 - Math.cos(t)*back
              urx: radius + Math.sin(t)*radius ury: 0 + Math.cos(t)*back
              lrx: radius + Math.sin(t)*radius lry: height - Math.cos(t)*back
              llx: radius - Math.sin(t)*radius lly: height + Math.cos(t)*back
          }
          onMouseMoved:function(e:MouseEvent):Void {
              println(e);
          }
          onMousePressed:function(e:MouseEvent):Void {
              println(e);
          }
      }

      var localBounds = Rectangle {
          x: bind rect.boundsInLocal.minX
          y: bind rect.boundsInLocal.minY
          width: bind rect.boundsInLocal.width
          height: bind rect.boundsInLocal.height
          fill: null
          stroke: Color.RED
          strokeWidth: 3
      }

      var layoutBounds = Rectangle {
          x: bind rect.layoutBounds.minX
          y: bind rect.layoutBounds.minY
          width: bind rect.layoutBounds.width
          height: bind rect.layoutBounds.height
          fill: null
          stroke: Color.GREEN
          strokeWidth: 3
      }

      Scene {
          width: 600
          height: 450
          content: [ rect, localBounds, layoutBounds ]
      }

            Unassigned Unassigned
            kcr Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: