-
Notifications
You must be signed in to change notification settings - Fork 182
Add OfFloat.from methods in Point/Rectangle #2486
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
base: master
Are you sure you want to change the base?
Add OfFloat.from methods in Point/Rectangle #2486
Conversation
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
Outdated
Show resolved
Hide resolved
b45d40f
to
ac95b91
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.
Some questions on this proposal:
- Are the methods supposed to be public API or shall they only be used internal for now? In the latter case, they need to be marked
@noreference
. Otherwise, why do they need to be static at all and cannot just betoFloat()
, as they become public API anyway? But since the classes themselves are currently@noreference
, this method should probably be as well. In any case, they need a documentation. - Since the methods are supposed to create OfFloat versions out of any other, wouldn't it make sense to place them inside
Point.OfFloat
, so that you writePoint.OfFloat.From(something)
instead ofPoint.from(something)
but giving you an OfFloat instead of a pure Point. - Is it correct and expected that a
Point.WithMonitor
loses the monitor information when passed to that method?
We do not need @noreference since the classes are already marked with it. Adding the documentation to the method.
They are already inside Point.OfFloat.
Adapting the method to call clone internally. |
0712c9f
to
36d25ab
Compare
I see. I expected them to be in You need to add an |
This commit adds Rectangle.OfFloat.from and Point.OfFloat.from methods and removes the Win32DPIUtils.FloatAwareGeometryFactory class to make these methods OS-independent. It additionally adds clone methods in Point class and sub-classes and Rectangle.OfFloat::clone.
36d25ab
to
59ed121
Compare
@HeikoKlare @fedejeanne if we move it here, would that not mean they should become public API now? And if not why not move them into the internal packages? |
The |
This is not the same. So if we now move them to a "more public place" and it was promised to make them public API last time, why not make them public API now (or consequently keep them internal as is).
|
Good point @laeubi , thank you. @amartya4256 can you draft this one too until you decide how to proceed? |
@laeubi so is your proposal to make both Point.OfFloat and Rectangle.OfFloat public API? |
Last time it was added "windows only" and @HeikoKlare stated we should make it sometimes public API (but not now). So if we now move it "up in the chain" to make it available for other OS, it might be it is "the time" to do so ... that's just my feelings about it before someone uses it by accident. |
Making it available for other OSes and making it public API are two different things. Unless it's necessary, we should avoid making things public API as it will make it more difficult to change it afterwards. If there is no specific need to make this public API right now, I would not be in favor of doing so. |
The point is that once we put it into commons it seems there actually is a specific need for it as it means the thing has escaped from the (internal) win32 impl it was needed for. |
I can only repeat myself:
|
And I can only repeat myself that the demand was to use it in a So using |
I mean this PR was intended to move the methods to the right class since having a utility in Win32DPIUtils in an inner factory class doesn't make much sense and the classes (Point.OfFloat and Rectangle.OfFloat) themselves seem to be the right candidate for such methods. So from a refactoring POV it seems to be a right thing to do. But what I believe the the discussion here is about if it should be an API or a @noreference. Am I right? I think since we intend for it to be not used outside by any consumer outside SWT, there's no need for it to be public. We also have a lot of static methods in many Common classes which have noreference methods. For instance we have StyledText#updateAndRefreshCarets, Drawable#internal_new_GC, ImageData#internal_new The same mistakes can be made with these methods as well. We intend to not encourage usage of OfFloat outside SWT at least for now. |
This PR adds Rectangle.OfFloat.from and Point.OfFloat.from methods and removes the Win32DPIUtils.FloatAwareGeometryFactory class to make these methods OS-independent.