mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
GP-1981 - Graph Theme Updates
This commit is contained in:
parent
50de9eb7b3
commit
ae02a34d8b
@ -16,7 +16,6 @@ data/ElfFunctionsThatDoNotReturn||GHIDRA||||END|
|
||||
data/ExtensionPoint.manifest||GHIDRA||||END|
|
||||
data/MachOFunctionsThatDoNotReturn||GHIDRA||||END|
|
||||
data/PEFunctionsThatDoNotReturn||GHIDRA||||END|
|
||||
data/base.functiongraph.theme.properties||GHIDRA||||END|
|
||||
data/base.listing.theme.properties||GHIDRA||||END|
|
||||
data/base.theme.properties||GHIDRA||||END|
|
||||
data/decompiler.theme.properties||GHIDRA||||END|
|
||||
|
@ -1,7 +1,7 @@
|
||||
[Defaults]
|
||||
|
||||
color.bg.listing = color.bg
|
||||
color.bg.currentline.listing = color.bg.currentline
|
||||
color.bg.currentline.listing = color.bg.currentline
|
||||
color.bg.selection.listing = color.bg.selection
|
||||
color.bg.highlight.listing = color.bg.highlight
|
||||
|
||||
|
@ -14,7 +14,7 @@ color.bg.functiongraph.vertex.picked = color.palette.yellow
|
||||
color.bg.functiongraph.edge.fall-through = color.flowtype.fall-through
|
||||
color.bg.functiongraph.edge.fall-through.highlight = rgb(255, 127, 127)
|
||||
color.bg.functiongraph.edge.jump.conditional = color.flowtype.jump.conditional
|
||||
color.bg.functiongraph.edge.jump.conditional.highlight = green
|
||||
color.bg.functiongraph.edge.jump.conditional.highlight = lime
|
||||
color.bg.functiongraph.edge.jump.unconditional = color.flowtype.jump.unconditional
|
||||
color.bg.functiongraph.edge.jump.unconditional.highlight = rgb(127, 127, 255)
|
||||
|
||||
|
@ -27,7 +27,6 @@ import edu.uci.ics.jung.visualization.RenderContext;
|
||||
import edu.uci.ics.jung.visualization.picking.PickedState;
|
||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||
import edu.uci.ics.jung.visualization.util.Caching;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.jung.renderer.FGEdgePaintTransformer;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.jung.renderer.FGVertexRenderer;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.jung.transformer.FGVertexPickableBackgroundPaintTransformer;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.layout.FGLayout;
|
||||
@ -38,6 +37,7 @@ import ghidra.graph.viewer.layout.LayoutListener.ChangeType;
|
||||
import ghidra.graph.viewer.layout.LayoutProvider;
|
||||
import ghidra.graph.viewer.layout.VisualGraphLayout;
|
||||
import ghidra.graph.viewer.renderer.VisualGraphEdgeLabelRenderer;
|
||||
import ghidra.graph.viewer.vertex.AbstractVisualVertexRenderer;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.util.SystemUtilities;
|
||||
@ -193,23 +193,25 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
@Override
|
||||
protected FGPrimaryViewer createPrimaryGraphViewer(VisualGraphLayout<FGVertex, FGEdge> layout,
|
||||
Dimension viewerSize) {
|
||||
return new FGPrimaryViewer(this, layout, viewerSize);
|
||||
}
|
||||
|
||||
FGPrimaryViewer viewer = new FGPrimaryViewer(this, layout, viewerSize);
|
||||
@Override
|
||||
protected void decoratePrimaryViewer(GraphViewer<FGVertex, FGEdge> viewer,
|
||||
VisualGraphLayout<FGVertex, FGEdge> layout) {
|
||||
|
||||
RenderContext<FGVertex, FGEdge> renderContext = viewer.getRenderContext();
|
||||
FGEdgePaintTransformer edgePaintTransformer =
|
||||
new FGEdgePaintTransformer(getFucntionGraphOptions());
|
||||
renderContext.setEdgeDrawPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowDrawPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowFillPaintTransformer(edgePaintTransformer);
|
||||
super.decoratePrimaryViewer(viewer, layout);
|
||||
|
||||
// the edge renderer was set by the parent call; get the renderer to add our painter
|
||||
Renderer<FGVertex, FGEdge> renderer = viewer.getRenderer();
|
||||
renderer.setVertexRenderer(new FGVertexRenderer());
|
||||
RenderContext<FGVertex, FGEdge> renderContext = viewer.getRenderContext();
|
||||
|
||||
// for background colors when we are zoomed to far to render the listing
|
||||
PickedState<FGVertex> pickedVertexState = viewer.getPickedVertexState();
|
||||
renderContext.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
FGVertexRenderer vertexRenderer = new FGVertexRenderer();
|
||||
vertexRenderer.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
pickedVertexState, PICKED_COLOR, START_COLOR, END_COLOR));
|
||||
renderer.setVertexRenderer(vertexRenderer);
|
||||
|
||||
// edge label rendering
|
||||
com.google.common.base.Function<FGEdge, String> edgeLabelTransformer = e -> e.getLabel();
|
||||
@ -240,31 +242,29 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
}
|
||||
}
|
||||
|
||||
return viewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SatelliteGraphViewer<FGVertex, FGEdge> createSatelliteGraphViewer(
|
||||
GraphViewer<FGVertex, FGEdge> masterViewer, Dimension viewerSize) {
|
||||
protected void decorateSatelliteViewer(SatelliteGraphViewer<FGVertex, FGEdge> viewer,
|
||||
VisualGraphLayout<FGVertex, FGEdge> layout) {
|
||||
|
||||
SatelliteGraphViewer<FGVertex, FGEdge> viewer =
|
||||
super.createSatelliteGraphViewer(masterViewer, viewerSize);
|
||||
super.decorateSatelliteViewer(viewer, layout);
|
||||
|
||||
RenderContext<FGVertex, FGEdge> renderContext = viewer.getRenderContext();
|
||||
// the edge renderer was set by the parent call; get the renderer to add our painter
|
||||
Renderer<FGVertex, FGEdge> renderer = viewer.getRenderer();
|
||||
|
||||
FGEdgePaintTransformer edgePaintTransformer =
|
||||
new FGEdgePaintTransformer(getFucntionGraphOptions());
|
||||
renderContext.setEdgeDrawPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowDrawPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowFillPaintTransformer(edgePaintTransformer);
|
||||
AbstractVisualVertexRenderer<FGVertex, FGEdge> vertexRenderer =
|
||||
(AbstractVisualVertexRenderer<FGVertex, FGEdge>) renderer.getVertexRenderer();
|
||||
|
||||
PickedState<FGVertex> pickedVertexState = viewer.getPickedVertexState();
|
||||
|
||||
RenderContext<FGVertex, FGEdge> renderContext = viewer.getRenderContext();
|
||||
renderContext.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
pickedVertexState, PICKED_COLOR, START_COLOR, END_COLOR));
|
||||
vertexRenderer.setVertexFillPaintTransformer(new FGVertexPickableBackgroundPaintTransformer(
|
||||
pickedVertexState, PICKED_COLOR, START_COLOR, END_COLOR));
|
||||
|
||||
viewer.setGraphOptions(vgOptions);
|
||||
|
||||
return viewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -289,7 +289,7 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
|
||||
// FG-specific Client Methods
|
||||
//==================================================================================================
|
||||
|
||||
public FunctionGraphOptions getFucntionGraphOptions() {
|
||||
public FunctionGraphOptions getFunctionGraphOptions() {
|
||||
return (FunctionGraphOptions) vgOptions;
|
||||
}
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.core.functiongraph.graph.jung.renderer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import ghidra.app.plugin.core.functiongraph.graph.FGEdge;
|
||||
import ghidra.app.plugin.core.functiongraph.mvc.FunctionGraphOptions;
|
||||
import ghidra.program.model.symbol.FlowType;
|
||||
|
||||
public class FGEdgePaintTransformer implements Function<FGEdge, Paint> {
|
||||
|
||||
private FunctionGraphOptions options;
|
||||
|
||||
public FGEdgePaintTransformer(FunctionGraphOptions options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint apply(FGEdge e) {
|
||||
FlowType flowType = e.getFlowType();
|
||||
Color color = options.getColor(flowType);
|
||||
return color;
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import ghidra.app.plugin.core.functiongraph.graph.FunctionGraph;
|
||||
import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex;
|
||||
import ghidra.app.plugin.core.functiongraph.mvc.FunctionGraphOptions;
|
||||
import ghidra.graph.viewer.renderer.ArticulatedEdgeRenderer;
|
||||
import ghidra.program.model.symbol.FlowType;
|
||||
|
||||
/**
|
||||
* A renderer used by the Function Graph API to provide additional edge coloring, as
|
||||
@ -31,13 +32,21 @@ import ghidra.graph.viewer.renderer.ArticulatedEdgeRenderer;
|
||||
public class FGEdgeRenderer extends ArticulatedEdgeRenderer<FGVertex, FGEdge> {
|
||||
|
||||
@Override
|
||||
public Color getBaseColor(Graph<FGVertex, FGEdge> g, FGEdge e) {
|
||||
public Color getDrawColor(Graph<FGVertex, FGEdge> g, FGEdge e) {
|
||||
FunctionGraphOptions options = getOptions(g);
|
||||
FlowType flowType = e.getFlowType();
|
||||
Color color = options.getColor(flowType);
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFocusedColor(Graph<FGVertex, FGEdge> g, FGEdge e) {
|
||||
FunctionGraphOptions options = getOptions(g);
|
||||
return options.getColor(e.getFlowType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getHighlightColor(Graph<FGVertex, FGEdge> g, FGEdge e) {
|
||||
public Color getSelectedColor(Graph<FGVertex, FGEdge> g, FGEdge e) {
|
||||
FunctionGraphOptions options = getOptions(g);
|
||||
return options.getHighlightColor(e.getFlowType());
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ class GroupedVertexInfo extends VertexInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
String superString = super.toString();
|
||||
StringBuffer buffy = new StringBuffer(superString);
|
||||
StringBuilder buffy = new StringBuilder(superString);
|
||||
buffy.append('\n');
|
||||
for (VertexInfo info : vertexInfos) {
|
||||
buffy.append('\t').append(info.toString()).append('\n');
|
||||
|
@ -1,7 +1,7 @@
|
||||
##VERSION: 2.0
|
||||
##MODULE IP: Oxygen Icons - LGPL 3.0
|
||||
Module.manifest||GHIDRA||||END|
|
||||
data/functioncall.theme.properties||GHIDRA||||END|
|
||||
data/functioncallgraph.theme.properties||GHIDRA||||END|
|
||||
src/main/help/help/TOC_Source.xml||GHIDRA||||END|
|
||||
src/main/help/help/shared/arrow.gif||GHIDRA||||END|
|
||||
src/main/help/help/shared/close16.gif||GHIDRA||||END|
|
||||
|
@ -1,10 +1,12 @@
|
||||
[Defaults]
|
||||
|
||||
color.bg.fcg.vertex.default = rgb(110, 197, 174) // chill green
|
||||
color.bg.fcg.vertex.toobig = color.palette.lightGray
|
||||
color.bg.fcg.vertex.toobig = color.palette.lightgray
|
||||
|
||||
color.bg.fcg.edge.primary.direct = rgb(143, 197, 143) // lightGreen
|
||||
color.bg.fcg.edge.primary.indirect = rgb(233, 233, 233) // lightGray
|
||||
color.bg.fcg.edge.primary.direct = rgb(143, 197, 143) // light pale green
|
||||
color.bg.fcg.edge.primary.direct.selected = rgb(68, 171, 96) // lighter green
|
||||
color.bg.fcg.edge.primary.indirect = rgb(233, 233, 233) // lightGray
|
||||
color.bg.fcg.edge.primary.indirect.selected = rgb(201, 195, 195)
|
||||
|
||||
// the satellite gets too cluttered, so wash out the edges
|
||||
color.bg.fcg.edge.satellite.direct = rgba(0,0,0,0.1) // 'washed out black'
|
@ -28,6 +28,7 @@ import javax.swing.border.LineBorder;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import docking.theme.Gui;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import ghidra.graph.viewer.vertex.AbstractVisualVertex;
|
||||
@ -45,7 +46,7 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid
|
||||
|
||||
//@formatter:off
|
||||
public static final Color DEFAULT_VERTEX_SHAPE_COLOR = new GColor("color.bg.fcg.vertex.default");
|
||||
private static final Color TOO_BIG_VERTEX_SHAPE_COLOR = new GColor("color.bg.fcg.vertex.toobig ");
|
||||
private static final Color TOO_BIG_VERTEX_SHAPE_COLOR = new GColor("color.bg.fcg.vertex.toobig");
|
||||
//@formatter:on
|
||||
|
||||
public static final Icon NOT_ALLOWED_ICON = Icons.ERROR_ICON;
|
||||
@ -55,9 +56,9 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid
|
||||
ResourceManager.getScaledIcon(Icons.COLLAPSE_ALL_ICON, 10, 10);
|
||||
|
||||
// higher numbered layers go on top
|
||||
private static final Integer VERTEX_SHAPE_LAYER = new Integer(100);
|
||||
private static final Integer TOGGLE_BUTTON_LAYER = new Integer(200);
|
||||
private static final Integer LABEL_LAYER = new Integer(300);
|
||||
private static final Integer VERTEX_SHAPE_LAYER = 100;
|
||||
private static final Integer TOGGLE_BUTTON_LAYER = 200;
|
||||
private static final Integer LABEL_LAYER = 300;
|
||||
|
||||
private static final int GAP = 2;
|
||||
private static final int VERTEX_SHAPE_SIZE = 50;
|
||||
@ -131,8 +132,8 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid
|
||||
Color vertexShapeColor = getVertexShapeColor();
|
||||
|
||||
Color lightColor = vertexShapeColor;
|
||||
Color darkColor = vertexShapeColor.darker();
|
||||
Color darkestColor = darkColor.darker();
|
||||
Color darkColor = Gui.darker(vertexShapeColor);
|
||||
Color darkestColor = Gui.darker(darkColor);
|
||||
int offset = 5 * level.getDistance();
|
||||
int half = VERTEX_SHAPE_SIZE / 2;
|
||||
int start = 0;
|
||||
@ -159,7 +160,7 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid
|
||||
|
||||
// calculate the needed size
|
||||
layeredPane = new JLayeredPane();
|
||||
Border border = createDebugBorder(new LineBorder(Color.YELLOW.darker(), 1));
|
||||
Border border = createDebugBorder(new LineBorder(Palette.GOLD, 1));
|
||||
layeredPane.setBorder(border);
|
||||
|
||||
updateLayeredPaneSize();
|
||||
@ -549,7 +550,7 @@ public class FcgVertex extends AbstractVisualVertex implements VertexShapeProvid
|
||||
/**
|
||||
* Sets whether this vertex has any outgoing references
|
||||
*
|
||||
* @param hasIncoming true if this vertex has any incoming references
|
||||
* @param hasOutgoing true if this vertex has any outgoing references
|
||||
*/
|
||||
|
||||
public void setHasOutgoingReferences(boolean hasOutgoing) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
package functioncalls.graph.renderer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
@ -26,7 +25,7 @@ import ghidra.util.ColorUtils;
|
||||
/**
|
||||
* Generates colors for a given {@link FcgEdge}
|
||||
*/
|
||||
public class FcgEdgePaintTransformer implements Function<FcgEdge, Paint> {
|
||||
public class FcgEdgePaintTransformer implements Function<FcgEdge, Color> {
|
||||
|
||||
private Color directColor;
|
||||
private Color indirectColor;
|
||||
@ -52,7 +51,7 @@ public class FcgEdgePaintTransformer implements Function<FcgEdge, Paint> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint apply(FcgEdge e) {
|
||||
public Color apply(FcgEdge e) {
|
||||
if (e.isDirectEdge()) {
|
||||
return getDirectEdgeColor(e);
|
||||
}
|
||||
|
@ -16,13 +16,16 @@
|
||||
package functioncalls.graph.view;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import edu.uci.ics.jung.visualization.RenderContext;
|
||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||
import functioncalls.graph.*;
|
||||
import functioncalls.graph.renderer.FcgEdgePaintTransformer;
|
||||
import functioncalls.graph.renderer.FcgVertexPaintTransformer;
|
||||
import functioncalls.plugin.FunctionCallGraphPlugin;
|
||||
import ghidra.graph.viewer.*;
|
||||
import ghidra.graph.viewer.edge.VisualEdgeRenderer;
|
||||
import ghidra.graph.viewer.layout.VisualGraphLayout;
|
||||
import ghidra.graph.viewer.renderer.VisualVertexSatelliteRenderer;
|
||||
import ghidra.graph.viewer.vertex.VisualVertexRenderer;
|
||||
|
||||
/**
|
||||
* A graph component for the {@link FunctionCallGraphPlugin}
|
||||
@ -32,13 +35,15 @@ public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCal
|
||||
// our parent stores a reference to this graph, but we do it here to maintain its type
|
||||
private FunctionCallGraph fcGraph;
|
||||
|
||||
// TODO use options for color
|
||||
private FcgVertexPaintTransformer vertexPaintTransformer =
|
||||
new FcgVertexPaintTransformer(FcgVertex.DEFAULT_VERTEX_SHAPE_COLOR);
|
||||
|
||||
private FcgEdgePaintTransformer edgePaintTransformer =
|
||||
new FcgEdgePaintTransformer(new GColor("color.bg.fcg.edge.primary.direct"),
|
||||
new GColor("color.bg.fcg.edge.primary.indirect"));
|
||||
private FcgEdgePaintTransformer selectedEdgePaintTransformer =
|
||||
new FcgEdgePaintTransformer(new GColor("color.bg.fcg.edge.primary.direct.selected"),
|
||||
new GColor("color.bg.fcg.edge.primary.indirect.selected"));
|
||||
private FcgEdgePaintTransformer satelliteEdgePaintTransformer =
|
||||
new FcgEdgePaintTransformer(new GColor("color.bg.fcg.edge.satellite.direct"),
|
||||
new GColor("color.bg.fcg.edge.satellite.indirect"));
|
||||
@ -59,15 +64,15 @@ public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCal
|
||||
|
||||
super.decoratePrimaryViewer(viewer, layout);
|
||||
|
||||
RenderContext<FcgVertex, FcgEdge> renderContext = viewer.getRenderContext();
|
||||
renderContext.setVertexFillPaintTransformer(vertexPaintTransformer);
|
||||
Renderer<FcgVertex, FcgEdge> renderer = viewer.getRenderer();
|
||||
VisualVertexRenderer<FcgVertex, FcgEdge> vertexRenderer =
|
||||
(VisualVertexRenderer<FcgVertex, FcgEdge>) renderer.getVertexRenderer();
|
||||
vertexRenderer.setVertexFillPaintTransformer(vertexPaintTransformer);
|
||||
|
||||
// Note: setting the fill for the edges has the effect of drawing a filled-in circle
|
||||
// instead of just the outer edge.
|
||||
// renderContext.setEdgeFillPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setEdgeDrawPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowFillPaintTransformer(edgePaintTransformer);
|
||||
renderContext.setArrowDrawPaintTransformer(edgePaintTransformer);
|
||||
VisualEdgeRenderer<FcgVertex, FcgEdge> edgeRenderer =
|
||||
(VisualEdgeRenderer<FcgVertex, FcgEdge>) renderer.getEdgeRenderer();
|
||||
edgeRenderer.setDrawColorTransformer(edgePaintTransformer);
|
||||
edgeRenderer.setSelectedColorTransformer(selectedEdgePaintTransformer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,12 +81,14 @@ public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCal
|
||||
|
||||
super.decorateSatelliteViewer(viewer, layout);
|
||||
|
||||
RenderContext<FcgVertex, FcgEdge> renderContext = viewer.getRenderContext();
|
||||
renderContext.setVertexFillPaintTransformer(vertexPaintTransformer);
|
||||
//renderContext.setEdgeFillPaintTransformer(satelliteEdgePaintTransformer);
|
||||
renderContext.setEdgeDrawPaintTransformer(satelliteEdgePaintTransformer);
|
||||
renderContext.setArrowFillPaintTransformer(satelliteEdgePaintTransformer);
|
||||
renderContext.setArrowDrawPaintTransformer(satelliteEdgePaintTransformer);
|
||||
Renderer<FcgVertex, FcgEdge> renderer = viewer.getRenderer();
|
||||
VisualVertexSatelliteRenderer<FcgVertex, FcgEdge> vertexRenderer =
|
||||
(VisualVertexSatelliteRenderer<FcgVertex, FcgEdge>) renderer.getVertexRenderer();
|
||||
vertexRenderer.setVertexFillPaintTransformer(vertexPaintTransformer);
|
||||
|
||||
VisualEdgeRenderer<FcgVertex, FcgEdge> edgeRenderer =
|
||||
(VisualEdgeRenderer<FcgVertex, FcgEdge>) renderer.getEdgeRenderer();
|
||||
edgeRenderer.setDrawColorTransformer(satelliteEdgePaintTransformer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,16 +3,36 @@
|
||||
color.palette.nocolor = rgba(255,255,255,0)
|
||||
|
||||
color.palette.black = black
|
||||
color.palette.blue = blue
|
||||
color.palette.crimson = crimson
|
||||
color.palette.cyan = cyan
|
||||
color.palette.lightGray = rgb(192, 192, 192)
|
||||
color.palette.darkblue = DarkBlue
|
||||
color.palette.darkkhaki = DarkKhaki
|
||||
color.palette.dodgerblue = DodgerBlue
|
||||
color.palette.gold = gold
|
||||
color.palette.gray = gray
|
||||
color.palette.green = green
|
||||
color.palette.khaki = khaki
|
||||
color.palette.lavender = lavender
|
||||
color.palette.lime = lime
|
||||
color.palette.lightgray = rgb(192, 192, 192)
|
||||
color.palette.lightgreen = rgb(127, 255, 127)
|
||||
color.palette.lightred = rgb(255, 127, 127)
|
||||
color.palette.magenta = magenta
|
||||
color.palette.mistyrose = mistyrose
|
||||
color.palette.olive = olive
|
||||
color.palette.orange = orange
|
||||
color.palette.palegreen = palegreen
|
||||
color.palette.palevioletred = PaleVioletRed
|
||||
color.palette.pink = pink
|
||||
color.palette.red = red
|
||||
color.palette.yellow = yellow
|
||||
color.palette.yellowgreen = yellowgreen
|
||||
color.palette.white = white
|
||||
|
||||
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
// TODO replace values above with dark values
|
||||
// TODO replace values above with dark values
|
||||
color.palette.black = lightgray
|
@ -48,8 +48,8 @@ color.bg.fieldpanel.selection-highlight = green
|
||||
[Dark Defaults]
|
||||
|
||||
color.bg = rgb(40, 42, 46)
|
||||
color.fg = gray
|
||||
color.bg.currentline = rgb(60,60,70)
|
||||
color.fg = lightgray
|
||||
color.bg.currentline = rgb(60,60,70) // dark gray
|
||||
|
||||
color.cursor.focused = indianRed
|
||||
color.cursor.unfocussed = darkGray
|
||||
@ -59,7 +59,7 @@ color.bg.textfield.hint.invalid = maroon
|
||||
color.bg.selection = teal
|
||||
color.bg.highlight = rgb(110,110,0)
|
||||
|
||||
color.bg.fieldpanel.select-highlight = darkGreen
|
||||
color.bg.fieldpanel.selection-highlight = darkGreen
|
||||
|
||||
color.bg.tableheader.gradient.start = color.bg
|
||||
color.bg.tableheader.gradient.end = darkGray
|
||||
|
@ -47,6 +47,16 @@ public class GColor extends Color implements Refreshable {
|
||||
|
||||
}
|
||||
|
||||
private GColor(String id, int alpha) {
|
||||
this(id);
|
||||
|
||||
delegate = new Color(delegate.getRed(), delegate.getGreen(), delegate.getBlue(), alpha);
|
||||
}
|
||||
|
||||
public GColor withAlpha(int alpha) {
|
||||
return new GColor(id, alpha);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -165,7 +175,8 @@ public class GColor extends Color implements Refreshable {
|
||||
public void refresh() {
|
||||
Color color = Gui.getRawColor(id, false);
|
||||
if (color != null) {
|
||||
delegate = color;
|
||||
int alpha = delegate.getAlpha();
|
||||
delegate = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
|
||||
}
|
||||
else {
|
||||
System.out.println("Hey");
|
||||
|
@ -48,19 +48,29 @@ public class GThemeDefaults {
|
||||
//@formatter:on
|
||||
|
||||
public static class Java {
|
||||
public static final Color BORDER = new GColor(Ids.Java.BORDER);
|
||||
public static final GColor BORDER = new GColor(Ids.Java.BORDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic palette colors, using color names, that may be changed along with the theme
|
||||
*/
|
||||
public static class Palette {
|
||||
|
||||
/** Transparent color */
|
||||
public static final Color NO_COLOR = new GColor("color.palette.nocolor");
|
||||
|
||||
public static final Color BLACK = new GColor("color.palette.black");
|
||||
public static final Color CYAN = new GColor("color.palette.cyan");
|
||||
public static final Color RED = new GColor("color.palette.red");
|
||||
public static final Color WHITE = new GColor("color.palette.white");
|
||||
public static final GColor BLACK = new GColor("color.palette.black");
|
||||
public static final GColor BLUE = new GColor("color.palette.blue");
|
||||
public static final GColor CYAN = new GColor("color.palette.cyan");
|
||||
public static final GColor GOLD = new GColor("color.palette.gold");
|
||||
public static final GColor GRAY = new GColor("color.palette.gray");
|
||||
public static final GColor GREEN = new GColor("color.palette.green");
|
||||
public static final GColor LIME = new GColor("color.palette.lime");
|
||||
public static final GColor ORANGE = new GColor("color.palette.orange");
|
||||
public static final GColor PINK = new GColor("color.palette.pink");
|
||||
public static final GColor RED = new GColor("color.palette.red");
|
||||
public static final GColor WHITE = new GColor("color.palette.white");
|
||||
public static final GColor YELLOW = new GColor("color.palette.yellow");
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import javax.swing.event.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.widgets.label.GDHtmlLabel;
|
||||
import docking.widgets.list.GList;
|
||||
import generic.util.WindowUtilities;
|
||||
@ -573,7 +574,9 @@ public class DropDownTextField<T> extends JTextField implements GComponent {
|
||||
matchingWindow.setFocusable(false);
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBorder(
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.GRAY, Color.BLACK));
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED,
|
||||
new GColor("color.border.bevel.highlight"),
|
||||
new GColor("color.border.bevel.shadow")));
|
||||
scrollPane.setFocusable(false);
|
||||
scrollPane.getVerticalScrollBar().setFocusable(false);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
@ -30,6 +30,7 @@ import javax.swing.text.Caret;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.DockingUtils.TreeTraversalResult;
|
||||
import docking.theme.GColor;
|
||||
import docking.widgets.textfield.TextFieldLinker;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.util.task.SwingUpdateManager;
|
||||
@ -131,9 +132,13 @@ public class TextFieldAutocompleter<T> {
|
||||
// Prepare all the swing components (except the window)
|
||||
{
|
||||
content.setBorder(
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.LIGHT_GRAY, Color.GRAY));
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED,
|
||||
new GColor("color.border.bevel.highlight"),
|
||||
new GColor("color.border.bevel.shadow")));
|
||||
scrollPane.setBorder(
|
||||
BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.GRAY));
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED,
|
||||
new GColor("color.border.bevel.highlight"),
|
||||
new GColor("color.border.bevel.shadow")));
|
||||
//content.setFocusable(false);
|
||||
|
||||
scrollPane.getVerticalScrollBar().setFocusable(false);
|
||||
@ -1094,7 +1099,7 @@ public class TextFieldAutocompleter<T> {
|
||||
|
||||
dual.setVisible(true);
|
||||
|
||||
AutocompletionModel<String> model = new AutocompletionModel<String>() {
|
||||
AutocompletionModel<String> model = new AutocompletionModel<>() {
|
||||
Set<String> strings =
|
||||
new HashSet<>(Arrays.asList(new String[] { "Test", "Testing", "Another",
|
||||
"Yet another", "Yet still more", "Yet still even more", "Yetis, yo" }));
|
||||
@ -1110,7 +1115,7 @@ public class TextFieldAutocompleter<T> {
|
||||
return matching;
|
||||
}
|
||||
};
|
||||
TextFieldAutocompleter<String> auto = new TextFieldAutocompleter<String>(model) {
|
||||
TextFieldAutocompleter<String> auto = new TextFieldAutocompleter<>(model) {
|
||||
@Override
|
||||
protected String getPrefix(JTextField field) {
|
||||
return dual.getTextBeforeCursor(field);
|
||||
|
@ -150,7 +150,7 @@ public abstract class WebColors {
|
||||
public static final Color MISTY_ROSE = registerColor("MistyRose", Color.decode("0xFFE4E1"));
|
||||
public static final Color BLANCHED_ALMOND = registerColor("BlanchedAlmond", Color.decode("0xFFEBCD"));
|
||||
public static final Color PAPAYA_WHIP = registerColor("PapayaWhip", Color.decode("0xFFEFD5"));
|
||||
public static final Color LAVENDAR_BLUSH = registerColor("LavenderBlush", Color.decode("0xFFF0F5"));
|
||||
public static final Color LAVENDER_BLUSH = registerColor("LavenderBlush", Color.decode("0xFFF0F5"));
|
||||
public static final Color SEASHELL = registerColor("SeaShell", Color.decode("0xFFF5EE"));
|
||||
public static final Color CORNSILK = registerColor("Cornsilk", Color.decode("0xFFF8DC"));
|
||||
public static final Color LEMON_CHIFFON = registerColor("LemonChiffon", Color.decode("0xFFFACD"));
|
||||
|
@ -20,12 +20,13 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class for storing weak reference to object instances. Objects of type T can be place
|
||||
* in this store and they will remain there until there are no references to that object
|
||||
* remaining. Note that this is not a Set and you can have multiple instances that are
|
||||
* "equal" in this store.The main purpose of this store is to be able to get all objects
|
||||
* in the store that are still reference; typically to refresh or "kick" them in some manner.
|
||||
* Could be useful for a thread safe weak listener list.
|
||||
* Class for storing weak reference to object instances. Objects of type T can be place in this
|
||||
* store and they will remain there until there are no references to that object remaining. Note
|
||||
* that this is not a Set and you can have multiple instances that are "equal" in this store.The
|
||||
* main purpose of this store is to be able to get all objects in the store that are still
|
||||
* referenced. This is useful when you need to visit all remaining items.
|
||||
* <p>
|
||||
* This class is thread safe.
|
||||
*
|
||||
* @param <T> The type of objects stored in this WeakStore
|
||||
*/
|
||||
|
@ -1,13 +1,21 @@
|
||||
[Defaults]
|
||||
|
||||
|
||||
# visual graph
|
||||
color.bg.visualgraph = color.bg
|
||||
color.bg.highlight.visualgraph = rgba(255,255,0,0.6) // somewhat transparent yellow
|
||||
color.bg.visualgraph.satellite = lightgray
|
||||
color.bg.highlight.visualgraph = rgba(255,255,0,155) // somewhat transparent yellow
|
||||
color.bg.visualgraph.message = rgb(138, 185, 241) // jordy blue
|
||||
|
||||
color.graph.display.vertex = green
|
||||
color.graph.display.edge = green
|
||||
color.graph.display.vertex.selected = blue
|
||||
color.graph.display.edge.selected = blue
|
||||
color.fg.visualgraph.message = color.palette.black
|
||||
|
||||
# graph display
|
||||
color.graphdisplay.vertex = green
|
||||
color.graphdisplay.edge = green
|
||||
color.graphdisplay.vertex.selected = blue
|
||||
color.graphdisplay.edge.selected = blue
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
color.bg.highlight.visualgraph = rgba(120,120,120,155) // light gray with dark bg = dark gray
|
||||
color.bg.visualgraph.message = rgb(65, 146, 242) // dark blue close to jordy blue
|
||||
color.fg.visualgraph.message = color.palette.lightgray
|
||||
|
@ -27,6 +27,10 @@ import com.google.common.base.Function;
|
||||
import docking.DockingUtils;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.help.HelpService;
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.PopupWindow;
|
||||
import docking.widgets.label.GIconLabel;
|
||||
@ -39,6 +43,7 @@ import edu.uci.ics.jung.visualization.decorators.PickableVertexPaintTransformer;
|
||||
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
|
||||
import edu.uci.ics.jung.visualization.picking.PickedState;
|
||||
import edu.uci.ics.jung.visualization.picking.ShapePickSupport;
|
||||
import edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer;
|
||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||
import edu.uci.ics.jung.visualization.util.Caching;
|
||||
import ghidra.graph.VisualGraph;
|
||||
@ -193,21 +198,6 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
|
||||
GraphViewer<V, E> viewer = new GraphViewer<>(layout, viewerSize);
|
||||
|
||||
Renderer<V, E> renderer = viewer.getRenderer();
|
||||
renderer.setVertexRenderer(new VisualVertexRenderer<>());
|
||||
|
||||
RenderContext<V, E> renderContext = viewer.getRenderContext();
|
||||
|
||||
Color normal = Color.GREEN.darker().darker();
|
||||
Color selected = Color.GREEN;
|
||||
renderContext.setEdgeDrawPaintTransformer(e -> e.isSelected() ? selected : normal);
|
||||
renderContext.setArrowDrawPaintTransformer(e -> e.isSelected() ? selected : normal);
|
||||
renderContext.setArrowFillPaintTransformer(e -> e.isSelected() ? selected : normal);
|
||||
|
||||
PickedState<V> pickedVertexState = viewer.getPickedVertexState();
|
||||
renderContext.setVertexFillPaintTransformer(
|
||||
new PickableVertexPaintTransformer<>(pickedVertexState, Color.WHITE, Color.YELLOW));
|
||||
|
||||
viewer.setGraphOptions(vgOptions);
|
||||
|
||||
return viewer;
|
||||
@ -258,10 +248,33 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
protected void decoratePrimaryViewer(GraphViewer<V, E> viewer, VisualGraphLayout<V, E> layout) {
|
||||
|
||||
Renderer<V, E> renderer = viewer.getRenderer();
|
||||
renderer.setEdgeRenderer(layout.getEdgeRenderer());
|
||||
BasicEdgeRenderer<V, E> edgeRenderer = layout.getEdgeRenderer();
|
||||
renderer.setEdgeRenderer(edgeRenderer);
|
||||
|
||||
RenderContext<V, E> renderContext = viewer.getRenderContext();
|
||||
|
||||
Color normal = Palette.GREEN;
|
||||
Color selected = Palette.LIME;
|
||||
if (edgeRenderer instanceof VisualEdgeRenderer) {
|
||||
VisualEdgeRenderer<V, E> visualRenderer =
|
||||
(VisualEdgeRenderer<V, E>) renderer.getEdgeRenderer();
|
||||
visualRenderer.setDrawColorTransformer(e -> normal);
|
||||
visualRenderer.setSelectedColorTransformer(e -> selected);
|
||||
}
|
||||
else {
|
||||
Function<? super E, Paint> edgeColorTransformer =
|
||||
e -> e.isSelected() ? selected : normal;
|
||||
renderContext.setEdgeDrawPaintTransformer(edgeColorTransformer);
|
||||
renderContext.setArrowDrawPaintTransformer(edgeColorTransformer);
|
||||
renderContext.setArrowFillPaintTransformer(edgeColorTransformer);
|
||||
}
|
||||
|
||||
VisualVertexRenderer<V, E> vertexRenderer = new VisualVertexRenderer<>();
|
||||
renderer.setVertexRenderer(vertexRenderer);
|
||||
PickedState<V> pickedVertexState = viewer.getPickedVertexState();
|
||||
vertexRenderer.setVertexFillPaintTransformer(
|
||||
new PickableVertexPaintTransformer<>(pickedVertexState, Palette.WHITE, Palette.YELLOW));
|
||||
|
||||
// this will paint thicker, but with the shape being used...which can look odd
|
||||
//renderContext.setEdgeFillPaintTransformer(null);
|
||||
PickedState<E> pickedEdgeState = viewer.getPickedEdgeState();
|
||||
@ -319,8 +332,14 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
|
||||
Renderer<V, E> renderer = viewer.getRenderer();
|
||||
renderer.setVertexRenderer(viewer.getPreferredVertexRenderer());
|
||||
renderer.setEdgeRenderer(new VisualGraphEdgeSatelliteRenderer<>(
|
||||
(VisualEdgeRenderer<V, E>) layout.getEdgeRenderer()));
|
||||
VisualGraphEdgeSatelliteRenderer<V, E> visualEdgeRenderer =
|
||||
new VisualGraphEdgeSatelliteRenderer<>(
|
||||
(VisualEdgeRenderer<V, E>) layout.getEdgeRenderer());
|
||||
renderer.setEdgeRenderer(visualEdgeRenderer);
|
||||
|
||||
Color normal = Palette.GREEN;
|
||||
Color selected = Palette.LIME;
|
||||
visualEdgeRenderer.setDrawColorTransformer(e -> e.isSelected() ? selected : normal);
|
||||
|
||||
Function<E, Shape> edgeTransformer = layout.getEdgeShapeTransformer();
|
||||
renderContext.setEdgeShapeTransformer(edgeTransformer);
|
||||
@ -374,7 +393,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
|
||||
mainPanel.add(layeredPane, BorderLayout.CENTER);
|
||||
|
||||
satellite.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
satellite.setBorder(BorderFactory.createLineBorder(Colors.Java.BORDER));
|
||||
|
||||
undockedSatellitePanel = new JPanel(new BorderLayout());
|
||||
undockedSatellitePanel.addComponentListener(new ComponentAdapter() {
|
||||
@ -966,7 +985,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
|
||||
private class MessagePaintable implements Paintable {
|
||||
|
||||
private final Color backgroundColor = new Color(134, 180, 238);
|
||||
private final Color backgroundColor = new GColor("color.bg.visualgraph.message");
|
||||
private String message = null;
|
||||
|
||||
@Override
|
||||
@ -1009,7 +1028,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
||||
g2.setPaint(bottomToTopGradiant);
|
||||
g2.fillRect(backgroundX, upperY, backgroundWidth, backgroundHeight);
|
||||
|
||||
g2.setPaint(Color.BLACK);
|
||||
g2.setPaint(Palette.BLACK);
|
||||
int textX =
|
||||
startX + (isGraphViewStale() ? staleGraphViewPanel.getBounds().width + 5 : 0);
|
||||
g2.drawString(message, textX, startY);
|
||||
|
@ -37,7 +37,7 @@ public class SatelliteGraphViewer<V extends VisualVertex, E extends VisualEdge<V
|
||||
|
||||
protected GraphViewer<V, E> graphViewer;
|
||||
private boolean docked;
|
||||
private VisualGraphOptions options;
|
||||
protected VisualGraphOptions options;
|
||||
|
||||
public SatelliteGraphViewer(GraphViewer<V, E> master, Dimension preferredSize) {
|
||||
super(master, preferredSize);
|
||||
|
@ -18,12 +18,15 @@ package ghidra.graph.viewer.edge;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import docking.theme.Gui;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.graph.Graph;
|
||||
import edu.uci.ics.jung.graph.util.Context;
|
||||
@ -75,6 +78,13 @@ import ghidra.graph.viewer.vertex.VisualGraphVertexShapeTransformer;
|
||||
* have to be changed, such as the {@link AbstractVisualGraphLayout}, which needs the centering
|
||||
* offsets to handle vertex clipping.
|
||||
*
|
||||
* <P>When painting edges this renderer will paint colors based on the following states: default,
|
||||
* hovered, focused and selected. A focused edge is one that is part of the path between focused
|
||||
* vertices, whereas a selected edge is one that has been selected by the user (see
|
||||
* {@link VisualEdge} for details). Each of these states may have a different color that can be
|
||||
* changed by calling the various setter methods on this renderer. When painting, these colors
|
||||
* are used along with various different strokes to paint in an overlay fashion.
|
||||
*
|
||||
* @param <V> the vertex type
|
||||
* @param <E> the edge type
|
||||
*/
|
||||
@ -88,8 +98,9 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
|
||||
private float dashingPatternOffset;
|
||||
|
||||
private Color defaultBaseColor = Color.BLACK;
|
||||
private Color defaultHighlightColor = Color.GRAY;
|
||||
private Function<E, Color> drawColorTransformer = e -> Palette.BLACK;
|
||||
private Function<E, Color> focusedColorTransformer = e -> Palette.GRAY;
|
||||
private Function<E, Color> selectedColorTransformer = e -> Palette.GRAY;
|
||||
|
||||
private VisualEdgeArrowRenderingSupport<V, E> arrowRenderingSupport =
|
||||
new VisualEdgeArrowRenderingSupport<>();
|
||||
@ -106,20 +117,58 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
this.dashingPatternOffset = dashingPatterOffset;
|
||||
}
|
||||
|
||||
public void setBaseColor(Color color) {
|
||||
this.defaultBaseColor = color;
|
||||
/**
|
||||
* Sets the color provider to use when drawing this edge.
|
||||
* @param transformer the color provider
|
||||
*/
|
||||
public void setDrawColorTransformer(Function<E, Color> transformer) {
|
||||
this.drawColorTransformer = Objects.requireNonNull(transformer);
|
||||
}
|
||||
|
||||
public Color getBaseColor(Graph<V, E> g, E e) {
|
||||
return defaultBaseColor;
|
||||
/**
|
||||
* Returns the current draw color.
|
||||
* @param g the graph
|
||||
* @param e the edge
|
||||
* @return the color
|
||||
*/
|
||||
public Color getDrawColor(Graph<V, E> g, E e) {
|
||||
return this.drawColorTransformer.apply(e);
|
||||
}
|
||||
|
||||
public void setHighlightColor(Color highlightColor) {
|
||||
this.defaultHighlightColor = highlightColor;
|
||||
/**
|
||||
* Sets the color provider to use when drawing this edge when the edge is focused.
|
||||
* @param transformer the color provider
|
||||
*/
|
||||
public void setFocusedColorTransformer(Function<E, Color> transformer) {
|
||||
this.focusedColorTransformer = Objects.requireNonNull(transformer);
|
||||
}
|
||||
|
||||
public Color getHighlightColor(Graph<V, E> g, E e) {
|
||||
return defaultHighlightColor;
|
||||
/**
|
||||
* Returns the current color to use when the edge is focused.
|
||||
* @param g the graph
|
||||
* @param e the edge
|
||||
* @return the color
|
||||
*/
|
||||
public Color getFocusedColor(Graph<V, E> g, E e) {
|
||||
return focusedColorTransformer.apply(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color provider to use when drawing this edge when the edge is selected.
|
||||
* @param transformer the color provider
|
||||
*/
|
||||
public void setSelectedColorTransformer(Function<E, Color> transformer) {
|
||||
this.selectedColorTransformer = Objects.requireNonNull(transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current color to use when the edge is selected.
|
||||
* @param g the graph
|
||||
* @param e the edge
|
||||
* @return the color
|
||||
*/
|
||||
public Color getSelectedColor(Graph<V, E> g, E e) {
|
||||
return selectedColorTransformer.apply(e);
|
||||
}
|
||||
|
||||
// template method
|
||||
@ -167,12 +216,13 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
boolean isSelected = isSelected(e);
|
||||
boolean isEmphasized = isEmphasiszed(e);
|
||||
|
||||
Color highlightColor = getHighlightColor(graph, e);
|
||||
Color baseColor = getBaseColor(graph, e);
|
||||
Color hoveredColor = highlightColor;
|
||||
Color focusedColor = baseColor;
|
||||
Color selectedColor = highlightColor.darker(); // note: we can do better for selected color
|
||||
Color selectedAccentColor = highlightColor;
|
||||
Color drawColor = getDrawColor(graph, e);
|
||||
Color focusedColor = getFocusedColor(graph, e);
|
||||
Color selectedColor = getSelectedColor(graph, e);
|
||||
Color selectedAccentColor = Gui.brighter(selectedColor);
|
||||
|
||||
// this can be changed if clients wish to set a separate color for the hovered state
|
||||
Color hoveredColor = selectedAccentColor;
|
||||
|
||||
float scale = Math.min(scalex, scaley);
|
||||
|
||||
@ -218,65 +268,13 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
BasicStroke selectedAccentStroke = getSelectedAccentStroke(e, scale);
|
||||
BasicStroke empahsisStroke = getEmphasisStroke(e, scale);
|
||||
|
||||
//
|
||||
// Fill
|
||||
//
|
||||
Paint fillPaint = rc.getEdgeFillPaintTransformer().apply(e);
|
||||
if (fillPaint != null) {
|
||||
// basic shape
|
||||
g.setPaint(fillPaint);
|
||||
g.fill(edgeShape);
|
||||
|
||||
// Currently, graphs with complicated edge shapes (those with articulations) do not
|
||||
// use a fill paint. If we execute this code with articulated edges, the display
|
||||
// looks unusual. So, for now, only 'fill' with these effects when the client has
|
||||
// explicitly used a fill paint transformer.
|
||||
if (isEmphasized) {
|
||||
Stroke saveStroke = g.getStroke();
|
||||
g.setPaint(fillPaint);
|
||||
g.setStroke(empahsisStroke);
|
||||
g.fill(edgeShape);
|
||||
g.setStroke(saveStroke);
|
||||
}
|
||||
|
||||
if (isInHoveredPath) {
|
||||
Stroke saveStroke = g.getStroke();
|
||||
g.setPaint(hoveredColor);
|
||||
g.setStroke(hoverStroke);
|
||||
g.fill(edgeShape);
|
||||
g.setStroke(saveStroke);
|
||||
}
|
||||
|
||||
if (isInFocusedPath) {
|
||||
Stroke saveStroke = g.getStroke();
|
||||
g.setPaint(focusedColor);
|
||||
g.setStroke(focusedStroke);
|
||||
g.fill(edgeShape);
|
||||
g.setStroke(saveStroke);
|
||||
}
|
||||
|
||||
if (isSelected) {
|
||||
Stroke saveStroke = g.getStroke();
|
||||
g.setPaint(selectedColor);
|
||||
g.setStroke(selectedStroke);
|
||||
g.fill(edgeShape);
|
||||
g.setStroke(saveStroke);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw
|
||||
//
|
||||
Paint drawPaint = rc.getEdgeDrawPaintTransformer().apply(e);
|
||||
if (drawPaint != null) {
|
||||
// basic shape
|
||||
g.setPaint(drawPaint);
|
||||
g.draw(edgeShape);
|
||||
}
|
||||
// basic shape
|
||||
g.setPaint(drawColor);
|
||||
g.draw(edgeShape);
|
||||
|
||||
if (isEmphasized) {
|
||||
Stroke saveStroke = g.getStroke();
|
||||
g.setPaint(drawPaint);
|
||||
g.setPaint(drawColor);
|
||||
g.setStroke(empahsisStroke);
|
||||
g.draw(edgeShape);
|
||||
g.setStroke(saveStroke);
|
||||
@ -313,7 +311,7 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
|
||||
// debug - draw a box around the edge
|
||||
//Rectangle shapeBounds = edgeShape.getBounds();
|
||||
//g.setPaint(Color.ORANGE);
|
||||
//g.setPaint(Palette.ORANGE);
|
||||
//g.draw(shapeBounds);
|
||||
|
||||
// can add this feature as needed to speed up painting
|
||||
@ -352,13 +350,13 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
return;
|
||||
}
|
||||
|
||||
Paint arrowFillPaint = rc.getArrowFillPaintTransformer().apply(e);
|
||||
Paint arrowDrawPaint = rc.getArrowDrawPaintTransformer().apply(e);
|
||||
Paint arrowDrawPaint = drawColor;
|
||||
Paint arrowFillPaint = arrowDrawPaint;
|
||||
Shape arrow = rc.getEdgeArrowTransformer().apply(context);
|
||||
arrow = scaleArrowForBetterVisibility(rc, arrow);
|
||||
arrow = at.createTransformedShape(arrow);
|
||||
|
||||
// basic shape
|
||||
// basic arrow shape
|
||||
g.setPaint(arrowFillPaint);
|
||||
g.fill(arrow);
|
||||
g.setPaint(arrowDrawPaint);
|
||||
@ -420,7 +418,7 @@ public abstract class VisualEdgeRenderer<V extends VisualVertex, E extends Visua
|
||||
* @param y2 the end vertex point y; layout space
|
||||
* @param isLoop true if the start == end, which is a self-loop
|
||||
* @param vertexShape the vertex shape (used in the case of a loop to draw a circle from the
|
||||
* shape to itself)
|
||||
* shape to itself)
|
||||
* @return the edge shape
|
||||
*/
|
||||
public abstract Shape getEdgeShape(RenderContext<V, E> rc, Graph<V, E> graph, E e, float x1,
|
||||
|
@ -27,6 +27,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.collections4.*;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.graph.Graph;
|
||||
import edu.uci.ics.jung.graph.util.Pair;
|
||||
@ -220,6 +222,7 @@ class ArticulatedEdgeRouter<V extends VisualVertex, E extends VisualEdge<V>>
|
||||
return createLineEdge(start, end, edge);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
E newEdge = (E) edge.cloneEdge(edge.getStart(), edge.getEnd());
|
||||
moveArticulationsAroundVertices(intersectingVertices, newEdge, goLeft);
|
||||
|
||||
@ -229,7 +232,6 @@ class ArticulatedEdgeRouter<V extends VisualVertex, E extends VisualEdge<V>>
|
||||
/**
|
||||
* Returns a mapping edges to vertices that touch them.
|
||||
*
|
||||
* @param viewer the viewer containing the graph
|
||||
* @param edgeCollection the edges to check for occlusion
|
||||
* @return a mapping of occluded edges (a subset of the provided edges) to those vertices that
|
||||
* occlude them.
|
||||
@ -319,35 +321,34 @@ class ArticulatedEdgeRouter<V extends VisualVertex, E extends VisualEdge<V>>
|
||||
|
||||
private Color getRoutingBoxColor(E edge) {
|
||||
if (isTrueEdge(edge)) {
|
||||
return Color.MAGENTA;
|
||||
return new GColor("color.palette.magenta");
|
||||
}
|
||||
return Color.ORANGE;
|
||||
return Palette.ORANGE;
|
||||
}
|
||||
|
||||
//
|
||||
// private Color getIntersectingBoxColor(E edge) {
|
||||
// if (isTrueEdge(edge)) {
|
||||
// return Color.RED;
|
||||
// return Palette.RED;
|
||||
// }
|
||||
// return Color.PINK;
|
||||
// return Palette.PINK;
|
||||
// }
|
||||
|
||||
private Color getPhantomEdgeColor(E edge, boolean isLeft) {
|
||||
if (isLeft) {
|
||||
if (isTrueEdge(edge)) {
|
||||
return new Color(0x999900);
|
||||
return new GColor("color.palette.darkkhaki");
|
||||
}
|
||||
|
||||
return new Color(0x009900);
|
||||
return Palette.GREEN;
|
||||
}
|
||||
if (isTrueEdge(edge)) {
|
||||
return new Color(0x3300CC);
|
||||
return new GColor("color.palette.darkblue");
|
||||
}
|
||||
return new Color(0x3399FF);
|
||||
return new GColor("color.palette.dodgerblue");
|
||||
}
|
||||
|
||||
private boolean isTrueEdge(E edge) {
|
||||
return true;
|
||||
// return edge.getFlowType().isJump(); // a jump is a 'true' edge
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.algorithms.layout.GraphElementAccessor;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.visualization.Layer;
|
||||
@ -94,7 +95,7 @@ public class JungPickingGraphMousePlugin<V, E> extends AbstractGraphMousePlugin
|
||||
/**
|
||||
* color for the picking rectangle
|
||||
*/
|
||||
protected Color lensColor = Color.cyan;
|
||||
protected Color lensColor = Palette.CYAN;
|
||||
|
||||
/**
|
||||
* create an instance with default settings
|
||||
|
@ -22,6 +22,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.util.Objects;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.visualization.*;
|
||||
import edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin;
|
||||
import edu.uci.ics.jung.visualization.transform.MutableTransformer;
|
||||
@ -92,6 +93,7 @@ public class VisualGraphMouseTrackingGraphMousePlugin<V extends VisualVertex,
|
||||
}
|
||||
|
||||
int offset = 20;
|
||||
offset = 0; // not sure why this was using an offset?
|
||||
Point downOver = new Point(down.x + offset, down.y + offset);
|
||||
Point pOver = new Point(p.x + offset, p.y + offset);
|
||||
Point gpOver = GraphViewerUtils.translatePointFromViewSpaceToGraphSpace(pOver, viewer);
|
||||
@ -115,7 +117,7 @@ public class VisualGraphMouseTrackingGraphMousePlugin<V extends VisualVertex,
|
||||
|
||||
// we get a lot of these events, so don't record them all
|
||||
if (++mouseMovedCount % 5 == 0) {
|
||||
addPointMousePaintable(e, new Color(0, 255, 0, 127)); // greenish
|
||||
addPointMousePaintable(e, Palette.GREEN.withAlpha(127));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +130,7 @@ public class VisualGraphMouseTrackingGraphMousePlugin<V extends VisualVertex,
|
||||
return;
|
||||
}
|
||||
|
||||
addPointMousePaintable(e, Color.ORANGE);
|
||||
addPointMousePaintable(e, Palette.ORANGE.withAlpha(127));
|
||||
}
|
||||
|
||||
private void addPointMousePaintable(MouseEvent e, Color color) {
|
||||
|
@ -76,6 +76,7 @@ public interface VisualGraphLayout<V extends VisualVertex,
|
||||
*
|
||||
* @param graph the graph that contains the vertices to layout
|
||||
* @param monitor the task monitor used to report progress or to cancel
|
||||
* @return the layout locations
|
||||
*/
|
||||
public LayoutPositions<V, E> calculateLocations(VisualGraph<V, E> graph, TaskMonitor monitor);
|
||||
|
||||
|
@ -19,11 +19,11 @@ import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.visualization.VisualizationServer;
|
||||
import edu.uci.ics.jung.visualization.VisualizationServer.Paintable;
|
||||
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator;
|
||||
import ghidra.util.Swing;
|
||||
|
||||
public class DebugShape<V, E> implements Paintable {
|
||||
|
||||
@ -75,7 +75,7 @@ public class DebugShape<V, E> implements Paintable {
|
||||
|
||||
g.draw(shape);
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.setColor(Palette.BLACK);
|
||||
FontMetrics fontMetrics = g.getFontMetrics();
|
||||
Rectangle2D stringBounds = fontMetrics.getStringBounds(text, g);
|
||||
Point location = shape.getBounds().getLocation();
|
||||
@ -88,12 +88,7 @@ public class DebugShape<V, E> implements Paintable {
|
||||
private boolean shapeIsOutdated() {
|
||||
if (drawingIterationID != drawingIterationCounter.get()) {
|
||||
// we are no longer drawing this shape
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
viewer.removePostRenderPaintable(DebugShape.this);
|
||||
}
|
||||
});
|
||||
Swing.runLater(() -> viewer.removePostRenderPaintable(DebugShape.this));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -19,12 +19,14 @@ import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
|
||||
/**
|
||||
* A debugging shape painter that allows the user to see where a mouse clicked happened.
|
||||
*/
|
||||
public class MouseClickedPaintableShape extends PaintableShape {
|
||||
|
||||
private static final Color DEFAULT_COLOR = new Color(255, 200, 0, 127); // orangish
|
||||
private static final Color DEFAULT_COLOR = Palette.ORANGE.withAlpha(127);
|
||||
|
||||
public MouseClickedPaintableShape(Point p, double tx, double ty) {
|
||||
this(p, tx, ty, DEFAULT_COLOR);
|
||||
|
@ -20,6 +20,11 @@ import java.awt.geom.GeneralPath;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
|
||||
/**
|
||||
* Paints a line showing the start and end points of a drag operation.
|
||||
*/
|
||||
public class MouseDraggedLinePaintableShape extends PaintableShape {
|
||||
|
||||
private List<Point> points = new ArrayList<>();
|
||||
@ -27,7 +32,7 @@ public class MouseDraggedLinePaintableShape extends PaintableShape {
|
||||
|
||||
public MouseDraggedLinePaintableShape(Point start, Point end, double tx, double ty) {
|
||||
super(tx, ty);
|
||||
this.color = new Color(0, 200, 0, 137);
|
||||
this.color = Palette.GREEN.withAlpha(127);
|
||||
this.stroke = new BasicStroke(20);
|
||||
|
||||
points.add(start);
|
||||
@ -89,7 +94,7 @@ public class MouseDraggedLinePaintableShape extends PaintableShape {
|
||||
g.draw(shape);
|
||||
// g.fill(shape);
|
||||
|
||||
// g.setColor(new Color(20, 200, 20, 147));
|
||||
// g.setColor(Palette.GREEN.withAlpha(127););
|
||||
// controls.forEach(c -> {
|
||||
//
|
||||
// int x = c.x;
|
||||
@ -101,7 +106,7 @@ public class MouseDraggedLinePaintableShape extends PaintableShape {
|
||||
// g.fill(r);
|
||||
// });
|
||||
//
|
||||
// g.setColor(Color.pink);
|
||||
// g.setColor(Palette.PINK);
|
||||
// points.forEach(p -> {
|
||||
// int x = p.x;
|
||||
// int y = p.y;
|
||||
|
@ -18,16 +18,21 @@ package ghidra.graph.viewer.renderer;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import docking.theme.GColor;
|
||||
|
||||
/**
|
||||
* Paints a rectangle showing the start and end points of a drag.
|
||||
*/
|
||||
public class MouseDraggedPaintableShape extends PaintableShape {
|
||||
|
||||
private static final Color START_COLOR = new Color(200, 0, 80, 25);
|
||||
private static final Color END_COLOR = new Color(200, 0, 80, 200);
|
||||
private static final GColor BASE_COLOR = new GColor("color.palette.crimson");
|
||||
private static final Color START_COLOR = BASE_COLOR.withAlpha(25);
|
||||
private static final Color END_COLOR = BASE_COLOR.withAlpha(200);
|
||||
|
||||
private Paint paint;
|
||||
|
||||
public MouseDraggedPaintableShape(Point start, Point end, double tx, double ty) {
|
||||
super(tx, ty);
|
||||
this.color = new Color(200, 0, 80, 147);
|
||||
this.stroke = new BasicStroke(15);
|
||||
|
||||
int x1 = start.x;
|
||||
|
@ -18,13 +18,15 @@ package ghidra.graph.viewer.renderer;
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
|
||||
/**
|
||||
* A base class for shapes that can be painted on the graph. See {@link MouseDebugPaintable}.
|
||||
*/
|
||||
public class PaintableShape {
|
||||
|
||||
protected Shape shape;
|
||||
protected Color color = new Color(255, 200, 0, 127); // orange with alpha;
|
||||
protected Color color = Palette.ORANGE.withAlpha(127);
|
||||
protected Stroke stroke;
|
||||
|
||||
protected double tx;
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -21,6 +21,7 @@ import java.util.*;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.visualization.*;
|
||||
import edu.uci.ics.jung.visualization.layout.ObservableCachingLayout;
|
||||
@ -143,8 +144,8 @@ public class VisualGraphRenderer<V extends VisualVertex, E extends VisualEdge<V>
|
||||
|
||||
GraphicsDecorator g = renderContext.getGraphicsContext();
|
||||
Color originalColor = g.getColor();
|
||||
Color gridColor = Color.ORANGE;
|
||||
Color textColor = Color.BLACK;
|
||||
Color gridColor = Palette.ORANGE;
|
||||
Color textColor = Palette.BLACK;
|
||||
|
||||
boolean isCondensed = locationMap.isCondensed();
|
||||
Row<?> lastRow = locationMap.lastRow();
|
||||
|
@ -17,6 +17,10 @@ package ghidra.graph.viewer.renderer;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.visualization.RenderContext;
|
||||
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator;
|
||||
@ -27,10 +31,14 @@ import ghidra.graph.viewer.vertex.AbstractVisualVertexRenderer;
|
||||
/**
|
||||
* A renderer for vertices for the satellite view. This is really just a basic renderer
|
||||
* that adds emphasis capability, as seen in the primary function graph renderer.
|
||||
* @param <V> the vertex type
|
||||
* @param <E> the edge type
|
||||
*/
|
||||
public class VisualVertexSatelliteRenderer<V extends VisualVertex, E extends VisualEdge<V>>
|
||||
extends AbstractVisualVertexRenderer<V, E> {
|
||||
|
||||
private Color highlightColor = new GColor("color.bg.highlight.visualgraph");
|
||||
|
||||
/**
|
||||
* Overridden to handle painting emphasis.
|
||||
*/
|
||||
@ -63,6 +71,27 @@ public class VisualVertexSatelliteRenderer<V extends VisualVertex, E extends Vis
|
||||
super.paintIconForVertex(rc, v, layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintShapeForVertex(RenderContext<V, E> rc, V v, Shape shape) {
|
||||
GraphicsDecorator g = rc.getGraphicsContext();
|
||||
Paint oldPaint = g.getPaint();
|
||||
|
||||
Function<? super V, Paint> fillXform = getVertexFillPaintTransformer();
|
||||
if (fillXform == null) {
|
||||
fillXform = rc.getVertexFillPaintTransformer();
|
||||
}
|
||||
|
||||
Paint fillPaint = fillXform.apply(v);
|
||||
if (fillPaint == null) {
|
||||
super.paintShapeForVertex(rc, v, shape);
|
||||
return;
|
||||
}
|
||||
|
||||
g.setPaint(fillPaint);
|
||||
g.fill(shape);
|
||||
g.setPaint(oldPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Shape prepareFinalVertexShape(RenderContext<V, E> rc, V v, Layout<V, E> layout,
|
||||
int[] coords) {
|
||||
@ -83,10 +112,7 @@ public class VisualVertexSatelliteRenderer<V extends VisualVertex, E extends Vis
|
||||
}
|
||||
|
||||
Paint oldPaint = g.getPaint();
|
||||
|
||||
int halfishTransparency = 150;
|
||||
Color yellowWithTransparency = new Color(255, 255, 0, halfishTransparency);
|
||||
g.setPaint(yellowWithTransparency);
|
||||
g.setPaint(highlightColor);
|
||||
|
||||
// int offset = (int) adjustValueForCurrentScale(rc, 10D, .25);
|
||||
int offset = 10;
|
||||
@ -98,7 +124,7 @@ public class VisualVertexSatelliteRenderer<V extends VisualVertex, E extends Vis
|
||||
bounds.height + (offset * 2));
|
||||
|
||||
if (isGraphScaledEnoughToBeDifficultToSee(rc)) {
|
||||
g.setColor(Color.BLACK);
|
||||
g.setColor(Colors.Java.BORDER);
|
||||
g.drawOval(bounds.x - offset, bounds.y - offset, bounds.width + (offset * 2),
|
||||
bounds.height + (offset * 2));
|
||||
g.drawOval(bounds.x - offset - 1, bounds.y - offset - 1,
|
||||
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.graph.Graph;
|
||||
import edu.uci.ics.jung.visualization.*;
|
||||
@ -39,8 +40,6 @@ public class CachingSatelliteGraphViewer<V extends VisualVertex, E extends Visua
|
||||
private BufferedImage bufferedBackgroundImage = null;
|
||||
private BufferedImage bufferedOverlayImage = null;
|
||||
|
||||
private Color backgroundColor;
|
||||
|
||||
private VisualVertexSatelliteRenderer<V, E> highlightRenderer =
|
||||
new VisualVertexSatelliteRenderer<>();
|
||||
|
||||
@ -56,10 +55,6 @@ public class CachingSatelliteGraphViewer<V extends VisualVertex, E extends Visua
|
||||
|
||||
preRenderers.clear(); // remove default lens painter
|
||||
|
||||
// same behavior as default ViewLens
|
||||
backgroundColor = masterViewer.getBackground().darker();
|
||||
setBackground(backgroundColor);
|
||||
|
||||
Layout<V, E> layout = masterViewer.getGraphLayout();
|
||||
if (layout instanceof ObservableCachingLayout<?, ?>) {
|
||||
ObservableCachingLayout<?, ?> cachingLayout = (ObservableCachingLayout<?, ?>) layout;
|
||||
@ -76,7 +71,7 @@ public class CachingSatelliteGraphViewer<V extends VisualVertex, E extends Visua
|
||||
|
||||
@Override
|
||||
public Renderer.Vertex<V, E> getPreferredVertexRenderer() {
|
||||
return new VisualVertexSatelliteRenderer<V, E>() {
|
||||
return new VisualVertexSatelliteRenderer<>() {
|
||||
@Override
|
||||
protected void paintHighlight(RenderContext<V, E> rc, V vertex, GraphicsDecorator g,
|
||||
Rectangle bounds) {
|
||||
@ -100,16 +95,16 @@ public class CachingSatelliteGraphViewer<V extends VisualVertex, E extends Visua
|
||||
bufferedBackgroundImage =
|
||||
new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = (Graphics2D) bufferedBackgroundImage.getGraphics();
|
||||
setBackground(backgroundColor);
|
||||
setBackground(options.getGraphBackgroundColor());
|
||||
renderGraph(graphics);
|
||||
graphics.dispose();
|
||||
|
||||
bufferedOverlayImage =
|
||||
new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
graphics = (Graphics2D) bufferedOverlayImage.getGraphics();
|
||||
setBackground(Color.WHITE);
|
||||
setBackground(Palette.WHITE);
|
||||
renderGraph(graphics);
|
||||
setBackground(backgroundColor);
|
||||
setBackground(options.getGraphBackgroundColor());
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import java.awt.geom.Point2D;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.visualization.*;
|
||||
import edu.uci.ics.jung.visualization.renderers.BasicVertexRenderer;
|
||||
@ -44,9 +45,28 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
|
||||
|
||||
private static final Color HIGHLIGHT_COLOR = new GColor("color.bg.highlight.visualgraph");
|
||||
|
||||
private Function<? super V, Paint> vertexFillPaintTransformer;
|
||||
|
||||
/**
|
||||
* Sets the optional transformer used to convert a vertex into a color
|
||||
* @param transformer the transformer
|
||||
*/
|
||||
public void setVertexFillPaintTransformer(Function<? super V, Paint> transformer) {
|
||||
this.vertexFillPaintTransformer = transformer;
|
||||
}
|
||||
|
||||
public Function<? super V, Paint> getVertexFillPaintTransformer() {
|
||||
return vertexFillPaintTransformer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the given {@link GraphicsDecorator} that may have scaling tweaked to
|
||||
* handle {@link VisualVertex#getEmphasis()} emphasized vertices.
|
||||
* @param g the graphics
|
||||
* @param vertex the vertex
|
||||
* @param rc the render context
|
||||
* @param layout the graph layout
|
||||
* @return the new graphics
|
||||
*/
|
||||
protected GraphicsDecorator getEmphasisGraphics(GraphicsDecorator g, V vertex,
|
||||
RenderContext<V, E> rc, Layout<V, E> layout) {
|
||||
@ -111,10 +131,10 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
|
||||
bounds.height + (offset * 2));
|
||||
|
||||
// DEBUG
|
||||
// g.setPaint(Color.BLUE);
|
||||
// g.setPaint(Palette.BLUE);
|
||||
// g.drawRect(bounds.x - offset, bounds.y - offset, bounds.width + (offset * 2),
|
||||
// bounds.height + (offset * 2));
|
||||
// g.setPaint(Color.BLACK);
|
||||
// g.setPaint(Palette.BLACK);
|
||||
// g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
|
||||
g.setPaint(oldPaint);
|
||||
@ -126,14 +146,14 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.GRAY);
|
||||
g.setColor(Palette.GRAY);
|
||||
int grayOffset = 15;
|
||||
int blackOffset = 5;
|
||||
|
||||
AffineTransform xform = AffineTransform.getTranslateInstance(grayOffset, grayOffset);
|
||||
Shape xShape = xform.createTransformedShape(shape);
|
||||
g.fill(xShape);
|
||||
g.setColor(Color.BLACK);
|
||||
g.setColor(Palette.BLACK);
|
||||
AffineTransform xform2 = AffineTransform.getTranslateInstance(blackOffset, blackOffset);
|
||||
Shape xShape2 = xform2.createTransformedShape(shape);
|
||||
g.fill(xShape2);
|
||||
@ -143,6 +163,7 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
|
||||
* Returns true if the view is zoomed far enough out that the user cannot interact with
|
||||
* its internal UI widgets
|
||||
*
|
||||
* @param rc the render context
|
||||
* @return true if the vertex is scaled past the interaction threshold
|
||||
*/
|
||||
protected boolean isScaledPastVertexInteractionThreshold(RenderContext<V, E> rc) {
|
||||
|
@ -23,6 +23,8 @@ import java.beans.PropertyChangeListener;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.GenericHeader;
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.graph.viewer.VisualVertex;
|
||||
import ghidra.util.MathUtilities;
|
||||
|
||||
@ -54,8 +56,8 @@ public class DockingVisualVertex extends AbstractVisualVertex {
|
||||
};
|
||||
textArea.setText(name);
|
||||
textArea.setPreferredSize(new Dimension(200, 50));
|
||||
textArea.setBackground(Color.YELLOW.darker());
|
||||
textArea.setCaretColor(Color.PINK);
|
||||
textArea.setBackground(new GColor("color.palette.darkkhaki"));
|
||||
textArea.setCaretColor(Palette.PINK);
|
||||
textArea.setBorder(BorderFactory.createRaisedBevelBorder());
|
||||
textArea.setLineWrap(true);
|
||||
|
||||
|
@ -21,6 +21,7 @@ import java.awt.*;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors;
|
||||
import edu.uci.ics.jung.algorithms.layout.Layout;
|
||||
import edu.uci.ics.jung.graph.Graph;
|
||||
import edu.uci.ics.jung.graph.util.Context;
|
||||
@ -108,10 +109,10 @@ public class VisualVertexRenderer<V extends VisualVertex, E extends VisualEdge<V
|
||||
|
||||
// DEBUG
|
||||
// Paint oldPaint = g.getPaint();
|
||||
// g.setPaint(Color.RED);
|
||||
// g.setPaint(Palette.RED);
|
||||
// g.draw(compactShape);
|
||||
//
|
||||
// g.setPaint(Color.CYAN);
|
||||
// g.setPaint(Palette.CYAN);
|
||||
// g.draw(fullShape);
|
||||
// g.setPaint(oldPaint);
|
||||
}
|
||||
@ -136,7 +137,12 @@ public class VisualVertexRenderer<V extends VisualVertex, E extends VisualEdge<V
|
||||
|
||||
protected void paintScaledVertex(RenderContext<V, E> rc, V vertex, GraphicsDecorator g,
|
||||
Shape shape) {
|
||||
Function<? super V, Paint> fillXform = rc.getVertexFillPaintTransformer();
|
||||
|
||||
Function<? super V, Paint> fillXform = getVertexFillPaintTransformer();
|
||||
if (fillXform == null) {
|
||||
fillXform = rc.getVertexFillPaintTransformer();
|
||||
}
|
||||
|
||||
Paint fillPaint = fillXform.apply(vertex);
|
||||
if (fillPaint == null) {
|
||||
return;
|
||||
@ -147,9 +153,10 @@ public class VisualVertexRenderer<V extends VisualVertex, E extends VisualEdge<V
|
||||
g.fill(shape);
|
||||
|
||||
// an outline
|
||||
g.setColor(Color.BLACK);
|
||||
g.setColor(Colors.Java.BORDER);
|
||||
g.draw(shape);
|
||||
|
||||
g.setPaint(oldPaint);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ import ghidra.util.bean.opteditor.OptionsVetoException;
|
||||
*/
|
||||
public class GraphDisplayOptions implements OptionsChangeListener {
|
||||
|
||||
private static final String COLOR_ID = "graph.display.color";
|
||||
|
||||
public static final GraphDisplayOptions DEFAULT = new GraphDisplayOptions(new EmptyGraphType());
|
||||
|
||||
private static final String FONT = "Font";
|
||||
@ -66,10 +64,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
||||
private Map<String, Integer> edgePriorityMap = new HashMap<>();
|
||||
private List<ChangeListener> changeListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private Color vertexSelectionColor = new GColor("color.graph.display.vertex.selected");
|
||||
private Color edgeSelectionColor = new GColor("color.graph.display.edge.selected");
|
||||
private Color defaultVertexColor = new GColor("color.graph.display.vertex");
|
||||
private Color defaultEdgeColor = new GColor("color.graph.display.edge");
|
||||
private Color vertexSelectionColor = new GColor("color.graphdisplay.vertex.selected");
|
||||
private Color edgeSelectionColor = new GColor("color.graphdisplay.edge.selected");
|
||||
private Color defaultVertexColor = new GColor("color.graphdisplay.vertex");
|
||||
private Color defaultEdgeColor = new GColor("color.graphdisplay.edge");
|
||||
private String favoredEdgeType;
|
||||
|
||||
private VertexShape defaultVertexShape = VertexShape.RECTANGLE;
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package ghidra.graph.support;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import ghidra.graph.graphs.TestEdge;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.graph.graphs.AbstractTestVertex;
|
||||
import ghidra.graph.graphs.TestEdge;
|
||||
import ghidra.graph.viewer.GraphViewer;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public class TestGraphViewer extends GraphViewer<AbstractTestVertex, TestEdge> {
|
||||
|
||||
public TestGraphViewer(TestGraphLayout layout, Dimension size) {
|
||||
super(layout, size);
|
||||
setBackground(Color.WHITE);
|
||||
setBackground(Palette.WHITE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package ghidra.graph.support;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
@ -26,6 +25,7 @@ import javax.swing.JComponent;
|
||||
import org.apache.commons.collections4.Factory;
|
||||
import org.apache.commons.collections4.map.LazyMap;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.widgets.label.GDHtmlLabel;
|
||||
import ghidra.graph.graphs.AbstractTestVertex;
|
||||
import ghidra.graph.graphs.TestEdge;
|
||||
@ -110,7 +110,7 @@ public class TestVertexTooltipProvider
|
||||
SpyTooltipLabel(String text) {
|
||||
setText(text);
|
||||
setOpaque(true);
|
||||
setBackground(Color.ORANGE.darker());
|
||||
setBackground(new GColor("color.palette.olive"));
|
||||
setPreferredSize(new Dimension(200, 100));
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ import java.beans.PropertyChangeListener;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.GenericHeader;
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.graph.graphs.AbstractTestVertex;
|
||||
|
||||
/**
|
||||
@ -39,8 +41,8 @@ public class TextAreaTestVertex extends AbstractTestVertex {
|
||||
|
||||
textArea.setText(name);
|
||||
textArea.setPreferredSize(new Dimension(200, 50));
|
||||
textArea.setBackground(Color.YELLOW.darker());
|
||||
textArea.setCaretColor(Color.PINK);
|
||||
textArea.setBackground(new GColor("color.palette.darkkhaki"));
|
||||
textArea.setCaretColor(Palette.PINK);
|
||||
textArea.setBorder(BorderFactory.createRaisedBevelBorder());
|
||||
textArea.setLineWrap(true);
|
||||
|
||||
|
@ -22,6 +22,8 @@ import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.theme.GColor;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.graph.algo.GraphAlgorithmStatusListener.STATUS;
|
||||
import ghidra.graph.graphs.AbstractTestVertex;
|
||||
import ghidra.graph.viewer.vertex.VertexShapeProvider;
|
||||
@ -87,10 +89,11 @@ public class AlgorithmTestSteppingVertex<V> extends AbstractTestVertex
|
||||
private void buildShapes() {
|
||||
|
||||
defaultShape = buildCircleShape(Color.LIGHT_GRAY, "default");
|
||||
defaultWithPathShape = buildCircleShape(new Color(192, 216, 65), "default; was in path");
|
||||
scheduledShape = buildCircleShape(new Color(255, 248, 169), "scheduled");
|
||||
exploringShape = buildCircleShape(new Color(0, 147, 0), "exploring");
|
||||
blockedShape = buildCircleShape(new Color(249, 190, 190), "blocked");
|
||||
defaultWithPathShape =
|
||||
buildCircleShape(new GColor("color.palette.yellowgreen"), "default; was in path");
|
||||
scheduledShape = buildCircleShape(new GColor("color.palette.khaki"), "scheduled");
|
||||
exploringShape = buildCircleShape(Palette.GREEN, "exploring");
|
||||
blockedShape = buildCircleShape(Palette.PINK, "blocked");
|
||||
|
||||
currentShape = defaultShape;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import javax.swing.*;
|
||||
import org.apache.commons.collections4.BidiMap;
|
||||
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
|
||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||
import generic.util.image.ImageUtils;
|
||||
@ -86,7 +87,7 @@ public class TestGraphAlgorithmSteppingViewerPanel<V, E extends GEdge<V>> extend
|
||||
|
||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setColor(Color.WHITE);
|
||||
g.setColor(Palette.WHITE);
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
try {
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package ghidra.graph.graphs;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import docking.widgets.label.GDLabel;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ public class LabelTestVertex extends AbstractTestVertex {
|
||||
super(name);
|
||||
label.setText(name);
|
||||
label.setPreferredSize(new Dimension(50, 50));
|
||||
label.setBackground(Color.YELLOW.darker());
|
||||
label.setBackground(Palette.GOLD);
|
||||
label.setOpaque(true);
|
||||
label.setBorder(BorderFactory.createRaisedBevelBorder());
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
@ -17,7 +17,6 @@ package ghidra.service.graph;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -25,6 +24,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import docking.FakeDockingTool;
|
||||
import docking.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.util.HelpLocation;
|
||||
@ -51,14 +51,14 @@ public class GraphDisplayOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testSetAndGetDefaultVertexColor() {
|
||||
options.setDefaultVertexColor(Color.MAGENTA);
|
||||
assertEquals(Color.MAGENTA, options.getDefaultVertexColor());
|
||||
options.setDefaultVertexColor(Palette.RED);
|
||||
assertEquals(Palette.RED, options.getDefaultVertexColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetDefaultEdgeColor() {
|
||||
options.setDefaultEdgeColor(Color.MAGENTA);
|
||||
assertEquals(Color.MAGENTA, options.getDefaultEdgeColor());
|
||||
options.setDefaultEdgeColor(Palette.RED);
|
||||
assertEquals(Palette.RED, options.getDefaultEdgeColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -131,62 +131,62 @@ public class GraphDisplayOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testGetVertexColor() {
|
||||
options.setVertexColor("V1", Color.RED);
|
||||
options.setVertexColor("V2", Color.GREEN);
|
||||
options.setVertexColor("V1", Palette.RED);
|
||||
options.setVertexColor("V2", Palette.GREEN);
|
||||
AttributedVertex vertex = new AttributedVertex("Foo");
|
||||
|
||||
assertEquals(options.getDefaultVertexColor(), options.getVertexColor(vertex));
|
||||
|
||||
vertex.setVertexType("V1");
|
||||
assertEquals(Color.RED, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.RED, options.getVertexColor(vertex));
|
||||
|
||||
vertex.setVertexType("V2");
|
||||
assertEquals(Color.GREEN, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.GREEN, options.getVertexColor(vertex));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVertexColorWithOverride() {
|
||||
options.setVertexColor("V1", Color.RED);
|
||||
options.setVertexColor("V2", Color.GREEN);
|
||||
options.setVertexColor("V1", Palette.RED);
|
||||
options.setVertexColor("V2", Palette.GREEN);
|
||||
options.setVertexColorOverrideAttributeKey("Color");
|
||||
AttributedVertex vertex = new AttributedVertex("Foo");
|
||||
|
||||
vertex.setVertexType("V1");
|
||||
assertEquals(Color.RED, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.RED, options.getVertexColor(vertex));
|
||||
|
||||
vertex.setAttribute("Color", WebColors.toString(Color.BLUE));
|
||||
vertex.setAttribute("Color", WebColors.toString(Palette.BLUE));
|
||||
|
||||
assertEquals(Color.BLUE, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.BLUE, options.getVertexColor(vertex));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEdgeColor() {
|
||||
options.setEdgeColor("E1", Color.RED);
|
||||
options.setEdgeColor("E2", Color.GREEN);
|
||||
options.setEdgeColor("E1", Palette.RED);
|
||||
options.setEdgeColor("E2", Palette.GREEN);
|
||||
AttributedEdge edge = new AttributedEdge("1");
|
||||
assertEquals(options.getDefaultEdgeColor(), options.getEdgeColor(edge));
|
||||
|
||||
edge.setEdgeType("E1");
|
||||
assertEquals(Color.RED, options.getEdgeColor(edge));
|
||||
assertEquals(Palette.RED, options.getEdgeColor(edge));
|
||||
|
||||
edge.setEdgeType("E2");
|
||||
assertEquals(Color.GREEN, options.getEdgeColor(edge));
|
||||
assertEquals(Palette.GREEN, options.getEdgeColor(edge));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEdgeColorWithOverride() {
|
||||
options.setEdgeColor("E1", Color.RED);
|
||||
options.setEdgeColor("E2", Color.GREEN);
|
||||
options.setEdgeColor("E1", Palette.RED);
|
||||
options.setEdgeColor("E2", Palette.GREEN);
|
||||
options.setEdgeColorOverrideAttributeKey("Color");
|
||||
AttributedEdge edge = new AttributedEdge("1");
|
||||
assertEquals(options.getDefaultEdgeColor(), options.getEdgeColor(edge));
|
||||
|
||||
edge.setEdgeType("E1");
|
||||
assertEquals(Color.RED, options.getEdgeColor(edge));
|
||||
assertEquals(Palette.RED, options.getEdgeColor(edge));
|
||||
|
||||
edge.setAttribute("Color", WebColors.toString(Color.BLUE));
|
||||
edge.setAttribute("Color", WebColors.toString(Palette.BLUE));
|
||||
|
||||
assertEquals(Color.BLUE, options.getEdgeColor(edge));
|
||||
assertEquals(Palette.BLUE, options.getEdgeColor(edge));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -206,8 +206,8 @@ public class GraphDisplayOptionsTest {
|
||||
@Test
|
||||
public void testGetVertexColorForType() {
|
||||
assertEquals(options.getDefaultVertexColor(), options.getVertexColor("V1"));
|
||||
options.setVertexColor("V1", Color.RED);
|
||||
assertEquals(Color.RED, options.getVertexColor("V1"));
|
||||
options.setVertexColor("V1", Palette.RED);
|
||||
assertEquals(Palette.RED, options.getVertexColor("V1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -220,8 +220,8 @@ public class GraphDisplayOptionsTest {
|
||||
@Test
|
||||
public void testGetEdgeColorForType() {
|
||||
assertEquals(options.getDefaultEdgeColor(), options.getEdgeColor("V1"));
|
||||
options.setEdgeColor("E1", Color.RED);
|
||||
assertEquals(Color.RED, options.getEdgeColor("E1"));
|
||||
options.setEdgeColor("E1", Palette.RED);
|
||||
assertEquals(Palette.RED, options.getEdgeColor("E1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -237,7 +237,7 @@ public class GraphDisplayOptionsTest {
|
||||
List<String> leafOptionNames = vertexColorOptions.getLeafOptionNames();
|
||||
assertEquals(Arrays.asList("V1", "V2", "V3"), leafOptionNames);
|
||||
assertEquals(options.getDefaultVertexColor(),
|
||||
vertexColorOptions.getColor("V1", Color.WHITE));
|
||||
vertexColorOptions.getColor("V1", Palette.WHITE));
|
||||
|
||||
Options vertexShapeOptions = graphDisplayOptions.getOptions("Vertex Shapes");
|
||||
leafOptionNames = vertexShapeOptions.getLeafOptionNames();
|
||||
@ -249,7 +249,7 @@ public class GraphDisplayOptionsTest {
|
||||
leafOptionNames = edgeColorOptions.getLeafOptionNames();
|
||||
assertEquals(Arrays.asList("E1", "E2", "E3"), leafOptionNames);
|
||||
assertEquals(options.getDefaultEdgeColor(),
|
||||
edgeColorOptions.getColor("E1", Color.WHITE));
|
||||
edgeColorOptions.getColor("E1", Palette.WHITE));
|
||||
|
||||
Options miscellaneousOptions = graphDisplayOptions.getOptions("Miscellaneous");
|
||||
leafOptionNames = miscellaneousOptions.getLeafOptionNames();
|
||||
@ -269,13 +269,13 @@ public class GraphDisplayOptionsTest {
|
||||
|
||||
AttributedVertex vertex = new AttributedVertex("Foo");
|
||||
vertex.setVertexType("V1");
|
||||
assertEquals(Color.BLUE, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.BLUE, options.getVertexColor(vertex));
|
||||
|
||||
Options graphDisplayOptions = toolOptions.getOptions(options.getRootOptionsName());
|
||||
Options vertexColorOptions = graphDisplayOptions.getOptions("Vertex Colors");
|
||||
vertexColorOptions.setColor("V1", Color.CYAN);
|
||||
vertexColorOptions.setColor("V1", Palette.CYAN);
|
||||
|
||||
assertEquals(Color.CYAN, options.getVertexColor(vertex));
|
||||
assertEquals(Palette.CYAN, options.getVertexColor(vertex));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user