Skip to content

Commit 3d3e3df

Browse files
8290069: IGV: Highlight both graphs of difference in outline
Reviewed-by: kvn, thartmann
1 parent 1c05507 commit 3d3e3df

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

src/utils/IdealGraphVisualizer/Coordinator/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
<artifactId>Util</artifactId>
7272
<version>${project.version}</version>
7373
</dependency>
74+
<dependency>
75+
<groupId>com.sun.hotspot.igv</groupId>
76+
<artifactId>View</artifactId>
77+
<version>${project.version}</version>
78+
</dependency>
7479
<dependency>
7580
<groupId>org.netbeans.api</groupId>
7681
<artifactId>org-openide-util</artifactId>

src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
import com.sun.hotspot.igv.coordinator.actions.*;
2828
import com.sun.hotspot.igv.data.GraphDocument;
2929
import com.sun.hotspot.igv.data.Group;
30+
import com.sun.hotspot.igv.data.InputGraph;
3031
import com.sun.hotspot.igv.data.services.GroupCallback;
3132
import com.sun.hotspot.igv.data.services.InputGraphProvider;
3233
import com.sun.hotspot.igv.util.LookupHistory;
34+
import com.sun.hotspot.igv.view.EditorTopComponent;
3335
import java.awt.BorderLayout;
3436
import java.io.IOException;
3537
import java.io.ObjectInput;
@@ -133,13 +135,22 @@ public void started(Group g) {
133135
// Fetch and select the latest active graph.
134136
private void updateGraphSelection() {
135137
final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);
136-
if (p == null) {
137-
return;
138-
}
139-
try {
140-
manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(p.getGraph())});
141-
} catch (Exception e) {
142-
Exceptions.printStackTrace(e);
138+
if (p != null) {
139+
try {
140+
InputGraph graph = p.getGraph();
141+
if (graph.isDiffGraph()) {
142+
EditorTopComponent editor = EditorTopComponent.getActive();
143+
if (editor != null) {
144+
InputGraph firstGraph = editor.getModel().getFirstGraph();
145+
InputGraph secondGraph = editor.getModel().getSecondGraph();
146+
manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(firstGraph), FolderNode.getGraphNode(secondGraph)});
147+
}
148+
} else {
149+
manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(graph)});
150+
}
151+
} catch (Exception e) {
152+
Exceptions.printStackTrace(e);
153+
}
143154
}
144155
}
145156

src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public class InputGraph extends Properties.Entity implements FolderElement {
3838
private Map<String, InputBlock> blocks;
3939
private List<InputBlockEdge> blockEdges;
4040
private Map<Integer, InputBlock> nodeToBlock;
41+
private boolean isDiffGraph;
42+
43+
public InputGraph(String name, boolean isDiffGraph) {
44+
this(name);
45+
this.isDiffGraph = isDiffGraph;
46+
}
4147

4248
public InputGraph(String name) {
4349
setName(name);
@@ -46,6 +52,11 @@ public InputGraph(String name) {
4652
blocks = new LinkedHashMap<>();
4753
blockEdges = new ArrayList<>();
4854
nodeToBlock = new LinkedHashMap<>();
55+
isDiffGraph = false;
56+
}
57+
58+
public boolean isDiffGraph() {
59+
return this.isDiffGraph;
4960
}
5061

5162
@Override

src/utils/IdealGraphVisualizer/Difference/src/main/java/com/sun/hotspot/igv/difference/Difference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static InputGraph createDiff(InputGraph a, InputGraph b, Set<NodePair> p
105105
}
106106
}
107107
g.getProperties().setProperty("name", "Difference");
108-
InputGraph graph = new InputGraph(a.getName() + ", " + b.getName());
108+
InputGraph graph = new InputGraph(a.getName() + ", " + b.getName(), true);
109109
g.addElement(graph);
110110

111111
Map<InputBlock, InputBlock> blocksMap = new HashMap<>();

src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public Diagram getDiagramToView() {
468468
Settings.get().get(Settings.NODE_SHORT_TEXT, Settings.NODE_SHORT_TEXT_DEFAULT),
469469
Settings.get().get(Settings.NODE_TINY_TEXT, Settings.NODE_TINY_TEXT_DEFAULT));
470470
getFilterChain().apply(diagram, getSequenceFilterChain());
471-
if (getFirstPosition() != getSecondPosition()) {
471+
if (graph.isDiffGraph()) {
472472
ColorFilter f = new ColorFilter("");
473473
f.addRule(stateColorRule("same", Color.white));
474474
f.addRule(stateColorRule("changed", Color.orange));

0 commit comments

Comments
 (0)