RFR: JDK-8306990: The guarantees given by Region's floor and ceiling functions should work for larger values [v4]

Andy Goryachev angorya at openjdk.org
Wed May 3 19:40:28 UTC 2023


On Tue, 2 May 2023 16:47:02 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> Region has floor and ceiling functions that ensure that calling them twice in a row will yield the same result:
>> 
>>      ceil(x) = ceil(ceil(x))
>> 
>> However, due to use of a constant `EPSILON` which is added/subtracted before doing the rounding, this only works for small numbers (in the range of 0-50 approximately).  For larger values and scales, rounding errors can easily occur.  This is visible as artifacts on screen where controls are a pixel wider than they should be.
>> 
>> The use of the `EPSILON` constant is incorrect, as its value depends on the magnitude of the value in question (as magnitude increases, the fractional precision decreases).
>> 
>> The Math class offers the function `ulp` that should be used here.  It represents the smallest possible change in value for a given double.
>> 
>> Extending the existing test case `snappingASnappedValueGivesTheSameValueTest` to use larger magnitude numbers exposes the problems.
>
> John Hendrikx has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix bad commit

The latest commit still completely breaks Monkey Tester layout when a scale other than 100% is used:
The Monkey Tester uses SplitPanes, BorderPanes and VBox:

![Screenshot 2023-05-03 123236](https://user-images.githubusercontent.com/107069028/236027123-0184010e-3773-4f8a-9aca-715dd76af160.png)


(a mirror as a standalone project has been moved to https://github.com/andy-goryachev-oracle/MonkeyTest )

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

PR Comment: https://git.openjdk.org/jfx/pull/1118#issuecomment-1533613792


More information about the openjfx-dev mailing list