modules/graphics/src/test/java/javafx/scene/layout/RegionPickTest.java
Print this page
*** 25,34 ****
--- 25,35 ----
package javafx.scene.layout;
import javafx.geometry.Insets;
import javafx.scene.paint.Color;
+ import javafx.scene.shape.Circle;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
*** 510,516 ****
* positionShape / scaleShape variants to make sure we are always picking *
* based on the perceived (rendered) shape *
* *
*************************************************************************/
! // TODO implement along with fix for RT-27775
}
--- 511,596 ----
* positionShape / scaleShape variants to make sure we are always picking *
* based on the perceived (rendered) shape *
* *
*************************************************************************/
! @Test public void pickingSimpleShape() {
! region.setPickOnBounds(false);
! region.setScaleShape(false);
! region.setCenterShape(false);
! region.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
!
! region.setShape(new Circle(50, 50, 30));
!
! assertFalse(region.contains(X + 50, Y + 81));
! assertFalse(region.contains(X + 50, Y + 19));
! assertFalse(region.contains(X + 81, Y + 50));
! assertFalse(region.contains(X + 19, Y + 50));
! assertTrue(region.contains(X + 50, Y + 79));
! assertTrue(region.contains(X + 50, Y + 21));
! assertTrue(region.contains(X + 79, Y + 50));
! assertTrue(region.contains(X + 21, Y + 50));
!
! }
!
! @Test public void pickingCenteredShape() {
! region.setPickOnBounds(false);
! region.setScaleShape(false);
! region.setCenterShape(true);
! region.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
!
! region.setShape(new Circle(0, 0, 30));
!
! assertFalse(region.contains(X + 50, Y + 81));
! assertFalse(region.contains(X + 50, Y + 19));
! assertFalse(region.contains(X + 81, Y + 50));
! assertFalse(region.contains(X + 19, Y + 50));
! assertTrue(region.contains(X + 50, Y + 79));
! assertTrue(region.contains(X + 50, Y + 21));
! assertTrue(region.contains(X + 79, Y + 50));
! assertTrue(region.contains(X + 21, Y + 50));
!
! }
!
! @Test public void pickingScaledShape() {
! region.setPickOnBounds(false);
! region.setScaleShape(true);
! region.setCenterShape(false);
! region.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
!
! region.setShape(new Circle(0, 0, 30));
!
! assertFalse(region.contains(X, Y + HEIGHT / 2 + 1));
! assertFalse(region.contains(X, Y - HEIGHT / 2 - 1));
! assertFalse(region.contains(X + WIDTH / 2 + 1, Y));
! assertFalse(region.contains(X - WIDTH / 2 - 1, Y));
!
! assertTrue(region.contains(X + 1, Y + HEIGHT / 2 - 1));
! assertTrue(region.contains(X + WIDTH / 2 - 1, Y));
!
! // Even though the shape is there, these points are outside of region's bounds, so it wouldn't be really picked.
! assertFalse(region.contains(X + 1, Y - HEIGHT / 2 + 1));
! assertFalse(region.contains(X - WIDTH / 2 + 1, Y));
!
! }
!
! @Test public void pickingScaledAndCenteredShape() {
! region.setPickOnBounds(false);
! region.setScaleShape(true);
! region.setCenterShape(true);
! region.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
!
! region.setShape(new Circle(0, 0, 30));
!
! assertFalse(region.contains(X + WIDTH / 2, Y + HEIGHT + 1));
! assertFalse(region.contains(X + WIDTH / 2, Y - 1));
! assertFalse(region.contains(X + WIDTH + 1, Y + HEIGHT / 2));
! assertFalse(region.contains(X - 1, Y + HEIGHT / 2));
!
! assertTrue(region.contains(X + WIDTH / 2, Y + HEIGHT - 1));
! assertTrue(region.contains(X + WIDTH / 2, Y + 1));
! assertTrue(region.contains(X + WIDTH - 1, Y + HEIGHT / 2));
! assertTrue(region.contains(X + 1, Y + HEIGHT / 2));
!
! }
!
}