use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class ZyGraphNodeBuilder method convertNode.
/**
* Creates a graph node from a raw node.
*
* @param node The raw node that provides the underlying data.
* @param graph2D The graph object where the node is created.
* @param graphSettings Graph settings used to build the graph.
*
* @return The created YNode/NaviNode pair.
*/
public static Pair<Node, NaviNode> convertNode(final INaviViewNode node, final Graph2D graph2D, final ZyGraphViewSettings graphSettings) {
Preconditions.checkNotNull(node, "IE00909: Node argument can not be null");
Preconditions.checkNotNull(graph2D, "IE00910: Graph2D argument can not be null");
// Create the node in the Graph2D
final Node yNode = createNode(graph2D, node);
final ZyLabelContent content = ZyGraphNodeBuilder.buildContent(node, graphSettings, null);
final IZyNodeRealizer realizer = createRealizer(node, content);
// Associate the user data with the Graph2D node
final NaviNode zyNode = new NaviNode(yNode, realizer, node);
realizer.setUserData(new ZyNodeData<NaviNode>(zyNode));
realizer.updateContentSelectionColor();
graph2D.setRealizer(yNode, realizer.getRealizer());
return new Pair<Node, NaviNode>(yNode, zyNode);
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CIndegreeEvaluatorTest method testComplete.
@Test
public void testComplete() {
final NaviNode node = CNaviNodeFactory.get();
assertTrue(CIndegreeEvaluator.matches(node, "=", 0));
assertFalse(CIndegreeEvaluator.matches(node, "=", 1));
assertFalse(CIndegreeEvaluator.matches(node, "<", 0));
assertFalse(CIndegreeEvaluator.matches(node, ">", 0));
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CColorEvaluatorTest method testComplete.
@Test
public void testComplete() {
final NaviNode node = CNaviNodeFactory.get();
assertTrue(CColorEvaluator.evaluate(node, Color.red));
assertFalse(CColorEvaluator.evaluate(node, Color.green));
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CCriteriumExecuterTest method testSingleTagCriterion.
@Test
public void testSingleTagCriterion() {
final Set<CTag> tags = new HashSet<CTag>();
for (final NaviNode node : m_graph.getNodes()) {
if (node.getRawNode().isTagged()) {
tags.addAll(node.getRawNode().getTags());
}
}
assertEquals(1, tags.size());
final CCachedTagCriterium criterium = new CCachedTagCriterium(false, Iterables.getOnlyElement(tags));
final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
assertEquals(0, m_graph.getSelectedNodes().size());
CCriteriumExecuter.execute(m_tree, m_graph);
assertEquals(1, m_graph.getSelectedNodes().size());
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class ZyGraphTest method testAddedCodeNode.
@Test
public void testAddedCodeNode() {
assertEquals(7, m_graph.visibleNodeCount());
assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
assertEquals(96, m_graph.getRawView().getNodeCount());
final MockFunction function = new MockFunction(m_provider);
final List<INaviInstruction> instructions = Lists.newArrayList((INaviInstruction) new MockInstruction(new CAddress(0x123456), "mov", new ArrayList<COperandTree>(), null, m_module));
final CCodeNode codeNode = m_graph.getRawView().getContent().createCodeNode(function, instructions);
assertEquals(8, m_graph.visibleNodeCount());
assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
assertEquals(97, m_graph.getRawView().getNodeCount());
final List<NaviNode> nodes = GraphHelpers.getNodes(m_graph);
final NaviNode cnn = searchNode(nodes, codeNode);
assertEquals(codeNode, cnn.getRawNode());
assertTrue(codeNode.isVisible());
assertEquals(codeNode.isVisible(), cnn.isVisible());
codeNode.setVisible(false);
assertFalse(codeNode.isVisible());
assertEquals(codeNode.isVisible(), cnn.isVisible());
codeNode.setVisible(true);
assertTrue(codeNode.isVisible());
assertEquals(codeNode.isVisible(), cnn.isVisible());
assertFalse(codeNode.isSelected());
assertEquals(codeNode.isSelected(), cnn.isSelected());
codeNode.setSelected(false);
assertFalse(codeNode.isSelected());
assertEquals(codeNode.isSelected(), cnn.isSelected());
codeNode.setSelected(true);
assertTrue(codeNode.isSelected());
assertEquals(codeNode.isSelected(), cnn.isSelected());
assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
codeNode.setColor(Color.GREEN);
assertEquals(Color.GREEN, codeNode.getColor());
assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
codeNode.setX(100);
assertEquals(100, codeNode.getX(), 0.1);
assertEquals(codeNode.getX(), cnn.getX(), 0.1);
codeNode.setY(200);
assertEquals(200, codeNode.getY(), 0.1);
assertEquals(codeNode.getY(), cnn.getY(), 0.1);
}
Aggregations