RFR: 8366739: ToolBar: overflow menu with fractional scale (2)

John Hendrikx jhendrikx at openjdk.org
Sun Dec 21 21:02:18 UTC 2025


On Sun, 21 Dec 2025 18:44:00 GMT, Cormac Redmond <duke at openjdk.org> wrote:

>> Ah yes, you are right, I skipped over the `+=` operation; indeed it also needs snapping.  It is simply the reality that even when values are already snapped, adding two snapped values together can still introduce a rounding error that must be resnapped.
>
> @hjohn: I'm a bit concerned that given snapPositionX/Y is basically just rounding (up or down), that x could still be wrong when compared to "length" in some scenarios (which I cannot produce)...any high-level thoughts on that?
> 
> I'm not up-to-speed on the various operations in ScaledMath and what assumptions I can make as true/false...

`length` is also supposed to be rounded with a similar function; if that's the case, then this should always work correctly.  Floating point operations may introduce slight errors, but if you round them to whole pixels (whether those pixels are of size 1, 0.75, 0.66666 or 0.5) the resulting value should always be the same for the same pixel position/size.

When I look at the values used in such calculations, and I see something weird like 0.6666664 or 1.000001, then I know it is not properly rounded; so if `length` looks good then it should work correctly.  Alternatively, you can try and see where `length` comes from and if it was the result of some snapping function.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2016#discussion_r2638093978


More information about the openjfx-dev mailing list