On Tue, 18 Aug 2026 23:51:46 GMT, Michael Strauß <[email protected]> wrote:

>> Pixel snapping is really hard to get right (in fact, it's so hard that even 
>> JavaFX itself gets it wrong in so many places).
>> I've compiled a list of things that I've learned, because there isn't really 
>> any good documentation as of yet.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Michael Strauß has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   remove empty tag

modules/javafx.graphics/src/main/java/javafx/scene/layout/Region.java line 1610:

> 1608:      */
> 1609:     @Override protected double computeMinWidth(double height) {
> 1610:         return getInsets().getLeft() + getInsets().getRight();

not relevant for this PR, but should this be snapped in the future? Or do you 
think this is better as default?

modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java 
line 245:

> 243:  *
> 244:  * At a render scale of {@code 1.0}, one logical unit is one pixel. At a 
> render scale of {@code 1.5}, one pixel is
> 245:  * {@code 1 / 1.5} ≈ {@code 0.6667}, logical units. A correctly snapped 
> value is therefore not necessarily an integer,

Is it just me or does the comma feels off here: `one pixel is ... 0.6667, 
logical units`

modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java 
line 349:

> 347:  * combined sum of such elements, each semantic role can require a 
> different decision:
> 348:  * <ul>
> 349:  *     <li>Snapping too early can lose precision, while snapping too 
> late can introduce errors.

There is no closing `</li>` tag here and below. 
I'm not sure if this is really needed. But probably best practise to do so.

modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java 
line 370:

> 368:  *
> 369:  *         double top = snapSpaceX(margin.getTop());   // Incorrect axis
> 370:  *         double gap = snapSpace(rawGap);             // Deprecated and 
> ambiguous

I wonder if we should remove those deprecated methods at one point. They are 
deprecated since JavaFX 9, so years ago.

We should probably start by marking them with `forRemoval = true`.

modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java 
line 427:

> 425:  *         double allocatedWidth = firstWidth + gapWidth + secondWidth;
> 426:  *         }
> 427:  *     <li><b>Snap independent allocations independently.</b><br>

This is very helpful and a nice example!

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3813662342
PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3812954875
PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3813049487
PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3813067929
PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3813106889

Reply via email to