Search in sources :

Example 6 with Node

use of y.base.Node in project binnavi by google.

the class TypeDependenceGraph method deleteType.

/**
   * Delete the given base type. If other types still depend on this type, the set of affected types
   * is returned.
   *
   * @param baseType The base type to delete.
   * @return Returns The set of base types that depend on the deleted type.
   */
public ImmutableSet<BaseType> deleteType(final BaseType baseType) {
    Preconditions.checkNotNull(baseType, "IE02766: Base type can not be null.");
    final Node containedTypeNode = containedRelationMap.get(baseType);
    Preconditions.checkNotNull(containedTypeNode, "Unable to delete type: corresponding node not found in the dependence graph.");
    final ImmutableSet<BaseType> affectedTypes = determineDependentTypes(baseType);
    containedRelation.removeNode(containedTypeNode);
    containedRelationMap.remove(baseType);
    return affectedTypes;
}
Also used : BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) Node(y.base.Node)

Example 7 with Node

use of y.base.Node in project binnavi by google.

the class ZyGraphBuilder method convertNodes.

/**
   * Converts the nodes of a view into Graph2D nodes.
   *
   * @param nodes The nodes to convert.
   * @param graph2D The graph where the nodes are inserted.
   * @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
   * @param graphSettings Graph settings used to build the graph.
   */
private void convertNodes(final Collection<INaviViewNode> nodes, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final ZyGraphViewSettings graphSettings) {
    for (final INaviViewNode node : nodes) {
        final Pair<Node, NaviNode> result = ZyGraphNodeBuilder.convertNode(node, graph2D, graphSettings);
        // Keep track of the view node => Graph2D node mapping
        rawNodeToNodeMap.put(node, result.first());
        m_ynodeToNodeMap.put(result.first(), result.second());
    }
}
Also used : Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode)

Example 8 with Node

use of y.base.Node in project binnavi by google.

the class ZyGraphBuilder method setupGroupNodes.

/**
   * Puts nodes that have raw parent group nodes into the corresponding yFiles group nodes.
   *
   * @param nodes The nodes to be put into their parent group nodes.
   * @param graph2D The yFiles graph the nodes belong to.
   * @param rawNodeToNodeMap Maps between raw nodes and yFiles nodes.
   */
private static void setupGroupNodes(final Iterable<INaviViewNode> nodes, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap) {
    for (final INaviViewNode node : nodes) {
        if (node.getParentGroup() != null) {
            final Node child = rawNodeToNodeMap.get(node);
            final Node parent = rawNodeToNodeMap.get(node.getParentGroup());
            graph2D.getHierarchyManager().setParentNode(child, parent);
        }
    }
}
Also used : 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)

Example 9 with Node

use of y.base.Node 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 10 with Node

use of y.base.Node in project binnavi by google.

the class CViewGraphSynchronizer method updateParentNode.

/**
   * Updates the parent group node of a node.
   *
   * @param node The node whose parent group node is updated.
   * @param groupNode The new parent group node.
   */
private void updateParentNode(final INaviViewNode node, final INaviGroupNode groupNode) {
    final Node mappedNaviNode = m_mappings.getYNode(node);
    final Node mappedGroupNode = groupNode == null ? null : m_mappings.getYNode(groupNode);
    if (mappedNaviNode != null) {
        // We need this null-check here because a group node can lose all
        // of its members to another group node while the group node itself
        // is also added to the new group. Since empty group nodes are
        // automatically removed, the original group node can already be
        // removed from the graph before the changedParentGroup event is sent.
        m_graph.getGraph().getHierarchyManager().setParentNode(mappedNaviNode, mappedGroupNode);
        m_graph.updateViews();
    }
}
Also used : IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) Node(y.base.Node) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode)

Aggregations

Node (y.base.Node)28 ZyGraphNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode)9 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 Edge (y.base.Edge)7 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)4 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)4 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)3 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)3 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 CStateChange (com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)3 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)3 ZyProximityNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)2 CallGraphSettingsConfigItem (com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem)2 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)2