Search in sources :

Example 11 with Graph2D

use of y.view.Graph2D in project binnavi by google.

the class CRootNodeComponent method createGui.

/**
   * Creates the GUI of this component.
   */
private void createGui() {
    final Graph2DView view = new ZyGraph2DView(new Graph2D());
    view.setScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final DefaultBackgroundRenderer backgroundRenderer = new DefaultBackgroundRenderer(view);
    backgroundRenderer.setImage(BACKGROUND_IMAGE);
    backgroundRenderer.setMode(DefaultBackgroundRenderer.CENTERED);
    backgroundRenderer.setColor(Color.white);
    view.setBackgroundRenderer(backgroundRenderer);
    add(view, BorderLayout.CENTER);
}
Also used : DefaultBackgroundRenderer(y.view.DefaultBackgroundRenderer) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) Graph2DView(y.view.Graph2DView) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) Graph2D(y.view.Graph2D)

Example 12 with Graph2D

use of y.view.Graph2D in project binnavi by google.

the class GraphSearcherTest method testSearchVisible.

@Test
public void testSearchVisible() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final MockSqlProvider sql = new MockSqlProvider();
    final CModule module = MockCreator.createModule(sql);
    module.load();
    final CFunction function = MockCreator.createFunction(module, sql);
    final CView m_view = MockCreator.createView(sql, module);
    final CInstruction instruction1 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction2 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction3 = MockCreator.createInstruction(module, sql);
    m_view.load();
    final CCodeNode node1 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final CCodeNode node2 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final CCodeNode node3 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final ZyNodeRealizer<NaviNode> r1 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final ZyNodeRealizer<NaviNode> r2 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final ZyNodeRealizer<NaviNode> r3 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final Graph2D g = new Graph2D();
    g.setHierarchyManager(new HierarchyManager(g));
    final NaviNode m_node1 = new NaviNode(g.createNode(), r1, node1);
    final NaviNode m_node2 = new NaviNode(g.createNode(), r2, node2);
    final NaviNode m_node3 = new NaviNode(g.createNode(), r3, node3);
    assertTrue(m_node1.isVisible());
    final GraphSearcher searcher = new GraphSearcher();
    searcher.getSettings().setOnlyVisible(true);
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), 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());
    searcher.getCursor().next();
    assertEquals(m_node2, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    searcher.getCursor().next();
    assertEquals(m_node3, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    m_node2.getRawNode().setVisible(false);
    searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), 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());
    searcher.getCursor().next();
    assertEquals(m_node3, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) Graph2D(y.view.Graph2D) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) HierarchyManager(y.view.hierarchy.HierarchyManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Aggregations

Graph2D (y.view.Graph2D)12 HierarchyManager (y.view.hierarchy.HierarchyManager)5 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)3 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)2 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)2 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)2 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)2 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)2 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)2 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)2 HashMap (java.util.HashMap)2 Edge (y.base.Edge)2 EdgeCursor (y.base.EdgeCursor)2 Node (y.base.Node)2 NodeCursor (y.base.NodeCursor)2 NodeList (y.base.NodeList)2 YPoint (y.geom.YPoint)2 EdgeRealizer (y.view.EdgeRealizer)2 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)1