RFR: JDK-8302846: IGV: Zoom stuck when zooming out on large graphs

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Mon Feb 20 13:44:23 UTC 2023


On Mon, 20 Feb 2023 09:55:29 GMT, Tobias Holenstein <tholenstein at openjdk.org> wrote:

> # Problem 
> In the IdealGraphVisualizer (IGV) the user can zoom in and out using either the mouse-wheel or by entering/selecting a value in the zoom combo-box. The zoom combo-box is implemented in `ZoomLevelAction.java`: 
> - `ZoomLevelAction` has a listener on `scene.getZoomChangedEvent()` which calls `changed(..)` each time the zoom level of the `diagramScene` changes, e.g. when the user zooms in/out with the mouse-wheel. 
> - `actionPerformed(..)` is called when the user enters/selects a zoom level in the combo-box, in which case it calls `setZoomLevel(..)` -> `diagramScene.setZoomPercentage(zoomLevel)` to update the zooming of the scene. 
> - `changed(..)` calls `setSelectedItem(..)` which updates the content of the combo-box and triggers a also a call to `actionPerformed(..)`. Unfortunately, in this case we should not call `diagramScene.setZoomPercentage(zoomLevel)` because the `diagramScene` is updating the `ZoomLevelAction` and not vice versa. The problem only reveals for small zooming level because `ZoomLevelAction` uses an integer for the zooming level (1-100%) while the `diagramScene` uses a float (1.0f is 100%). In the example where the bug occurs, mouse wheel zooming changed zoom level in `diagramScene` from 0.01 to 0.012 -  then `diagramScene` updates the `ZoomLevelAction` which rounds 1.2% to 1% :  and now the BUG: `ZoomLevelAction ` sets `diagramScene` zooming again to 0.01. The zooming is stuck at 0.01
> 
> # Solution
> When `diagramScene` updates the `ZoomLevelAction`, `actionPerformed(..)` should not call `diagramScene.setZoomPercentage(zoomLevel)`. So we introduce a ` boolean updateZoomInScene` that is set to `false` when a change of zoom in `diagramScene ` triggered the  `actionPerformed(..)`

Thanks for fixing this, Toby! Please update the copyright header.

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

Marked as reviewed by rcastanedalo (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12652


More information about the hotspot-compiler-dev mailing list