RFR: 8279614: The left line of the TitledBorder is not painted on 150 scale factor [v7]
Kevin Rushforth
kcr at openjdk.java.net
Tue Mar 29 23:39:41 UTC 2022
On Mon, 28 Mar 2022 17:47:50 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> > I also think there's at least some analogy with OpenJFX's snap-to-pixel idea that it is sometimes better to pick a pixel and stick with it rather than span pixels and be fuzzy. Not an expert on the details of that by any means @kevinrushforth might be able to point to something if it is relevant.
>
> I wonder how it's handled in OpenJFX. There should be the same problem with borders at fractional scales.
>
> > If we figure this out properly it might be useful to apply to other cases rather than applying inconsistent hacks.
JavaFX implements snap-to-pixel by default for Region (which is the base class of all layout panes and UI controls). This is done by either doing a round, floor, or ceil operation by first scaling the user-space value (by the screen scale), rounding (or floor or ceil) in screen coords, and then dividing by the scale to get it back to user space. For region borders, we snap all four corners of each border to pixels. The stroke width is scaled, so that a border of 1 will show up as 3 pixels with a screen scale of 3.
I don't know whether you could do anything analagous in Java2D.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7449
More information about the client-libs-dev
mailing list