RFR: 8314512: IGV: clean up hierarchical layout code
Tobias Holenstein
tholenstein at openjdk.org
Wed Nov 27 17:35:58 UTC 2024
This refactoring enhances layer and node management by encapsulating computations within LayoutGraph, LayoutLayer, and LayoutNode, improving modularity and delegation of responsibilities for handling dummy nodes and self-edges to dedicated utility classes. Code duplication was reduced by consolidating common logic, such as edge reversal, into reusable methods, and optimizing processes like updating node positions and crossings. Additionally, method names were updated to better reflect their functionality,
### LayoutGraph
The LayoutGraph class is responsible for organizing and arranging a graph's nodes and edges for visual display. It takes a collection of nodes (Vertex) and connections between them (Link) and structures them into layers, creating a hierarchical layout. The class handles complexities like edges that span multiple layers by inserting temporary "dummy" nodes to maintain a clear hierarchy. This organization helps ensure that when the graph is displayed, it is easy to understand and visually coherent, making the relationships between nodes clear and straightforward.
### LayoutLayer
The LayoutLayer class represents a single horizontal layer in a hierarchical graph layout. It holds a list of nodes (LayoutNode) that are all on the same vertical level. This class provides simple methods to manage these nodes: you can add nodes to the layer, calculate the maximum height needed to fit all nodes, center the nodes vertically within the layer, and set their horizontal positions with proper spacing. In essence, LayoutLayer helps organize nodes neatly in a graph, making it easier to display the graph clearly and understand the relationships between nodes.
### LayoutNode
The LayoutNode class represents a node in a hierarchical graph layout. It can be either an actual node from the original graph or a temporary "dummy" node added during the layout process to handle complex edge connections. This class stores important layout information like the node's position (x and y coordinates), size (width and height), layer level, and connections to other nodes through incoming and outgoing edges. It provides methods to calculate optimal positions, manage margins, and handle reversed edges, all aimed at arranging the nodes neatly in layers to create a clear and visually organized graph display.
### LayoutEdge
The LayoutEdge class represents a connection between two nodes (LayoutNode) in a hierarchical graph layout. It stores information about the starting node (from), the ending node (to), and the positions where the edge connects to these nodes. It also keeps track of whether the edge has been reversed, which is useful for handling edges that go against the main flow in hierarchical layouts (like loops or back edges). This class ensures that edges are drawn correctly between nodes, helping to create clear and understandable visualizations of the graph.
`LayoutGraph` with `LayoutLayers`
<img width="564" alt="LayoutGraph" src="https://github.com/user-attachments/assets/006e0402-d943-4f75-aedb-62b4c8f9ad83">
`LayoutLayer` with `LayoutNodes`
<img width="343" alt="LayoutLayer" src="https://github.com/user-attachments/assets/73781542-0ffe-4521-b25b-d9171a71ee1c">
### Keeping edges straight until they leave the LayoutLayer
`before`
<img width="334" alt="old" src="https://github.com/user-attachments/assets/69c14c1c-a42d-4b91-9786-1c06968c73bd">
`now`
<img width="318" alt="new" src="https://github.com/user-attachments/assets/7b87c403-0e72-42e8-a9d0-2f5fb3bd8c8a">
-------------
Commit messages:
- remove executability of igv.sh
- update Figure height calculation for Slots
- run IGV without asserts
- batch add connectionLayer.addChildren(newWidgets);
- remove dead code in LineWidget
- cached
- Fix crash: missing Figure after filter applied
- Node labels in the CFG view left aligned
- 8314512: IGV: clean up hierarchical layout code
- Revert "AllSoFar"
- ... and 2 more: https://git.openjdk.org/jdk/compare/b9c6ce90...ad4d0761
Changes: https://git.openjdk.org/jdk/pull/22402/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22402&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8314512
Stats: 4980 lines in 41 files changed: 1840 ins; 2186 del; 954 mod
Patch: https://git.openjdk.org/jdk/pull/22402.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22402/head:pull/22402
PR: https://git.openjdk.org/jdk/pull/22402
More information about the hotspot-compiler-dev
mailing list