44import org .openqa .selenium .Point ;
55import org .openqa .selenium .WebElement ;
66
7- import java .util .function .Function ;
7+ import static net .itarray .automotion .internal .geometry .Direction .DOWN ;
8+ import static net .itarray .automotion .internal .geometry .Direction .RIGHT ;
89
910public class Rectangle {
1011 private final Vector origin ;
1112 private final Vector corner ;
1213
13- public static final ExtendGiving <Vector > ORIGIN_CORNER = new ExtendGiving <Vector >() {
14- @ Override
15- public String extendName () {
16- return "size" ;
17- }
18-
19- @ Override
20- public String beginName () {
21- return "top left" ;
22- }
23-
24- @ Override
25- public String endName () {
26- return "bottom right" ;
27- }
28-
29- @ Override
30- public Vector begin (Rectangle rectangle ) {
31- return rectangle .getOrigin ();
32- }
33-
34- @ Override
35- public Vector end (Rectangle rectangle ) {
36- return rectangle .getCorner ();
37- }
38-
39- @ Override
40- public Function <Vector , Vector > transform () {
41- return v -> v ;
42- }
43- };
44-
45-
14+ public static final ExtendGiving <Vector > ORIGIN_CORNER = new VectorExtendGiving (RIGHT , DOWN );
4615
4716 public static Rectangle rectangle (WebElement webElement ) {
4817 Point location = webElement .getLocation ();
@@ -77,7 +46,7 @@ public boolean intersects(Direction direction, Rectangle other) {
7746 }
7847
7948 public boolean intersects (Rectangle other ) {
80- return intersects (Direction . RIGHT , other ) && intersects (Direction . DOWN , other );
49+ return intersects (RIGHT , other ) && intersects (DOWN , other );
8150 }
8251
8352 public boolean contains (Direction direction , Rectangle other ) {
@@ -86,12 +55,13 @@ public boolean contains(Direction direction, Rectangle other) {
8655 }
8756
8857 public boolean contains (Rectangle other ) {
89- return contains (Direction . RIGHT , other ) && contains (Direction . DOWN , other );
58+ return contains (RIGHT , other ) && contains (DOWN , other );
9059 }
9160
9261 @ Override
9362 public String toString () {
9463 Vector extend = corner .minus (origin );
9564 return String .format ("[(%s,%s) - %sx%s]" , origin .getX (), origin .getY (), extend .getX (), extend .getY ());
9665 }
66+
9767}
0 commit comments