-
Notifications
You must be signed in to change notification settings - Fork 176
Use Float Aware Geometry for Scaling #62 #2200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Float Aware Geometry for Scaling #62 #2200
Conversation
Test Results104 files - 441 104 suites - 441 4s ⏱️ - 31m 45s Results for commit a9f3fc7. ± Comparison against base commit 5389894. This pull request removes 4335 tests.
♻️ This comment has been updated with latest results. |
I must confess that this Is there any reason to not have proper getter/setter instead of public modifiable fields? The e.g. a setX(double) can always update the integer fields as well. Also one might look at how AWT is doing it here: https://docs.oracle.com/javase/8/docs/api/java/awt/geom/Rectangle2D.html So the have
|
I don't see a good reason to not have proper getter/setters for the newly added fields. One issue from OO perspective is that we have the public fields in the existing Rectangle/Points classes which are accessed directly everywhere and makes it difficult to properly extend the classes. But for the additional classes with higher precision, which are only supposed to be used inside SWT at least for now anyway, it definitely makes sense to apply proper encapsulation. I also agree that that names sound strange, at least the float version (for MonitorAware* it makes more sense to me). |
tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java
Show resolved
Hide resolved
I'm not sure if we should design such "supposed to be internal" API here. Actually one big drawback of SWT compared to eg. |
I think this is a misunderstanding. I did not want to propose to design an API that is supposed to only be internal. I just wanted to say that these classes are only supposed to be used internally for now, so still having the chance for redesign before they are eventually made public API. We should first adapt the code inside SWT to properly handle higher-precision coordinates (for the reasons you also mentioned) and see where/whether we run into problems there and what needs to be done to adapt all consumers of Point/Rectangle to properly handle the higher-precision versions of them. Afterwards, once we know how to properly do it and once everything is implemented, we can make it API public. If we would do it now, strange things would happen as a consumer could pass a point with floating-point precision to consumers inside SWT without them being adapted to properly consider the higher-precision value. So there is quite some need to adaptation before we might do that. |
As per our discussion, I would move the *Aware classes inside Rectangle and Point and would rather call them Rectangle.Float and Rectangle.withMonitor (Same for Point) which would then have getters and setters implemented. The inner classes will be @noreference classes as they must only be used internally in SWT. I will then adapt the intended consumers accordingly, inside SWT. |
1f6354b
to
c6ec000
Compare
ae52c61
to
c0b9458
Compare
This commit moves the classes MonitorAwareRectangle and MonitorAwarePoint to Rectangle and Point as a static class and renames them to WithMonitor to allow them to be used as Rectangle.WithMonitor and Point.WithMonitor. contributes to eclipse-platform#62 and eclipse-platform#128
c0b9458
to
aa079f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, I have some concerns regarding loss of precision when cloning and some nitpicky comments about coding practices.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
Outdated
Show resolved
Hide resolved
One note about API, I think it would be good to have getter in e.g. This has the advantage that code can move away from the int fields to proper getters/setters without needing to know the actual type of storage, this is similar to using As an alternative, a Point might has |
Thank you for your suggestions @laeubi , I like them, but I would like to move that discussion to another PR. As Heiko mentioned already, we'd like to keep this PR about using Would that be ok? |
It just seem to complicate things a lot, in any case I would love to see using higher precision values in SWT anyways :-D |
The day will come when we can all enjoy better precision in SWT (I'm also looking forward to it!) . I'll take your comment as a 👍 on postponing the discussion about the public API, hope that's ok for you :-) |
75b3a05
to
f62cac5
Compare
ded6873
to
c924244
Compare
This commit introduces Rectangle.OfFloat and Point.OfFloat classes as an extension of Rectangle and Point respectively to improve scaling precision in the DPIUtil by using residuals obtained from rounding. Contributes to eclipse-platform#62 and eclipse-platform#128
c924244
to
a9f3fc7
Compare
The API Tools check is failing because internal classes were removed from Windows But these classes were marked with Pull-Request Checks / check-versions / Check and increment service versions (pull_request) fails with this error, which is also unrelated:
I am ignoring these check failures. |
MonitorAwarePoint is not internal API, why have you thought it is? This caused api warnings on Linux too. |
The noferencence is smth that majority of people will not see. Anyway as this has been in only couple of release I am fine with dropping it now but api filters have to be added ASAP to fix errors in workspaces. |
The reason why api tools fail on all platform is because this code is in "Eclipse SWT/common" directory which is shared between all swt ws/os combos and thus api filters are needed for all of them. |
Now all SWT PR's (like #2223) are failing with API errors and they are also visible in IDE on Linux!
|
I plan to merge the reverted commits once the build will be green via #2264. |
Please next time double check PR build results. All the checks we have are not there to be ignored, except it is known problem that is documented via a ticket. |
@iloveeclipse would you kindly tell me how to properly get rid of the API validation errors instead? I tried increasing the version of the affected plugins in my IDE before merging the PR but the error persisted so I assumed it was a bogus error. How would you get rid of the errors? |
The SWT bundle minor version segment was already increased for 4.37 release. We don't update minor segment multiple times during release cycle. Whatever error you saw, it was wrong solution anyway.
Like this but for all platforms:
Note, usually we do not delete non deprecated API, I assume this is safe now only because it was introduced in the last release and it was marked as |
This PR introduces Rectangle.OfFloat and Point.OfFloat as an extension of Rectangle and Point respectively to improve scaling precision in the DPIUtil by using residuals obtained from rounding.
Contributes to
#62 and #128