Search in sources :

Example 1 with HierarchyManager

use of y.view.hierarchy.HierarchyManager in project binnavi by google.

the class ZyGroupNodeRealizer method moveContent.

private void moveContent(final double dx, final double dy) {
    final Graph2D graph = (Graph2D) m_userData.getNode().getNode().getGraph();
    final HierarchyManager hm = graph.getHierarchyManager();
    // Find the children contained in the given group node.
    final NodeList childNodes = new NodeList();
    addChildren(hm, getNode(), childNodes);
    // Move the children.
    moveNodes(graph, childNodes.nodes(), dx, dy);
}
Also used : HierarchyManager(y.view.hierarchy.HierarchyManager) NodeList(y.base.NodeList) Graph2D(y.view.Graph2D)

Example 2 with HierarchyManager

use of y.view.hierarchy.HierarchyManager in project binnavi by google.

the class YHelpers method openFolder.

/**
   * Opens a folder node.
   * 
   * @param graph The graph the folder node belongs to.
   * @param folderNode The folder node to be opened.
   */
public static void openFolder(final Graph2D graph, final Node folderNode) {
    Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
    Preconditions.checkNotNull(folderNode, "Error: Folder node argument can not be null");
    final HierarchyManager hierarchy = graph.getHierarchyManager();
    final double w = graph.getWidth(folderNode);
    final double h = graph.getHeight(folderNode);
    final NodeList folderNodes = new NodeList();
    folderNodes.add(folderNode);
    graph.firePreEvent();
    for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
        // get original location of folder node
        final Graph2D innerGraph = (Graph2D) hierarchy.getInnerGraph(nc.node());
        final YPoint folderP = graph.getLocation(nc.node());
        final NodeList innerNodes = new NodeList(innerGraph.nodes());
        hierarchy.openFolder(nc.node());
        // get new location of group node
        final Rectangle2D.Double gBox = graph.getRealizer(nc.node()).getBoundingBox();
        // move grouped nodes to former location of folder node
        LayoutTool.moveSubgraph(graph, innerNodes.nodes(), folderP.x - gBox.x, folderP.y - gBox.y);
    }
    graph.firePostEvent();
    graph.unselectAll();
    for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
        graph.setSelected(nc.node(), true);
    }
    // to the node
    if ((w != graph.getWidth(folderNode)) || (h != graph.getHeight(folderNode))) {
        for (final EdgeCursor ec = folderNode.outEdges(); ec.ok(); ec.next()) {
            graph.setSourcePointRel(ec.edge(), YPoint.ORIGIN);
        }
        for (final EdgeCursor ec = folderNode.inEdges(); ec.ok(); ec.next()) {
            graph.setTargetPointRel(ec.edge(), YPoint.ORIGIN);
        }
    }
    graph.updateViews();
}
Also used : HierarchyManager(y.view.hierarchy.HierarchyManager) EdgeCursor(y.base.EdgeCursor) NodeList(y.base.NodeList) Rectangle2D(java.awt.geom.Rectangle2D) NodeCursor(y.base.NodeCursor) YPoint(y.geom.YPoint) Graph2D(y.view.Graph2D)

Example 3 with HierarchyManager

use of y.view.hierarchy.HierarchyManager in project binnavi by google.

the class ZyGraphBuilder method convert.

/**
   * Converts a view to a Graph2D object.
   *
   * @param nodes Nodes to convert.
   * @param edges Edges to convert.
   * @param graphSettings Graph settings used to build the graph.
   * @param adjustColors True, to initialize the colors of the nodes. False, otherwise.
   *
   * @return The created Graph2D object.
   * @throws LoadCancelledException Thrown if loading the graph was cancelled.
   */
