use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge 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.NaviEdge 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());
}
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge in project binnavi by google.
the class CSearchResultComparator method compare.
@Override
public // NO_UCD
int compare(// NO_UCD
final SearchResult first, // NO_UCD
final SearchResult second) {
IAddress firstAddress = null;
IAddress secondAddress = null;
if (first.getObject() instanceof NaviEdge) {
firstAddress = getAddress((NaviEdge) first.getObject());
} else if (first.getObject() instanceof NaviNode) {
firstAddress = getAddress(((NaviNode) first.getObject()).getRawNode());
}
if (second.getObject() instanceof NaviEdge) {
secondAddress = getAddress((NaviEdge) second.getObject());
} else if (second.getObject() instanceof NaviNode) {
secondAddress = getAddress(((NaviNode) second.getObject()).getRawNode());
}
if ((firstAddress == null) || (secondAddress == null)) {
throw new IllegalStateException("IE01155: Address can't be null.");
}
return firstAddress.toBigInteger().compareTo(secondAddress.toBigInteger());
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge in project binnavi by google.
the class CBreakpointTableTest method testAddedDebugger.
/**
* This test is making sure that listeners are correctly attached to new debuggers.
*
* @throws CouldntSaveDataException
* @throws FileReadException
*/
@Test
public void testAddedDebugger() throws CouldntSaveDataException, FileReadException {
ConfigManager.instance().read();
final INaviModule mockModule = new MockModule();
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final ZyGraphViewSettings settings = new ZyGraphViewSettings(new FlowGraphSettingsConfigItem());
settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
final ZyGraph graph = new ZyGraph(new MockView(), new LinkedHashMap<Node, NaviNode>(), new LinkedHashMap<Edge, NaviEdge>(), settings, new ZyGraph2DView());
final IViewContainer viewContainer = new MockViewContainer();
final CBreakpointTable table = new CBreakpointTable(debuggerProvider, graph, viewContainer);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
final MockModule module = new MockModule();
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0)))));
debuggerProvider.addDebugger(debugger);
table.dispose();
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge in project binnavi by google.
the class GraphSearcherTest method testSearchSelected.
@Test
public void testSearchSelected() {
final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
final GraphSearcher searcher = new GraphSearcher();
searcher.getSettings().setOnlySelected(true);
m_content.addLineContent(new ZyLineContent("Hello my Test", null));
searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
assertNull(searcher.getCursor().current());
m_node1.getRawNode().setSelected(true);
searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
assertEquals(m_node1, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
// TEST: Do not move beyond the last result
searcher.getCursor().next();
assertEquals(m_node1, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
}
Aggregations