use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CGraphSynchonizerTest method test1Simple.
// TODO this test is very artificial as it does not test a real work flow.
@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final ZyGraph graph = ZyGraphFactory.generateTestGraph();
final CSpecialInstructionsModel model = new CSpecialInstructionsModel();
final List<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>();
final ITypeDescription callsDescription = model.getDescriptions().get(0);
callsDescription.setEnabled(true);
final CSpecialInstruction instruction = new CSpecialInstruction(callsDescription, Iterables.getFirst(graph.getRawView().getBasicBlocks().get(2).getInstructions(), null));
final CCodeNode node = graph.getRawView().getBasicBlocks().get(2);
final NaviNode naviNode = graph.getNode(node);
final BackEndDebuggerProvider provider = new MockDebuggerProvider();
new CCodeNodeUpdater(graph, naviNode, node, provider);
instructions.add(instruction);
model.setInstructions(instructions);
assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
final CGraphSynchronizer synchronizer = new CGraphSynchronizer(graph, model);
CTypeResultsHighlighter.updateHighlighting(graph, Lists.newArrayList(instruction));
assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CGraphFunctions method selectNodesWithString.
/**
* Selects all nodes of a graph that contain a given search string.
*
* @param graph The graph to search through and select.
* @param searchString The search string to search for.
*/
public static void selectNodesWithString(final ZyGraph graph, final String searchString) {
Preconditions.checkNotNull(graph, "IE02117: Graph argument can not be null");
Preconditions.checkNotNull(searchString, "IE02118: Search string argument can not be null");
final GraphSearcher searcher = new GraphSearcher();
searcher.search(GraphHelpers.getNodes(graph), new ArrayList<NaviEdge>(), searchString);
final List<SearchResult> results = searcher.getResults();
final List<NaviNode> resultNodes = new ArrayList<NaviNode>();
for (final SearchResult searchResult : results) {
resultNodes.add((NaviNode) searchResult.getObject());
}
graph.selectNodes(resultNodes, true);
searcher.dispose();
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CGraphSearchField method jumpTo.
/**
* Jumps to a search result of the given index.
*
* @param index The index of the search result to jump to.
*/
public void jumpTo(final int index) {
m_searcher.getCursor().jumpTo(index);
final SearchResult result = m_searcher.getCursor().current();
if (result == null) {
return;
}
if (result.getObject() instanceof NaviNode) {
ZyGraphHelpers.centerNode(m_graph, (NaviNode) result.getObject(), false);
} else if (result.getObject() instanceof NaviEdge) {
ZyGraphHelpers.centerEdgeLabel(m_graph, (NaviEdge) result.getObject(), false);
}
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class GraphSearcher method clearResults.
/**
* Clears the results list.
*/
public void clearResults() {
for (final SearchResult result : m_results) {
if (result.getObject() instanceof NaviNode) {
((NaviNode) result.getObject()).setBackgroundColor(result.getLine(), result.getPosition(), result.getLength(), null);
} else if (result.getObject() instanceof NaviEdge) {
final NaviEdge edge = (NaviEdge) result.getObject();
final ZyLabelContent content = edge.getLabelContent();
content.getLineContent(result.getLine()).setBackgroundColor(result.getPosition(), result.getLength(), null);
}
}
m_results.clear();
m_cursor.clear();
m_changed = false;
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class ZyGraphBuilder method convertEdges.
/**
* Converts the edges of a view into Graph2D edges.
*
* @param edges The edges to convert.
* @param graph2D The graph where the edges are inserted.
* @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
* @param adjustColors
*/
private void convertEdges(final Collection<INaviEdge> edges, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final boolean adjustColors) {
for (final INaviEdge edge : edges) {
// Get the nodes connected by the edge
final NaviNode sourceNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getSource()));
final NaviNode targetNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getTarget()));
final Pair<Edge, NaviEdge> result = ZyEdgeBuilder.convertEdge(edge, sourceNode, targetNode, graph2D, adjustColors);
m_yedgeToEdgeMap.put(result.first(), result.second());
}
}
Aggregations