Skip to content

Commit 0b60d6b

Browse files
committed
integrate AndExpression in overlaps
1 parent 0a70d88 commit 0b60d6b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,15 @@ public Scalar getBottom() {
165165
return getCorner().getY();
166166
}
167167

168-
public boolean overlaps(UIElement other, Context context) {
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);
168+
public Expression<Boolean> overlaps(UIElement other) {
169+
return Expression.and(
170+
Expression.and(
171+
Condition.lessThan(other.end(RIGHT)).applyTo(end(LEFT)),
172+
Condition.lessThan(end(RIGHT)).applyTo(other.end(LEFT))),
173+
Expression.and(
174+
Condition.lessThan(other.end(DOWN)).applyTo(end(UP)),
175+
Condition.lessThan(end(DOWN)).applyTo(other.end(UP)))
176+
);
173177
}
174178

175179
public boolean notOverlaps(UIElement other, Context context) {
@@ -346,7 +350,7 @@ public <V extends MetricSpace<V>> void validateSuccessor(ExtendGiving<V> directi
346350

347351

348352
public void validateOverlappingWithElement(UIElement element, Context context) {
349-
if (!overlaps(element, context)) {
353+
if (!overlaps(element).evaluateIn(context, DOWN)) {
350354
context.add(String.format("Element %s is not overlapped with element %s but should be",
351355
getQuotedName(),
352356
element.getQuotedName()));

0 commit comments

Comments
 (0)