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 @@ -210,6 +210,15 @@ void translateRectangleInPixelsInBothMonitorsBackAndForthShouldBeTheSame(Coordin
assertEquals(rectInPxs, mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom()));
}

@ParameterizedTest
@MethodSource("provideCoordinateSystemMappers")
void translateRectangleInPixelsForZeroSize(CoordinateSystemMapper mapper) {
setupMonitors(mapper);
Rectangle rectInPts = createExpectedRectangle(mapper, 0, 0, 0, 0, monitors[0]);
Rectangle rectInPxs = mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom());
assertEquals(rectInPts, mapper.translateFromDisplayCoordinates(rectInPxs, monitors[0].getZoom()));
}

private Point createExpectedPoint(CoordinateSystemMapper mapper, int x, int y, Monitor monitor) {
if (mapper instanceof SingleZoomCoordinateSystemMapper) {
return new Point(x, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ private Monitor getContainingMonitorForPoints(int x, int y) {
}

private Monitor getContainingMonitorForPoints(int x, int y, int width, int height) {
if (width <= 0 || height <= 0) {
return getContainingMonitorForPoints(x, y);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to return the monitor of the containing point (x,y)in this case using getContainingMonitorForPoints(int x, int y)
Since this function's caller is getValidMonitorIfApplicable(int x, int y, int width, int height, Monitor monitor) and it assigns the rectangle the defaultMonitor in case null is returned. For correctness, we can keep the monitor consistent by calling getContainingMonitorForPoints(int x, int y). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, thank you! I have adapted the PR accordingly. Can you check whether it now fits to your proposal, @amartya4256?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is good.

Monitor[] monitors = monitorSupplier.get();
Monitor selectedMonitor = null;
int highestIntersectionRatio = 0;
Expand Down
Loading