Skip to content

Conversation

@ShahzaibIbrahim
Copy link
Contributor

When the size point is Point.OfFloat, return Rectangle.OfFloat to retain sub-pixel precision; otherwise return the classic Rectangle.

This is introduced as needed to be used in eclipse-platform/eclipse.platform.ui#3597

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

Test Results

  176 files  ±0    176 suites  ±0   27m 55s ⏱️ + 2m 28s
4 676 tests +4  4 654 ✅ +4  22 💤 ±0  0 ❌ ±0 
  482 runs  ±0    476 ✅ ±0   6 💤 ±0  0 ❌ ±0 

Results for commit b701ab0. ± Comparison against base commit 892be33.

♻️ This comment has been updated with latest results.

When the size point is Point.OfFloat, return Rectangle.OfFloat to retain
sub-pixel precision; otherwise return the classic Rectangle.
* dimensions
* @since 3.133
*/
public static Rectangle of(Point topLeft, Point dimension) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already of(Point, int, int). Since that and this new method are basically equal (just that the new one can carry additional context information in the dimension point), I would expect them to behave the same whenever possible. This particularly means:

  • The existing method should also properly handle the passed topleft point being OfFloat
  • This new method should also deal with topLeft being WithMonitor

Comment on lines +390 to +393
* If the provided {@code Point} instance carries additional OfFloat
* information, an extended {@code Rectangle} type may be returned to preserve
* that context. Otherwise, a standard {@code Rectangle} is returned.
* </p>
Copy link
Contributor

Choose a reason for hiding this comment

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

"OfFloat" is nothing known at public API. The contract of the method should be accordingly abstract. I would propose to adopt the formulation of the existing of(Point, int, int) method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SWT: Add Rectangle.of(Point, Point) preserving OfFloat dimensions

4 participants