Search in sources :

Example 11 with Edge

use of y.base.Edge 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 12 with Edge

use of y.base.Edge 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 13 with Edge

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

the class CNodeMover method moveNode.

public static void moveNode(final AbstractZyGraph<?, ?> graph, final ZyGraphNode<?> node, final double xdist, final double ydist, final Set<Bend> movedBends) {
    graph.getGraph().getRealizer(node.getNode()).moveBy(xdist, ydist);
    for (final EdgeCursor cursor = node.getNode().edges(); cursor.ok(); cursor.next()) {
        final Edge edge = cursor.edge();
        for (final BendCursor bendCursor = graph.getGraph().getRealizer(edge).bends(); bendCursor.ok(); bendCursor.next()) {
            final Bend bend = bendCursor.bend();
            if (movedBends.contains(bend)) {
                continue;
            }
            bend.moveBy(xdist, ydist);
            movedBends.add(bend);
        }
    }
}
Also used : EdgeCursor(y.base.EdgeCursor) BendCursor(y.view.BendCursor) Bend(y.view.Bend) Edge(y.base.Edge)

Example 14 with Edge

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

the class CEdgeHighlighter method highlightEdgesOfNode.

/**
   * Highlights all edges of a node.
   * 
   * @param node The node whose edges are highlighted.
   * @param highlight True to add highlighting to the edges. False to remove it.
   */
public static void highlightEdgesOfNode(final Node node, final boolean highlight) {
    final EdgeCursor edges = node.edges();
    int edgeCount = node.degree();
    for (Edge edge = edges.edge(); edgeCount > 0; edgeCount--) {
        final EdgeRealizer edgeRealizer = ((Graph2D) node.getGraph()).getRealizer(edge);
        highlightEdge(edgeRealizer, highlight);
        edges.cyclicNext();
        edge = edges.edge();
    }
}
Also used : EdgeCursor(y.base.EdgeCursor) EdgeRealizer(y.view.EdgeRealizer) Edge(y.base.Edge) Graph2D(y.view.Graph2D)

Example 15 with Edge

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

the class ZyGraphBuilder method convertEdges.

/**
   * Converts the edges of a view into Graph2D edges.
   *
   * @param edges The edges to convert.
   * @param graph2D The graph where the edges are inserted.
   * @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
   * @param adjustColors
   */
private void convertEdges(final Collection<INaviEdge> edges, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final boolean adjustColors) {
    for (final INaviEdge edge : edges) {
        // Get the nodes connected by the edge
        final NaviNode sourceNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getSource()));
        final NaviNode targetNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getTarget()));
        final Pair<Edge, NaviEdge> result = ZyEdgeBuilder.convertEdge(edge, sourceNode, targetNode, graph2D, adjustColors);
        m_yedgeToEdgeMap.put(result.first(), result.second());
    }
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Aggregations

Edge (y.base.Edge)18 Node (y.base.Node)7 EdgeCursor (y.base.EdgeCursor)6 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)5 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)4 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)4 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)4 ZyEdgeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer)4 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 ArrayList (java.util.ArrayList)3 HitInfo (y.view.HitInfo)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 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)2 ReilEdge (com.google.security.zynamics.reil.ReilEdge)2