mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-16 15:40:14 +00:00
Merge remote-tracking branch
'origin/GP-793_emteere_PR-2953_tomnelson_edgeAndVertexHighlighting' (Closes #2953)
This commit is contained in:
commit
ca3e853825
@ -27,13 +27,13 @@ dependencies {
|
||||
api project(":Base")
|
||||
|
||||
// jungrapht - exclude slf4j which produces a conflict with other uses with Ghidra
|
||||
api ("com.github.tomnelson:jungrapht-visualization:1.2") { exclude group: "org.slf4j", module: "slf4j-api" }
|
||||
api ("com.github.tomnelson:jungrapht-layout:1.2") { exclude group: "org.slf4j", module: "slf4j-api" }
|
||||
api ("com.github.tomnelson:jungrapht-visualization:1.3") { exclude group: "org.slf4j", module: "slf4j-api" }
|
||||
api ("com.github.tomnelson:jungrapht-layout:1.3") { exclude group: "org.slf4j", module: "slf4j-api" }
|
||||
|
||||
api "org.jgrapht:jgrapht-core:1.5.1"
|
||||
|
||||
api "org.jgrapht:jgrapht-core:1.5.0"
|
||||
|
||||
// not using jgrapht-io code that depends on antlr, so exclude antlr
|
||||
api ("org.jgrapht:jgrapht-io:1.5.0") { exclude group: "org.antlr", module: "antlr4-runtime" }
|
||||
api ("org.jgrapht:jgrapht-io:1.5.1") { exclude group: "org.antlr", module: "antlr4-runtime" }
|
||||
|
||||
runtimeOnly "org.slf4j:slf4j-api:1.7.25"
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.jgrapht.Graph;
|
||||
import org.jgrapht.graph.AsSubgraph;
|
||||
import org.jungrapht.visualization.*;
|
||||
import org.jungrapht.visualization.annotations.MultiSelectedVertexPaintable;
|
||||
import org.jungrapht.visualization.annotations.SelectedEdgePaintable;
|
||||
import org.jungrapht.visualization.annotations.SingleSelectedVertexPaintable;
|
||||
import org.jungrapht.visualization.control.*;
|
||||
import org.jungrapht.visualization.decorators.*;
|
||||
@ -201,6 +202,13 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
private PopupRegulator<AttributedVertex, AttributedEdge> popupRegulator;
|
||||
private GhidraGraphCollapser graphCollapser;
|
||||
|
||||
private MultiSelectedVertexPaintable<AttributedVertex, AttributedEdge> multiSelectedVertexPaintable;
|
||||
|
||||
// manages highlight painting of a single selected vertex
|
||||
private SingleSelectedVertexPaintable<AttributedVertex, AttributedEdge> singleSelectedVertexPaintable;
|
||||
|
||||
private SelectedEdgePaintable<AttributedVertex, AttributedEdge> selectedEdgePaintable;
|
||||
|
||||
/**
|
||||
* Create the initial display, the graph-less visualization viewer, and its controls
|
||||
* @param displayProvider provides a {@link PluginTool} for Docking features
|
||||
@ -311,16 +319,24 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
* create the highlighters ({@code Paintable}s to show which vertices have been selected or focused)
|
||||
*/
|
||||
private void buildHighlighers() {
|
||||
|
||||
viewer.removePostRenderPaintable(multiSelectedVertexPaintable);
|
||||
|
||||
viewer.removePostRenderPaintable(singleSelectedVertexPaintable);
|
||||
|
||||
// for highlighting of multiple selected vertices
|
||||
MultiSelectedVertexPaintable<AttributedVertex, AttributedEdge> multiSelectedVertexPaintable =
|
||||
this.multiSelectedVertexPaintable =
|
||||
MultiSelectedVertexPaintable.builder(viewer)
|
||||
.selectionStrokeMin(4.f)
|
||||
.selectionStrokeMin(15.f)
|
||||
.selectionPaint(getSelectedVertexColor())
|
||||
.useBounds(false)
|
||||
.useBounds(true)
|
||||
.useOval(true)
|
||||
.highlightScale(1.15)
|
||||
.fillHighlight(false)
|
||||
.build();
|
||||
|
||||
// manages highlight painting of a single selected vertex
|
||||
SingleSelectedVertexPaintable<AttributedVertex, AttributedEdge> singleSelectedVertexPaintable =
|
||||
this.singleSelectedVertexPaintable =
|
||||
SingleSelectedVertexPaintable.builder(viewer)
|
||||
.selectionStrokeMin(4.f)
|
||||
.selectionPaint(getSelectedVertexColor())
|
||||
@ -328,11 +344,20 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
.build();
|
||||
|
||||
// draws the selection highlights
|
||||
viewer.addPostRenderPaintable(multiSelectedVertexPaintable);
|
||||
viewer.addPreRenderPaintable(multiSelectedVertexPaintable);
|
||||
|
||||
// draws the location arrow
|
||||
viewer.addPostRenderPaintable(singleSelectedVertexPaintable);
|
||||
|
||||
viewer.removePreRenderPaintable(selectedEdgePaintable);
|
||||
|
||||
this.selectedEdgePaintable = SelectedEdgePaintable.builder(viewer)
|
||||
.selectionPaintFunction(e -> getSelectedEdgeColor())
|
||||
.selectionStrokeMultiplier(2)
|
||||
.build();
|
||||
|
||||
viewer.addPreRenderPaintable(selectedEdgePaintable);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -629,7 +654,6 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
|
||||
private void growSelection(Set<AttributedVertex> vertices) {
|
||||
viewer.getSelectedVertexState().select(vertices);
|
||||
selectEdgesConnecting(vertices);
|
||||
}
|
||||
|
||||
// select all the edges that connect the supplied vertices
|
||||
@ -967,6 +991,10 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
nodeSelectedState.clear();
|
||||
if (!vertices.isEmpty()) {
|
||||
nodeSelectedState.select(vertices, fireEvents);
|
||||
if (!fireEvents) {
|
||||
// need to make explicit call since event not fired
|
||||
selectEdgesConnecting(vertices);
|
||||
}
|
||||
scrollToSelected(vertices);
|
||||
}
|
||||
viewer.repaint();
|
||||
@ -1286,21 +1314,17 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||
this.iconCache = new GhidraIconCache();
|
||||
RenderContext<AttributedVertex, AttributedEdge> renderContext = vv.getRenderContext();
|
||||
|
||||
renderContext.getSelectedVertexState().addItemListener(item -> {
|
||||
renderContext.getSelectedEdgeState().clear();
|
||||
selectEdgesConnecting(renderContext.getSelectedVertexState().getSelected());
|
||||
});
|
||||
|
||||
setVertexPreferences(vv);
|
||||
|
||||
// selected edges will be drawn with a wider stroke
|
||||
renderContext.setEdgeStrokeFunction(
|
||||
e -> isSelected(e) ? new BasicStroke(20.f)
|
||||
: ProgramGraphFunctions.getEdgeStroke(e));
|
||||
|
||||
// selected edges will be drawn in red (instead of default)
|
||||
Color selectedEdgeColor = getSelectedEdgeColor();
|
||||
renderContext.setEdgeDrawPaintFunction(
|
||||
e -> isSelected(e) ? selectedEdgeColor : Colors.getColor(e));
|
||||
renderContext.setArrowDrawPaintFunction(
|
||||
e -> isSelected(e) ? selectedEdgeColor : Colors.getColor(e));
|
||||
renderContext.setArrowFillPaintFunction(
|
||||
e -> isSelected(e) ? selectedEdgeColor : Colors.getColor(e));
|
||||
renderContext.setEdgeStrokeFunction(e -> ProgramGraphFunctions.getEdgeStroke(e));
|
||||
renderContext.setEdgeDrawPaintFunction(e -> Colors.getColor(e));
|
||||
renderContext.setArrowDrawPaintFunction(e -> Colors.getColor(e));
|
||||
renderContext.setArrowFillPaintFunction(e -> Colors.getColor(e));
|
||||
|
||||
// assign the shapes to the modal renderer
|
||||
ModalRenderer<AttributedVertex, AttributedEdge> modalRenderer = vv.getRenderer();
|
||||
|
@ -32,10 +32,10 @@ dependencies {
|
||||
api "net.sf.jung:jung-graph-impl:2.1.1"
|
||||
api "net.sf.jung:jung-visualization:2.1.1"
|
||||
|
||||
api "org.jgrapht:jgrapht-core:1.5.0"
|
||||
api "org.jgrapht:jgrapht-core:1.5.1"
|
||||
|
||||
// not using jgrapht-io code that depends on antlr, so exclude antlr
|
||||
api ("org.jgrapht:jgrapht-io:1.5.0") { exclude group: "org.antlr", module: "antlr4-runtime" }
|
||||
api ("org.jgrapht:jgrapht-io:1.5.1") { exclude group: "org.antlr", module: "antlr4-runtime" }
|
||||
|
||||
// These have abstract test classes and stubs needed by this module
|
||||
testImplementation project(path: ':Docking', configuration: 'testArtifacts')
|
||||
|
Loading…
Reference in New Issue
Block a user