public Graph2D convert(final Collection<INaviViewNode> nodes, final Collection<INaviEdge> edges, final ZyGraphViewSettings graphSettings, final boolean adjustColors) throws LoadCancelledException {
    Preconditions.checkNotNull(nodes, "IE00905: View can not be null");
    Preconditions.checkNotNull(edges, "IE00906: Edges argument can not be null");
    if (!m_loadReporter.report(GraphBuilderEvents.Started)) {
        throw new LoadCancelledException();
    }
    m_loadReporter.start();
    final Graph2D graph2D = new Graph2D();
    final HierarchyManager hierarchyManager = new HierarchyManager(graph2D);
    graph2D.setHierarchyManager(hierarchyManager);
    hierarchyManager.addHierarchyListener(new GroupNodeRealizer.StateChangeListener());
    checkCancellation(GraphBuilderEvents.InitializedGraph);
    // Keep track of all connections between view nodes and yfiles nodes
    final HashMap<INaviViewNode, Node> rawNodeToNodeMap = new HashMap<INaviViewNode, Node>();
    // To convert the view into a Graph2D object, it is necessary to convert every node
    // and every edge from the view into the corresponding yfiles objects.
    convertNodes(nodes, graph2D, rawNodeToNodeMap, graphSettings);
    checkCancellation(GraphBuilderEvents.ConvertedNodes);
    convertEdges(edges, graph2D, rawNodeToNodeMap, adjustColors);
    checkCancellation(GraphBuilderEvents.ConvertedEdges);
    setupGroupNodes(nodes, graph2D, rawNodeToNodeMap);
    checkCancellation(GraphBuilderEvents.CreatedGroupNodes);
    checkCancellation(GraphBuilderEvents.Finished);
    return graph2D;
}
Also used : GroupNodeRealizer(y.view.hierarchy.GroupNodeRealizer) HierarchyManager(y.view.hierarchy.HierarchyManager) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) Graph2D(y.view.Graph2D)

Example 4 with HierarchyManager

use of y.view.hierarchy.HierarchyManager in project binnavi by google.

the class AbstractZyGraph method setupHierarchyManager.

private void setupHierarchyManager() {
    if (m_graph.getHierarchyManager() == null) {
        final HierarchyManager hierarchyManager = new HierarchyManager(m_graph);
        m_graph.setHierarchyManager(hierarchyManager);
        hierarchyManager.addHierarchyListener(new GroupNodeRealizer.StateChangeListener());
    }
}
Also used : GroupNodeRealizer(y.view.hierarchy.GroupNodeRealizer) HierarchyManager(y.view.hierarchy.HierarchyManager)

Example 5 with HierarchyManager

use of y.view.hierarchy.HierarchyManager in project binnavi by google.

the class YHelpers method closeGroup.

/**
   * Closes a group node.
   * 
   * @param graph The graph the group node belongs to.
   * @param groupNode The group node to be closed.
   */
public static void closeGroup(final Graph2D graph, final Node groupNode) {
    Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
    Preconditions.checkNotNull(groupNode, "Error: Group node argument can not be null");
    final HierarchyManager hierarchy = graph.getHierarchyManager();
    final double w = graph.getWidth(groupNode);
    final double h = graph.getHeight(groupNode);
    final NodeList groupNodes = new NodeList();
    groupNodes.add(groupNode);
    graph.firePreEvent();
    for (final NodeCursor nc = groupNodes.nodes(); nc.ok(); nc.next()) {
        hierarchy.closeGroup(nc.node());
    }
    graph.firePostEvent();
    // to the node
    if ((w != graph.getWidth(groupNode)) || (h != graph.getHeight(groupNode))) {
        for (final EdgeCursor ec = groupNode.outEdges(); ec.ok(); ec.next()) {
            graph.setSourcePointRel(ec.edge(), YPoint.ORIGIN);
        }
        for (final EdgeCursor ec = groupNode.inEdges(); ec.ok(); ec.next()) {
            graph.setTargetPointRel(ec.edge(), YPoint.ORIGIN);
        }
    }
    graph.updateViews();
}
Also used : HierarchyManager(y.view.hierarchy.HierarchyManager) EdgeCursor(y.base.EdgeCursor) NodeList(y.base.NodeList) NodeCursor(y.base.NodeCursor)

Aggregations

HierarchyManager (y.view.hierarchy.HierarchyManager)8 Graph2D (y.view.Graph2D)5 Node (y.base.Node)3 NodeList (y.base.NodeList)3 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)2 EdgeCursor (y.base.EdgeCursor)2 NodeCursor (y.base.NodeCursor)2 GroupNodeRealizer (y.view.hierarchy.GroupNodeRealizer)2 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)1 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)1 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)1 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)1 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)1 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)1 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)1 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)1 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)1 IGroupNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode)1 IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)1