On Sat, 8 Aug 2026 22:27:17 GMT, John Hendrikx <[email protected]> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/javafx/scene/layout/Snapper.java
>> line 37:
>>
>>> 35: * operations used by layout math.
>>> 36: */
>>> 37: public interface Snapper {
>>
>> Really like the idea of the `Snapper`.
>>
>> What I would really like to see documented is what values developers should
>> snap.
>> Maybe we could add all the information we gathered over the years here.
>> So the conclusion of the mailing list entries,
>> https://github.com/openjdk/jfx/pull/1948,
>> https://github.com/openjdk/jfx/pull/1111 (maybe even revive this one after)
>> and there are probably more.
>>
>> Especially: Snap only final values once (before they are returned or used as
>> x/y/w/h (If I understood that right).
>
> Yeah, we can add documentation here, just like how `Measurable` explains the
> bias system a bit.
>
>> Snap only final values once (before they are returned or used as x/y/w/h (If
>> I understood that right).
>
> That's probably best indeed; it depends on what's using those values again
> whether or not the snapping proved important or not (often the value gets
> resnapped again, depending on the container, but you shouldn't rely on that).
>
> I also discovered a slight bug in how `ceil` works. We shouldn't subtract 1
> ulp from the values, as 1 ulp (at Double.MAX_VALUE) can be a huge number. I
> was wrong when I implemented that (although it works for most "normal"
> values).
>
> Instead I propose that we subtract 1 millionth of a pixel. At
> `Double.MAX_VALUE` that rounds to 0, while at more reasonable values it will
> remove any slight floating point errors that could cause a small 1 pixel
> misalignment.
I think @mstr2 already solved this one.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2241#discussion_r3826616238