RFR: 8345261: Refactor the Dimension2D classes

Nir Lisker nlisker at openjdk.org
Mon Dec 2 11:27:46 UTC 2024


On Mon, 2 Dec 2024 02:19:46 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:

>> A small refactoring of the Dimension classes.
>> 
>> * `com.sun.javafx.geom.Dimension` was removed and its uses were replaced by `com.sun.javafx.geom.Dimension2D`.
>> * `com.sun.javafx.geom.Dimension2D` became a record.
>> * `javafx.geometry.Dimension2D`: fields became `final`.
>> 
>> I'm not sure we need the implementation class at all considering we are free to use the public one.
>
> These 3 classes are all different from each other. They use different types of variables to store data (`double`, `float`, `int`).
> 
> We have `com.sun.javafx.geom.Rectangle` which uses `int`, and the `com.sun.javafx.geom.Dimension` was specifically introduced as its pair which also uses `int`.
> (just as we have a pair of `javafx.geometry.Rectangle2D` and `javafx.geometry.Dimension2D.java`).
> 
> Switching from `int` to `float` may have some side effects on stream processing due to the imprecise comparison.
> 
> So I would prefer to keep the `com.sun.javafx.geom.Dimension`.

Thanks @azvegint. If the `int`-based dimensions are coupled with `com.sun.javafx.geom.Rectangle` (and from the code, that's the only place they are used at), would you object to making `Dimension` an inner class of `Rectangle`? The `float`-based dimensions are used in other 2D shapes, so are more general purpose.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1653#issuecomment-2511272926


More information about the openjfx-dev mailing list