Skip to content

Commit 6c03eb0

Browse files
committed
refactored (not)contains towards more expression like looking
1 parent 75b25d7 commit 6c03eb0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/net/itarray/automotion/internal/UIElement.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ public Scalar getBottom() {
166166
}
167167

168168
public boolean overlaps(UIElement other, Context context) {
169-
return Condition.lessThan(other.getRight()).isSatisfiedOn(getLeft(), context, RIGHT) &&
170-
Condition.lessThan(getRight()).isSatisfiedOn(other.getLeft(), context, RIGHT) &&
171-
Condition.lessThan(other.getBottom()).isSatisfiedOn(getTop(), context, DOWN) &&
172-
Condition.lessThan(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
169+
return Condition.lessThan(other.end(RIGHT)).applyTo(end(LEFT)).evaluateIn(context, RIGHT) &&
170+
Condition.lessThan(end(RIGHT)).applyTo(other.end(LEFT)).evaluateIn(context, RIGHT) &&
171+
Condition.lessThan(other.end(DOWN)).applyTo(end(UP)).evaluateIn(context, DOWN) &&
172+
Condition.lessThan(end(DOWN)).applyTo(other.end(UP)).evaluateIn(context, DOWN);
173173
}
174174

175175
public boolean notOverlaps(UIElement other, Context context) {
176-
return Condition.greaterOrEqualTo(other.getRight()).isSatisfiedOn(getLeft(), context, RIGHT) ||
177-
Condition.greaterOrEqualTo(getRight()).isSatisfiedOn(other.getLeft(), context, RIGHT) ||
178-
Condition.greaterOrEqualTo(other.getBottom()).isSatisfiedOn(getTop(), context, DOWN) ||
179-
Condition.greaterOrEqualTo(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
176+
return Condition.greaterOrEqualTo(other.end(RIGHT)).applyTo(end(LEFT)).evaluateIn(context, RIGHT) ||
177+
Condition.greaterOrEqualTo(end(RIGHT)).applyTo(other.end(LEFT)).evaluateIn(context, RIGHT) ||
178+
Condition.greaterOrEqualTo(other.end(DOWN)).applyTo(end(UP)).evaluateIn(context, DOWN) ||
179+
Condition.greaterOrEqualTo(end(DOWN)).applyTo(other.end(UP)).evaluateIn(context, DOWN);
180180
}
181181

182182
private <V extends MetricSpace<V>> Expression<V> offset(UIElement page, ExtendGiving<V> direction) {

0 commit comments

Comments
 (0)