Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void validateElementsAreNotOverlapped(List<UIElement> elements) {
UIElement first = elements.get(firstIndex);
for (int secondIndex = firstIndex+1; secondIndex < elements.size(); secondIndex++) {
UIElement second = elements.get(secondIndex);
if (first.overlaps(second, context)) {
if (!first.notOverlaps(second, context)) {
context.add("Elements are overlapped");
context.draw(first);
break;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/net/itarray/automotion/internal/UIElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ public boolean overlaps(UIElement other, Context context) {
Condition.lessThan(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
}

public boolean notOverlaps(UIElement other, Context context) {
return Condition.greaterOrEqualTo(other.getRight()).isSatisfiedOn(getLeft(), context, RIGHT) ||
Condition.greaterOrEqualTo(getRight()).isSatisfiedOn(other.getLeft(), context, RIGHT) ||
Condition.greaterOrEqualTo(other.getBottom()).isSatisfiedOn(getTop(), context, DOWN) ||
Condition.greaterOrEqualTo(getBottom()).isSatisfiedOn(other.getTop(), context, DOWN);
}

private Scalar getOffset(Direction direction, UIElement page) {
return direction.signedDistance(getEnd(direction), page.getEnd(direction));
}
Expand Down Expand Up @@ -347,7 +354,7 @@ public void validateOverlappingWithElement(UIElement element, Context context) {
}

public void validateNotOverlappingWithElement(UIElement element, Context context) {
if (overlaps(element, context)) {
if (!notOverlaps(element, context)) {
context.add(String.format("Element %s is overlapped with element %s but should not",
getQuotedName(),
element.getQuotedName()));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/util/validator/ResponsiveUIValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ protected ResponsiveUIValidator(net.itarray.automotion.validation.ResponsiveUIVa
responsiveUIValidator.dontDrawMap();
}

public ResponsiveUIValidator withTolerance(int tolerance) {
responsiveUIValidator.withTolerance(tolerance);
return this;
}

public boolean isWithReport() {
return responsiveUIValidator.isWithReport();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/rectangles/IntersectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void shouldNotOverlap() {

@Test
public void areNotOverlapped() {
assertThat(areNotOverlappedWithEachOther(Arrays.asList(root, other)))
assertThat(doNotOverlap(Arrays.asList(root, other)))
.withFailMessage(failMessage(intersectionExpectation()))
.isEqualTo(!intersects);
}
Expand Down
Loading