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

Tobias Holenstein tholenstein at openjdk.org
Mon Feb 20 13:14:17 UTC 2023


# 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(..)`

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

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

Changes: https://git.openjdk.org/jdk/pull/12652/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12652&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8302846
  Stats: 9 lines in 1 file changed: 7 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/12652.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12652/head:pull/12652

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


More information about the hotspot-compiler-dev mailing list