JavaFX snapping and scale

Marius Hanl mariushanl at web.de
Mon Sep 27 09:41:40 UTC 2021


   I recently tried to fix "TableView: visual glitch at borders on
   horizontal scrolling".
   Ticket: [1]https://bugs.openjdk.java.net/browse/JDK-8218745
   PR: [2]https://github.com/openjdk/jfx/pull/630

   As also written in the PR I have problems understanding the
   snapping/scaling of JavaFX.
   Here in short what I found out:
   - Snapping fixed the issue for a scale of 1 or 2, but not for a scale
   like 1.25 or 1.5
   --- Also VirtualFlow is the only occurence where we set the layoutX of
   a clip (might be the problem?)
   - This visual glitch only happens sometimes when the x value is a
   decimal number, e.g. 12.66 (never when it's a round number like 13)
   - Math.round(..) or a cast to int fixed this (for all scales), but is
   probably not the correct solution or maybe only fixing a symptom here

   Which leads to my question where may some of you can help me:
   - How does JavaFX renders a node when e.g. x is a decimal number? How
   many pixel are used then?
   - And does a decimal number make sense (Why we e.g. don't round the
   value), which looks like it works fine and doesn't result in visual
   glitches

   Also information/insights about fixes made in the past which relates
   with this are welcome.
   I saw that there were quite some issues with a scale other then 1 in
   the past.

   Note: If the result is that everything works as expected chances are
   there might a generic problem with snapping/layout/rendering somewhere
   then.
   Any information are welcome and feel free to also have a look at the
   PR.

   -- Marius

References

   1. https://bugs.openjdk.java.net/browse/JDK-8218745
   2. https://github.com/openjdk/jfx/pull/630


More information about the openjfx-dev mailing list