Search in sources :

Example 21 with Node

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

the class ZyGraphVerifier method verifyMap.

/**
   * Verifies the map that maps between ynode objects and node objects. If the map has an incorrect
   * format, the function throws an {@link IllegalArgumentException}.
   * 
   * @param graph
   */
public static <NodeType> void verifyMap(final Graph2D graph, final HashMap<Node, NodeType> nodeMap) {
    // Let's verify the node map.
    //
    // - The number of mappings must equal or less than the number of graphs in the node (each node
    // must be mapped, but some nodes can be hidden in folder nodes)
    // - No element of the key set/value set of the mapping must appear more than once
    // - No key or value of the mapping must be null
    Preconditions.checkArgument(graph.nodeCount() <= nodeMap.size(), "Error: Invalid node map (Graph contains " + graph.nodeCount() + " nodes while nodeMap contains " + nodeMap.size() + " nodes");
    final HashSet<Node> visitedNodes = new HashSet<Node>();
    final HashSet<NodeType> visitedNodes2 = new HashSet<NodeType>();
    for (final Map.Entry<Node, NodeType> elem : nodeMap.entrySet()) {
        final Node ynode = elem.getKey();
        final NodeType node = elem.getValue();
        Preconditions.checkArgument((ynode != null) && (node != null), "Error: Invalid node map");
        // We can not check this because of nodes hidden in folder nodes
        // if (!graph.contains(ynode))
        Preconditions.checkArgument(!visitedNodes.contains(ynode), "Error: Invalid node map");
        Preconditions.checkArgument(!visitedNodes2.contains(node), "Error: Invalid node map");
        visitedNodes.add(ynode);
        visitedNodes2.add(node);
    }
}
Also used : Node(y.base.Node) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 22 with Node

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

the class CSelectionMode method selectionBoxAction.

@Override
protected void selectionBoxAction(final Rectangle rect, final boolean shiftMode) {
    m_graph.getGraph().firePreEvent();
    final NodeList selectedNodes = new NodeList();
    for (final NodeCursor node = m_graph.getGraph().nodes(); node.ok(); node.next()) {
        final NodeType zyNode = m_graph.getNode(node.node());
        if ((zyNode == null) || (zyNode instanceof ZyProximityNode<?>)) {
            continue;
        }
        if (belongsToSelection(node.node(), rect)) {
            selectedNodes.add(node.node());
        }
    }
    if (((getLastDragEvent().getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == 0) && ((getLastDragEvent().getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == 0)) {
        m_graph.getGraph().unselectAll();
    }
    for (final Object nodeObject : selectedNodes) {
        final Node node = (Node) nodeObject;
        m_graph.getGraph().setSelected(node, true);
    }
    for (final EdgeCursor ec = m_graph.getGraph().selectedEdges(); ec.ok(); ec.next()) {
        final Edge e = ec.edge();
        final Node src = e.source();
        final Node dst = e.target();
        if (!m_graph.getGraph().getRealizer(src).isSelected() && !m_graph.getGraph().getRealizer(dst).isSelected()) {
            m_graph.getGraph().getRealizer(e).setSelected(false);
        }
    }
    m_graph.getGraph().firePostEvent();
    m_graph.getGraph().updateViews();
}
Also used : EdgeCursor(y.base.EdgeCursor) NodeList(y.base.NodeList) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node) ZyProximityNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode) NodeCursor(y.base.NodeCursor) Edge(y.base.Edge) ZyProximityNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode)

Example 23 with Node

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

the class CMousePressedHandler method handleMousePressed.

public static IMouseStateChange handleMousePressed(final CStateFactory<?, ?> factory, final IMouseState defaultState, final AbstractZyGraph<?, ?> graph, final MouseEvent event) {
    final double x = graph.getEditMode().translateX(event.getX());
    final double y = graph.getEditMode().translateY(event.getY());
    final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);
    if (hitInfo.hasHitNodes()) {
        final Node n = hitInfo.getHitNode();
        if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) {
            return new CStateChange(factory.createNodePressedLeftState(n, event), true);
        } else if (SwingUtilities.isRightMouseButton(event)) {
            return new CStateChange(factory.createNodePressedRightState(n, event), true);
        } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
            return new CStateChange(factory.createNodePressedMiddleState(n, event), false);
        } else {
            return new CStateChange(defaultState, true);
        }
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException("yFiles Labels are not in use...");
    } else if (hitInfo.hasHitEdges()) {
        final Edge edge = hitInfo.getHitEdge();
        if (SwingUtilities.isLeftMouseButton(event)) {
            return new CStateChange(factory.createEdgePressedLeftState(edge, event), true);
        } else if (SwingUtilities.isRightMouseButton(event)) {
            return new CStateChange(factory.createEdgePressedRightState(edge, event), true);
        } else {
            return new CStateChange(defaultState, true);
        }
    } else if (hitInfo.hasHitEdgeLabels()) {
        // {
        return new CStateChange(defaultState, true);
    // }
    } else if (hitInfo.hasHitBends()) {
        final Bend bend = hitInfo.getHitBend();
        if (SwingUtilities.isLeftMouseButton(event)) {
            return new CStateChange(factory.createBendPressedLeftState(bend, event), true);
        } else {
            return new CStateChange(defaultState, true);
        }
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(factory.createDefaultState(), true);
    } else {
        if (SwingUtilities.isLeftMouseButton(event)) {
            return new CStateChange(factory.createBackgroundPressedLeftState(event), true);
        } else if (SwingUtilities.isRightMouseButton(event)) {
            return new CStateChange(factory.createBackgroundPressedRightState(event), true);
        }
        return new CStateChange(factory.createDefaultState(), true);
    }
}
Also used : HitInfo(y.view.HitInfo) Bend(y.view.Bend) Node(y.base.Node) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange) Edge(y.base.Edge)

Example 24 with Node

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

the class AbstractZyGraph method removeNode.

protected void removeNode(final NodeType node) {
    if (node.getNode().getGraph() == null) {
        m_graph.reInsertNode(node.getNode());
    }
    final HierarchyManager manager = m_graph.getHierarchyManager();
    final Node n = node.getNode();
    if (manager.isNormalNode(n)) {
        m_graph.removeNode(node.getNode());
    } else if (getGraph().getHierarchyManager().isFolderNode(node.getNode())) {
        GroupHelpers.extractFolder(m_graph, node.getNode());
        m_graph.removeNode(node.getNode());
    } else if (getGraph().getHierarchyManager().isGroupNode(node.getNode())) {
        GroupHelpers.extractGroup(m_graph, node.getNode());
        m_graph.removeNode(node.getNode());
    }
    m_mappings.removeNode(node);
}
Also used : HierarchyManager(y.view.hierarchy.HierarchyManager) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node)

Example 25 with Node

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

the class TypeDependenceGraph method determineDependentTypes.

/**
   * Determines the set of base types that are (transitively) contained within baseType. A type A is
   * said to be contained within B iff B has a member of type A, or if there exists a chain of
   * nested types within B leading to at least one type that has a member of type A.
   *
   * @param baseType The type for which to determine the set of dependent types.
   * @return The set of dependent types.
   */
public ImmutableSet<BaseType> determineDependentTypes(final BaseType baseType) {
    Preconditions.checkNotNull(baseType, "Error: Base type can not be null.");
    final Node typeNode = containedRelationMap.get(baseType);
    final TypeSearch search = new TypeSearch(containedRelationMap.inverse());
    search.start(containedRelation, typeNode);
    return search.getDependentTypes();
}
Also used : Node(y.base.Node)

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