@Test
  public void keyTriggerSetsCoordinatesToFocusOwner() {
    Rectangle rect = new Rectangle(100, 100);
    rect.setTranslateX(100);
    rect.setTranslateY(100);
    Group root = new Group(rect);
    Scene scene = new Scene(root);
    Stage stage = new Stage();
    stage.setScene(scene);
    stage.show();
    rect.requestFocus();

    rect.setOnContextMenuRequested(
        event -> {
          Assert.assertEquals(25.0, event.getX(), 0.0001);
          Assert.assertEquals(125, event.getSceneX(), 0.0001);
          Assert.assertEquals(225, event.getScreenX(), 0.0001);
          Assert.assertEquals(50.0, event.getY(), 0.0001);
          Assert.assertEquals(150, event.getSceneY(), 0.0001);
          Assert.assertEquals(250, event.getScreenY(), 0.0001);
          assertTrue(event.isKeyboardTrigger());
        });

    ((StubScene) scene.impl_getPeer()).getListener().menuEvent(101, 102, 201, 202, true);
  }
  @Test
  public void shouldCompute3dCoordinates() {
    Rectangle rect = new Rectangle(100, 100);
    rect.setTranslateX(100);
    rect.setTranslateY(100);
    rect.setTranslateZ(50);
    Group root = new Group(rect, new Rectangle(0, 0));
    Scene scene = new Scene(root);
    Stage stage = new Stage();
    stage.setScene(scene);
    stage.show();
    rect.requestFocus();

    rect.setOnContextMenuRequested(
        event -> {
          Assert.assertEquals(1.0, event.getX(), 0.0001);
          Assert.assertEquals(101, event.getSceneX(), 0.0001);
          Assert.assertEquals(201, event.getScreenX(), 0.0001);
          Assert.assertEquals(2.0, event.getY(), 0.0001);
          Assert.assertEquals(102, event.getSceneY(), 0.0001);
          Assert.assertEquals(202, event.getScreenY(), 0.0001);
          Assert.assertEquals(0, event.getZ(), 0.0001);
          assertFalse(event.isKeyboardTrigger());
        });

    scene.setOnContextMenuRequested(
        event -> {
          Assert.assertEquals(101.0, event.getX(), 0.0001);
          Assert.assertEquals(101, event.getSceneX(), 0.0001);
          Assert.assertEquals(201, event.getScreenX(), 0.0001);
          Assert.assertEquals(102.0, event.getY(), 0.0001);
          Assert.assertEquals(102, event.getSceneY(), 0.0001);
          Assert.assertEquals(202, event.getScreenY(), 0.0001);
          Assert.assertEquals(50, event.getZ(), 0.0001);
          assertFalse(event.isKeyboardTrigger());
        });

    ((StubScene) scene.impl_getPeer()).getListener().menuEvent(101, 102, 201, 202, false);
  }
  @Test
  public void pickResultIsFromEventCoordinates() {
    final Rectangle rect = new Rectangle(100, 100);
    rect.setTranslateX(100);
    rect.setTranslateY(100);
    Group root = new Group(rect);
    Scene scene = new Scene(root);
    Stage stage = new Stage();
    stage.setScene(scene);
    stage.show();
    rect.requestFocus();

    rect.setOnContextMenuRequested(
        event -> {
          PickResult pickRes = event.getPickResult();
          assertNotNull(pickRes);
          assertSame(rect, pickRes.getIntersectedNode());
          assertEquals(25, pickRes.getIntersectedPoint().getX(), 0.00001);
          assertEquals(50, pickRes.getIntersectedPoint().getY(), 0.00001);
          assertEquals(0, pickRes.getIntersectedPoint().getZ(), 0.00001);
        });

    ((StubScene) scene.impl_getPeer()).getListener().menuEvent(1330, 1350, 1340, 1360, true);
  }