Ghidra is a software reverse engineering (SRE) framework
added javadoc and removed some cruft
Tom Nelson6609b4aa6727
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/GraphDisplayBroker.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/GraphDisplayBroker.javaindex bdd7be006c..e374ce8c36 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/GraphDisplayBroker.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/GraphDisplayBroker.java@@ -67,6 +67,14 @@ public interface GraphDisplayBroker {return getDefaultGraphDisplay(reuseGraph, Collections.emptyMap(), monitor);}+ /**+ * A convenience method for getting a {@link GraphDisplay} from the currently active provider+ * @param reuseGraph if true, the provider will attempt to re-use a current graph display+ * @param properties a {@code Map} of property key/values that can be used to customize the display+ * @param monitor the {@link TaskMonitor} that can be used to cancel the operation+ * @return a {@link GraphDisplay} object to sends graphs to be displayed or exported.+ * @throws GraphException thrown if an error occurs trying to get a graph display+ */GraphDisplay getDefaultGraphDisplay(boolean reuseGraph, Map<String, String> properties, TaskMonitor monitor)throws GraphException;diff --git a/Ghidra/Features/GraphServices/src/main/help/help/topics/GraphServices/GraphDisplay.htm b/Ghidra/Features/GraphServices/src/main/help/help/topics/GraphServices/GraphDisplay.htmindex 3ebb957878..ae6bf805d0 100644--- a/Ghidra/Features/GraphServices/src/main/help/help/topics/GraphServices/GraphDisplay.htm+++ b/Ghidra/Features/GraphServices/src/main/help/help/topics/GraphServices/GraphDisplay.htm@@ -213,7 +213,11 @@<LI><A name="Expand_Selected"><B>Expand Selected Vertices</B> - Any group vertices are reverted back to the vertices that it contains.</LI>-+ <LI><A name="Grow_Selection_To_Entire_Component">+ <B>Grow Selection To Entire Component</B> - Adds to the selection all vertices that are reachable from the+ currently selected vertices.</LI>++</UL><H3>Vertex Popup Actions</H3>diff --git a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplay.java b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplay.javaindex 8ac99e9f75..ab48cb329a 100644--- a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplay.java+++ b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplay.java@@ -81,6 +81,13 @@ public class DefaultGraphDisplay implements GraphDisplay {private static final String ACTION_OWNER = "GraphServices";private static final String FAVORED_EDGE = "Fall-Through";++ private static final String SELECTED_VERTEX_COLOR = "selectedVertexColor";+ private static final String SELECTED_EDGE_COLOR = "selectedEdgeColor";+ private static final String INITIAL_LAYOUT_ALGORITHM = "initialLayoutAlgorithm";+ private static final String DISPLAY_VERTICES_AS_ICONS = "displayVerticesAsIcons";+ private static final String VERTEX_LABEL_POSITION = "vertexLabelPosition";+private static final int MAX_NODES = Integer.getInteger("maxNodes", 10000);private static final Dimension PREFERRED_VIEW_SIZE = new Dimension(1000, 1000);private static final Dimension PREFERRED_LAYOUT_SIZE = new Dimension(3000, 3000);@@ -210,25 +217,28 @@ public class DefaultGraphDisplay implements GraphDisplay {connectSelectionStateListeners();}+ @Overridepublic void setProperty(String key, String value) {this.graphDisplayProperties.put(key, value);}- public String getProperty(String key) {+ @Override+ public String getValue(String key) {return graphDisplayProperties.get(key);}- public Map<String, String> getPropertyMap() {+ @Override+ public Map<String, String> getProperties() {return Collections.unmodifiableMap(graphDisplayProperties);}private Color getSelectedVertexColor() {- return Colors.getHexColor(graphDisplayProperties.getOrDefault("selectedVertexColor",+ return Colors.getHexColor(graphDisplayProperties.getOrDefault(SELECTED_VERTEX_COLOR,"0xFF0000"));}private Color getSelectedEdgeColor() {- return Colors.getHexColor(graphDisplayProperties.getOrDefault("selectedEdgeColor", "0xFF0000"));+ return Colors.getHexColor(graphDisplayProperties.getOrDefault(SELECTED_EDGE_COLOR, "0xFF0000"));}@@ -933,8 +943,8 @@ public class DefaultGraphDisplay implements GraphDisplay {}private void setInitialLayoutAlgorithm() {- if (graphDisplayProperties.containsKey("initialLayoutAlgorithm")) {- String layoutAlgorithmName = graphDisplayProperties.get("initialLayoutAlgorithm");+ if (graphDisplayProperties.containsKey(INITIAL_LAYOUT_ALGORITHM)) {+ String layoutAlgorithmName = graphDisplayProperties.get(INITIAL_LAYOUT_ALGORITHM);layoutTransitionManager.setLayout(layoutAlgorithmName);} else {LayoutAlgorithm<AttributedVertex> initialLayoutAlgorithm =@@ -1284,7 +1294,7 @@ public class DefaultGraphDisplay implements GraphDisplay {private void setVertexPreferences(VisualizationViewer<AttributedVertex, AttributedEdge> vv) {RenderContext<AttributedVertex, AttributedEdge> renderContext = vv.getRenderContext();- if (Boolean.parseBoolean(graphDisplayProperties.getOrDefault("displayVerticesAsIcons", "true"))) {+ if (Boolean.parseBoolean(graphDisplayProperties.getOrDefault(DISPLAY_VERTICES_AS_ICONS, "true"))) {// set up the shape and color functionsIconShapeFunction<AttributedVertex> nodeImageShapeFunction =new IconShapeFunction<>(new EllipseShapeFunction<>());@@ -1307,7 +1317,7 @@ public class DefaultGraphDisplay implements GraphDisplay {vv.getRenderContext().setVertexLabelFunction(Object::toString);vv.getRenderContext().setVertexLabelPosition(VertexLabel.Position.valueOf(- graphDisplayProperties.getOrDefault("vertexLabelPosition", "AUTO")));+ graphDisplayProperties.getOrDefault(VERTEX_LABEL_POSITION, "AUTO")));}}diff --git a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/GhidraIconCache.java b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/GhidraIconCache.javaindex 0b505b50a8..af47493d17 100644--- a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/GhidraIconCache.java+++ b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/GhidraIconCache.java@@ -197,11 +197,11 @@ public class GhidraIconCache {map.remove(vertex);}+ /**+ * Sets the vertex label to the value of the passed attribute name+ * @param attributeName the attribute key for the vertex label value to be displayed+ */public void setPreferredLabel(String attributeName) {this.preferredLabel = attributeName;}-- public void setLabelAlignment(int labelAlignment) {- this.labelAlignment = labelAlignment;- }}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplay.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplay.javaindex 382a130d8a..21370fee12 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplay.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplay.java@@ -35,8 +35,6 @@ public interface GraphDisplay {public static final int ALIGN_LEFT = 0; // aligns graph text to the leftpublic static final int ALIGN_CENTER = 1; // aligns graph text to the centerpublic static final int ALIGN_RIGHT = 2; // aligns graph text to the right- public static final int ALIGN_TOP = 3; // aligns graph text to the right- public static final int ALIGN_BOTTOM = 4; // aligns graph text to the right/*** Sets a {@link GraphDisplayListener} to be notified when the user changes the vertex focus@@ -112,7 +110,7 @@ public interface GraphDisplay {/*** Sets the name of the attribute which should be used as the primary vertex label in the display.* @param attributeName the name of the attribute to use as the display label for vertices.- * @param alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_TOP, or ALIGN_BOTTOM)+ * @param alignment (ALIGN_LEFT, ALIGN_RIGHT, or ALIGN_CENTER)* @param size the font size to use for the display label* @param monospace true if the font should be monospaced* @param maxLines the maximum number lines to display in the vertex labels@@ -157,13 +155,27 @@ public interface GraphDisplay {*/public void addAction(DockingAction action);+ /**+ * set a property key/value pair. This may be used to pass preferences to the implementation+ * @param key the property key+ * @param value the propery value+ */default void setProperty(String key, String value) {}+ /**+ *+ * @param key the key to fetch a value for+ * @return the value associated with the passed key+ */default String getValue(String key) {return null;}+ /**+ * Returns the property {@code Map} Should be implemented to pass an unmodifiable or copy+ * @return the complete {@code Map} of properties.+ */default Map<String, String> getProperties() {return Collections.emptyMap();}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplayProvider.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplayProvider.javaindex 2298b1f2e5..80b36c556e 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplayProvider.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/service/graph/GraphDisplayProvider.java@@ -46,6 +46,15 @@ public interface GraphDisplayProvider extends ExtensionPoint {*/public GraphDisplay getGraphDisplay(boolean reuseGraph, TaskMonitor monitor) throws GraphException;+ /**+ * Returns a GraphDisplay that can be used to "display" a graph+ *+ * @param reuseGraph if true, this provider will attempt to re-use an existing GraphDisplay+ * @param properties a {@code Map} of property key/values that can be used to customize the display+ * @param monitor the {@link TaskMonitor} that can be used to monitor and cancel the operation+ * @return A GraphDisplay that can be used to display (or otherwise consume - e.g. export) the graph+ * @throws GraphException thrown if there is a problem creating a GraphDisplay+ */default GraphDisplay getGraphDisplay(boolean reuseGraph, Map<String, String> properties,TaskMonitor monitor) throws GraphException {return getGraphDisplay(reuseGraph, monitor);diff --git a/certification.local.manifest b/certification.local.manifestindex 260e8d4092..beb26db281 100644--- a/certification.local.manifest+++ b/certification.local.manifest@@ -10,5 +10,3 @@ NOTICE||GHIDRA||||END|README.md||GHIDRA||||END|build.gradle||GHIDRA||||END|settings.gradle||GHIDRA||||END|-tldr.bat||GHIDRA||||END|-tldr.sh||GHIDRA||||END|