GT-2735 - Function Graph - show selection color when nodes are zoomed

out
This commit is contained in:
dragonmacher 2019-04-09 09:52:09 -04:00
parent 49c2010b63
commit c018c3bac5
6 changed files with 34 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import com.google.common.base.Function;
import edu.uci.ics.jung.visualization.picking.PickedInfo; import edu.uci.ics.jung.visualization.picking.PickedInfo;
import ghidra.app.plugin.core.functiongraph.graph.FGVertexType; import ghidra.app.plugin.core.functiongraph.graph.FGVertexType;
import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex; import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex;
import ghidra.program.util.ProgramSelection;
public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVertex, Paint> { public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVertex, Paint> {
@ -55,6 +56,15 @@ public class FGVertexPickableBackgroundPaintTransformer implements Function<FGVe
@Override @Override
public Paint apply(FGVertex v) { public Paint apply(FGVertex v) {
Color backgroundColor = v.getBackgroundColor(); Color backgroundColor = v.getBackgroundColor();
ProgramSelection selection = v.getProgramSelection();
if (!selection.isEmpty()) {
// mix the colors so the user can see both the selection and the background color
Color selectionColor = v.getSelectionColor();
Color mixed = mix(selectionColor, backgroundColor);
backgroundColor = mixed;
}
FGVertexType vertexType = v.getVertexType(); FGVertexType vertexType = v.getVertexType();
if (info.isPicked(v)) { if (info.isPicked(v)) {
if (v.isDefaultBackgroundColor()) { if (v.isDefaultBackgroundColor()) {

View File

@ -289,6 +289,11 @@ public abstract class AbstractFunctionGraphVertex implements FGVertex {
return doGetComponent().getBackgroundColor(); return doGetComponent().getBackgroundColor();
} }
@Override
public Color getSelectionColor() {
return doGetComponent().getSelectionColor();
}
@Override @Override
public void clearColor() { public void clearColor() {
doGetComponent().clearColor(); doGetComponent().clearColor();

View File

@ -90,6 +90,8 @@ public abstract class AbstractGraphComponentPanel extends JPanel {
abstract Color getBackgroundColor(); abstract Color getBackgroundColor();
abstract Color getSelectionColor();
abstract Color getUserDefinedColor(); abstract Color getUserDefinedColor();
abstract Color getDefaultBackgroundColor(); abstract Color getDefaultBackgroundColor();

View File

@ -86,6 +86,8 @@ public interface FGVertex extends VisualVertex {
public Color getBackgroundColor(); public Color getBackgroundColor();
public Color getSelectionColor();
public void setBackgroundColor(Color color); public void setBackgroundColor(Color color);
public void clearColor(); public void clearColor();
@ -205,5 +207,7 @@ public interface FGVertex extends VisualVertex {
*/ */
public void setShowing(boolean isShowing); public void setShowing(boolean isShowing);
@Override
public void dispose(); public void dispose();
} }

View File

@ -39,6 +39,7 @@ import ghidra.util.*;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
import ghidra.util.layout.VerticalLayout; import ghidra.util.layout.VerticalLayout;
import resources.ResourceManager; import resources.ResourceManager;
import util.CollectionUtils;
/** /**
* This panel looks similar in appearance to the LisGraphComponentPanel, with a header, actions * This panel looks similar in appearance to the LisGraphComponentPanel, with a header, actions
@ -414,6 +415,13 @@ public class GroupedFunctionGraphComponentPanel extends AbstractGraphComponentPa
return defaultBackgroundColor; return defaultBackgroundColor;
} }
@Override
Color getSelectionColor() {
Set<FGVertex> vertices = groupVertex.getVertices();
FGVertex v = CollectionUtils.any(vertices);
return v.getSelectionColor();
}
@Override @Override
JComponent getHeader() { JComponent getHeader() {
return genericHeader; return genericHeader;

View File

@ -261,6 +261,11 @@ public class ListingGraphComponentPanel extends AbstractGraphComponentPanel {
return listingPanel.getTextBackgroundColor(); return listingPanel.getTextBackgroundColor();
} }
@Override
Color getSelectionColor() {
return fieldPanel.getSelectionColor();
}
private void createActions() { private void createActions() {
String firstGroup = "group1"; String firstGroup = "group1";
String secondGroup = "group2"; String secondGroup = "group2";