On Fri, 28 Oct 2022 23:29:36 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> Depending on the desired result, we use `Math.floor`, `Math.ceil`, or 
>> `Math.round` -- it's important to pick the right one.
>> 
>> But yes, using one of those is (almost always) better than just casting to 
>> `(int)` if the value might be negative.
>
> I think in this case, `Math.floor()` is what you want. I wonder, though, 
> whether it needs to be converted to an `int` at all? It looks like everywhere 
> it is used, it can be kept as a double.
> 
> Btw, I almost wrote a comment asking a question as to whether you were using 
> the values of x, y, width, and height correctly, because I got confused that 
> you were using a Dimension to hold an x,y point. If you decide to keep it as 
> a Dimension, I might suggest adding a clarifying comment.

We need the int values, as they are used to invoke `mouseEvent`, `scrollEvent` 
and `menuEvent` on `com.sun.javafx.embed.EmbeddedSceneInterface` . 
For some reason, `scrollEvent` takes doubles, but `mouseEvent` and `menuEvent` 
take ints.
I'll use `Math.floor()` instead of the `int` cast. The key thing here is that 
the strategy for the mouse/scroll/menu events should be the same as the 
strategy for the window location changes.

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

PR: https://git.openjdk.org/jfx/pull/924

Reply via email to