mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-31 13:27:42 +08:00
GP-1981 - Checkpoint - Initial Theming
This commit is contained in:
+10
-6
@@ -21,6 +21,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.visualization.RenderContext;
|
||||
import edu.uci.ics.jung.visualization.picking.PickedState;
|
||||
@@ -45,9 +46,12 @@ import ghidra.util.UndefinedFunction;
|
||||
|
||||
public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph> {
|
||||
|
||||
private static final Color END_COLOR = new Color(255, 127, 127);
|
||||
private static final Color START_COLOR = new Color(127, 255, 127);
|
||||
private static final Color UNDEFINED_FUNCTION_COLOR = new Color(220, 220, 220);
|
||||
//@formatter:off
|
||||
private static final Color PICKED_COLOR = new GColor("color.bg.functiongraph.vertex.picked");
|
||||
private static final Color START_COLOR = new GColor("color.bg.functiongraph.vertex.entry");
|
||||
private static final Color END_COLOR = new GColor("color.bg.functiongraph.vertex.exit");
|
||||
private static final Color UNDEFINED_FUNCTION_COLOR = new GColor("color.bg.undefined");
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* A somewhat arbitrary value that is used to signal a 'big' graph, which is one that will
|
||||
@@ -206,7 +210,7 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
// for background colors when we are zoomed to far to render the listing
|
||||
PickedState<FGVertex> pickedVertexState = viewer.getPickedVertexState();
|
||||
renderContext.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
pickedVertexState, Color.YELLOW, START_COLOR, END_COLOR));
|
||||
pickedVertexState, PICKED_COLOR, START_COLOR, END_COLOR));
|
||||
|
||||
// edge label rendering
|
||||
com.google.common.base.Function<FGEdge, String> edgeLabelTransformer = e -> e.getLabel();
|
||||
@@ -233,7 +237,7 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
viewer.setBackground(UNDEFINED_FUNCTION_COLOR);
|
||||
}
|
||||
else {
|
||||
viewer.setBackground(Color.WHITE);
|
||||
viewer.setBackground(new GColor("color.bg.functiongraph"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +261,7 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
|
||||
PickedState<FGVertex> pickedVertexState = viewer.getPickedVertexState();
|
||||
renderContext.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
pickedVertexState, Color.YELLOW, START_COLOR, END_COLOR));
|
||||
pickedVertexState, PICKED_COLOR, START_COLOR, END_COLOR));
|
||||
|
||||
viewer.setGraphOptions(vgOptions);
|
||||
|
||||
|
||||
+23
-13
@@ -17,9 +17,11 @@ package ghidra.app.plugin.core.functiongraph.graph.jung.transformer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import docking.theme.Gui;
|
||||
import edu.uci.ics.jung.visualization.picking.PickedInfo;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.FGVertexType;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex;
|
||||
@@ -31,8 +33,8 @@ public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVe
|
||||
private final Color pickedColor;
|
||||
private final Color entryColor;
|
||||
private final Color exitColor;
|
||||
private final Color pickedStartColor;
|
||||
private final Color pickedEndColor;
|
||||
private final Color pickedEntryColor;
|
||||
private final Color pickedExitColor;
|
||||
|
||||
private static Color mix(Color c1, Color c2) {
|
||||
return new Color((c1.getRed() + c2.getRed()) / 2, (c1.getGreen() + c2.getGreen()) / 2,
|
||||
@@ -42,15 +44,12 @@ public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVe
|
||||
public FGVertexPickableBackgroundPaintTransformer(PickedInfo<FGVertex> info, Color pickedColor,
|
||||
Color startColor, Color endColor) {
|
||||
|
||||
if (info == null) {
|
||||
throw new IllegalArgumentException("PickedInfo instance must be non-null");
|
||||
}
|
||||
this.info = info;
|
||||
this.info = Objects.requireNonNull(info);
|
||||
this.pickedColor = pickedColor;
|
||||
this.entryColor = startColor;
|
||||
this.exitColor = endColor;
|
||||
this.pickedStartColor = mix(pickedColor, startColor);
|
||||
this.pickedEndColor = mix(pickedColor, endColor);
|
||||
this.pickedEntryColor = mix(pickedColor, startColor);
|
||||
this.pickedExitColor = mix(pickedColor, endColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,20 +68,31 @@ public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVe
|
||||
if (info.isPicked(v)) {
|
||||
if (v.isDefaultBackgroundColor()) {
|
||||
if (vertexType.isEntry()) {
|
||||
return pickedStartColor;
|
||||
return pickedEntryColor;
|
||||
}
|
||||
if (vertexType.isExit()) {
|
||||
return pickedEndColor;
|
||||
return pickedExitColor;
|
||||
}
|
||||
return pickedColor;
|
||||
}
|
||||
if (vertexType.isEntry()) {
|
||||
return pickedStartColor.darker();
|
||||
// this is a vertex that has a non-default, user-defined color; making the value
|
||||
// darker() is meant to signal that the 'picked entry color' is on top of a vertex
|
||||
// that has another color underneath
|
||||
return Gui.darker(pickedEntryColor);
|
||||
}
|
||||
if (vertexType.isExit()) {
|
||||
return pickedEndColor.darker();
|
||||
// this is a vertex that has a non-default, user-defined color; making the value
|
||||
// darker() is meant to signal that the 'picked exit color' is on top of a vertex
|
||||
// that has another color underneath
|
||||
return Gui.darker(pickedExitColor);
|
||||
}
|
||||
return pickedColor.darker();
|
||||
|
||||
// this is a vertex that has a non-default, user-defined color; making the value
|
||||
// darker() is meant to signal that the 'picked color' is on top of a vertex that has
|
||||
// another color underneath
|
||||
Color mixed = mix(pickedColor, backgroundColor);
|
||||
return Gui.darker(mixed);
|
||||
}
|
||||
|
||||
if (vertexType.isEntry()) {
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import java.awt.geom.Point2D;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors;
|
||||
import edu.uci.ics.jung.visualization.VisualizationViewer;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.FGEdge;
|
||||
import ghidra.app.plugin.core.functiongraph.mvc.FGController;
|
||||
@@ -133,7 +134,7 @@ public abstract class AbstractGraphComponentPanel extends JPanel {
|
||||
abstract ProgramLocation getProgramLocation();
|
||||
|
||||
boolean isDefaultBackgroundColor() {
|
||||
return getBackgroundColor().equals(Color.WHITE);
|
||||
return getBackgroundColor().equals(Colors.BACKGROUND);
|
||||
}
|
||||
|
||||
boolean isHeaderClick(Component clickedComponent) {
|
||||
|
||||
+2
-2
@@ -31,6 +31,7 @@ import docking.ActionContext;
|
||||
import docking.GenericHeader;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.ToolBarData;
|
||||
import docking.theme.GThemeDefaults.Colors;
|
||||
import docking.widgets.fieldpanel.FieldPanel;
|
||||
import docking.widgets.fieldpanel.Layout;
|
||||
import docking.widgets.fieldpanel.field.Field;
|
||||
@@ -204,7 +205,6 @@ public class ListingGraphComponentPanel extends AbstractGraphComponentPanel {
|
||||
previewListingPanel = new FGVertexListingPanel(controller,
|
||||
getFormatManager(useFullSizeTooltip), program, addressSet);
|
||||
previewListingPanel.setTextBackgroundColor(FGVertex.TOOLTIP_BACKGROUND_COLOR);
|
||||
// previewListingPanel.getFieldPanel().setSelectionMode( FieldPanel.NO_SELECTION );
|
||||
previewListingPanel.getFieldPanel().setCursorOn(false);
|
||||
|
||||
// keep the tooltip window from getting too big; use an arbitrary, reasonable max
|
||||
@@ -224,7 +224,7 @@ public class ListingGraphComponentPanel extends AbstractGraphComponentPanel {
|
||||
|
||||
JPanel headerPanel = new JPanel(new BorderLayout());
|
||||
headerPanel.add(tooltipTitleLabel);
|
||||
headerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
headerPanel.setBorder(BorderFactory.createLineBorder(Colors.Java.BORDER));
|
||||
|
||||
panel.add(headerPanel, BorderLayout.NORTH);
|
||||
panel.add(previewListingPanel, BorderLayout.CENTER);
|
||||
|
||||
+17
-19
@@ -19,6 +19,7 @@ import java.awt.Color;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import ghidra.app.plugin.core.functiongraph.FunctionGraphPlugin;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.layout.FGLayoutOptions;
|
||||
import ghidra.framework.options.Options;
|
||||
@@ -85,24 +86,21 @@ public class FunctionGraphOptions extends VisualGraphOptions {
|
||||
"Signals that any user color changes to a group vertex will apply that same color to " +
|
||||
"all grouped vertices as well.";
|
||||
|
||||
public static final Color DEFAULT_VERTEX_BACKGROUND_COLOR = Color.WHITE;
|
||||
public static final Color DEFAULT_GROUP_BACKGROUND_COLOR = new Color(226, 255, 155);
|
||||
private static final Color HOVER_HIGHLIGHT_FALL_THROUGH_COLOR = new Color(255, 127, 127);
|
||||
private static final Color HOVER_HIGHLIGHT_UNCONDITIONAL_COLOR = new Color(127, 127, 255);
|
||||
private static final Color HOVER_HIGHLIGHT_CONDITIONAL_COLOR = Color.GREEN;
|
||||
|
||||
private Color defaultVertexBackgroundColor = DEFAULT_VERTEX_BACKGROUND_COLOR;
|
||||
|
||||
private boolean updateGroupColorsAutomatically = true;
|
||||
private Color defaultGroupBackgroundColor = DEFAULT_GROUP_BACKGROUND_COLOR;
|
||||
|
||||
private Color fallthroughEdgeColor = Color.RED;
|
||||
private Color unconditionalJumpEdgeColor = Color.BLUE;
|
||||
private Color conditionalJumpEdgeColor = Color.GREEN.darker().darker();
|
||||
//@formatter:off
|
||||
public static final Color DEFAULT_GROUP_BACKGROUND_COLOR = new GColor("color.bg.functiongraph.vertex.group");
|
||||
private Color defaultVertexBackgroundColor = new GColor("color.bg.functiongraph");
|
||||
private Color defaultGroupBackgroundColor = new GColor("color.bg.functiongraph.vertex.group");
|
||||
|
||||
private Color fallthroughEdgeHighlightColor = HOVER_HIGHLIGHT_FALL_THROUGH_COLOR;
|
||||
private Color unconditionalJumpEdgeHighlightColor = HOVER_HIGHLIGHT_UNCONDITIONAL_COLOR;
|
||||
private Color conditionalJumpEdgeHighlightColor = HOVER_HIGHLIGHT_CONDITIONAL_COLOR;
|
||||
private Color fallthroughEdgeColor = new GColor("color.bg.functiongraph.edge.fall-through");
|
||||
private Color conditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.conditional");
|
||||
private Color unconditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.unconditional");
|
||||
|
||||
private Color fallthroughEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.fall-through.highlight");
|
||||
private Color conditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.conditional.highlight");
|
||||
private Color unconditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.unconditional.highlight");
|
||||
//@formatter:on
|
||||
|
||||
private boolean useFullSizeTooltip = false;
|
||||
|
||||
@@ -174,10 +172,10 @@ public class FunctionGraphOptions extends VisualGraphOptions {
|
||||
options.registerOption(USE_CONDENSED_LAYOUT_KEY, useCondensedLayout(),
|
||||
new HelpLocation(OWNER, "Layout_Compressing"), USE_CONDENSED_LAYOUT_DESCRIPTION);
|
||||
|
||||
options.registerOption(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, DEFAULT_VERTEX_BACKGROUND_COLOR,
|
||||
options.registerOption(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, defaultVertexBackgroundColor,
|
||||
help, DEFAULT_VERTEX_BACKGROUND_COLOR_DESCRPTION);
|
||||
|
||||
options.registerOption(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, DEFAULT_GROUP_BACKGROUND_COLOR,
|
||||
options.registerOption(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, defaultGroupBackgroundColor,
|
||||
help, DEFAULT_GROUP_BACKGROUND_COLOR_DESCRPTION);
|
||||
|
||||
options.registerOption(UPDATE_GROUP_AND_UNGROUP_COLORS, updateGroupColorsAutomatically,
|
||||
@@ -238,10 +236,10 @@ public class FunctionGraphOptions extends VisualGraphOptions {
|
||||
useFullSizeTooltip = options.getBoolean(USE_FULL_SIZE_TOOLTIP_KEY, useFullSizeTooltip);
|
||||
|
||||
defaultVertexBackgroundColor =
|
||||
options.getColor(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, DEFAULT_VERTEX_BACKGROUND_COLOR);
|
||||
options.getColor(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, defaultVertexBackgroundColor);
|
||||
|
||||
defaultGroupBackgroundColor =
|
||||
options.getColor(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, DEFAULT_GROUP_BACKGROUND_COLOR);
|
||||
options.getColor(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, defaultGroupBackgroundColor);
|
||||
|
||||
updateGroupColorsAutomatically =
|
||||
options.getBoolean(UPDATE_GROUP_AND_UNGROUP_COLORS, updateGroupColorsAutomatically);
|
||||
|
||||
Reference in New Issue
Block a user