8302846: IGV: Zoom stuck when zooming out on large graphs

Reviewed-by: rcastanedalo, thartmann
This commit is contained in:
Tobias Holenstein 2023-02-21 13:48:49 +00:00
parent 92dfa1175e
commit 02eb240c71

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,6 +40,8 @@ public final class ZoomLevelAction extends JComboBox<String> implements ChangedL
private final DiagramViewer diagramScene;
boolean updateZoomInScene = true;
@Override
public void actionPerformed(ActionEvent e) {
EditorTopComponent editor = EditorTopComponent.getActive();
@ -58,6 +60,9 @@ public final class ZoomLevelAction extends JComboBox<String> implements ChangedL
level = Math.max(level, minLevel);
level = Math.min(level, maxLevel);
setZoomLevel(level);
if (updateZoomInScene) {
diagramScene.setZoomPercentage(level);
}
} catch(NumberFormatException exception) {
changed(diagramScene);
}
@ -84,11 +89,12 @@ public final class ZoomLevelAction extends JComboBox<String> implements ChangedL
private void setZoomLevel(int zoomLevel) {
setSelectedItem(zoomLevel + "%");
diagramScene.setZoomPercentage(zoomLevel);
}
@Override
public void changed(DiagramViewer diagramViewer) {
setSelectedItem(diagramViewer.getZoomPercentage() + "%");
updateZoomInScene = false;
setZoomLevel(diagramViewer.getZoomPercentage());
updateZoomInScene = true;
}
}