-
Enhancement
-
Resolution: Unresolved
-
P4
-
8, 9
The information about (to be forwarded) events that is exchanged between JFXPanel/FXCanvas and EmbeddedScene/EmbeddedStage is currently encoded via constants of com.sun.javafx.embed.AbstractEvents. That is, FXCanvas and JFXPanel map SWT respectively AWT event information to constants in AbstractEvents, which are then mapped to respective JavaFX representations within EmbeddedScene/EmbeddedStage.
As FXCanvas and JFXPanel are dedicated to embedding JavaFX alone (according to Artem Ananiev the motivation for introducing an indirection was that embedding other components was thought to be a potential scenario: http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-September/019695.html), and as both already contain a lot of JavaFX specific code, the indirection no longer makes sense. It is furthermore already bypassed in certain situations. For instance, in case of EmbeddedSceneInterface#inputMethodEvent() EventType is already used as a parameter instead of an AbstractEvents constant. Also, the modifier constants defined within AbstractEvents are only used in case of key events, while for mouse and gesture events, boolean parameters are used to transport this information (which could also be done in case of key events).
To improve readability and maintainability of the code base, AbstractEvents should be removed, directly using JavaFX abstractions to mediate between FXCanvas/JFXPanel and EmbeddedScene/EmbeddedStage instead. This might also bring a slight performance improvement.
As FXCanvas and JFXPanel are dedicated to embedding JavaFX alone (according to Artem Ananiev the motivation for introducing an indirection was that embedding other components was thought to be a potential scenario: http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-September/019695.html), and as both already contain a lot of JavaFX specific code, the indirection no longer makes sense. It is furthermore already bypassed in certain situations. For instance, in case of EmbeddedSceneInterface#inputMethodEvent() EventType is already used as a parameter instead of an AbstractEvents constant. Also, the modifier constants defined within AbstractEvents are only used in case of key events, while for mouse and gesture events, boolean parameters are used to transport this information (which could also be done in case of key events).
To improve readability and maintainability of the code base, AbstractEvents should be removed, directly using JavaFX abstractions to mediate between FXCanvas/JFXPanel and EmbeddedScene/EmbeddedStage instead. This might also bring a slight performance improvement.