Skip to content

Commit 9484c6a

Browse files
committed
Add Rect overlap method
1 parent 0a4eb24 commit 9484c6a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

core/src/org/testar/monkey/alayer/Rect.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/***************************************************************************************************
22
*
3-
* Copyright (c) 2013, 2014, 2015, 2016, 2017 Universitat Politecnica de Valencia - www.upv.es
3+
* Copyright (c) 2013 - 2026 Universitat Politecnica de Valencia - www.upv.es
4+
* Copyright (c) 2018 - 2026 Open Universiteit - www.ou.nl
45
*
56
* Redistribution and use in source and binary forms, with or without
67
* modification, are permitted provided that the following conditions are met:
@@ -27,10 +28,6 @@
2728
* POSSIBILITY OF SUCH DAMAGE.
2829
*******************************************************************************************************/
2930

30-
31-
/**
32-
* @author Sebastian Bauersfeld
33-
*/
3431
package org.testar.monkey.alayer;
3532

3633
import org.testar.monkey.Assert;
@@ -47,6 +44,14 @@ public static boolean intersect(Rect r1, Rect r2) {
4744
r2.y() + r2.height() < r1.y());
4845
}
4946

47+
public static boolean overlap(Rect r1, Rect r2) {
48+
Assert.notNull(r1, r2);
49+
return !(r1.x() + r1.width() <= r2.x() ||
50+
r1.y() + r1.height() <= r2.y() ||
51+
r2.x() + r2.width() <= r1.x() ||
52+
r2.y() + r2.height() <= r1.y());
53+
}
54+
5055
public static boolean contains(Rect r1, Rect r2) {
5156
Assert.notNull(r1, r2);
5257
return r2.x() >= r1.x() && r2.x() + r2.width() <= r1.x() + r1.width() &&
@@ -102,7 +107,6 @@ public void paint(Canvas canvas, Pen pen) {
102107
canvas.rect(pen, x, y, width, height);
103108
}
104109

105-
// by urueda
106110
@Override
107111
public boolean equals(Object o){
108112
if (o == this) return true;

0 commit comments

Comments
 (0)