Search in sources :

Example 16 with Node

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

the class CNodeEditState method mouseReleased.

@Override
public IMouseStateChange mouseReleased(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    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()) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretEnd(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedLeftState(n, event), true);
            }
        } else if (SwingUtilities.isRightMouseButton(event)) {
            if (n == m_node) {
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedRightState(n, event), true);
            }
        } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretEnd(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true);
            }
        } else {
            return new CStateChange(this, false);
        }
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true);
    } else if (hitInfo.hasHitEdgeLabels()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel().getEdge(), event), true);
    } else if (hitInfo.hasHitBends()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true);
    } else if (hitInfo.hasHitPorts()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createDefaultState(), true);
    } else {
        // User left-pressed the background.
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true);
    }
}
Also used : HitInfo(y.view.HitInfo) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 17 with Node

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

the class CReilInstructionGraph method createInstructionNode.

/**
   * Creates an instruction graph node
   * 
   * @param reilInstruction The REIL instruction which will be contained in the node.
   * 
   * @return The yfiles node which has been created and inserted in the graph.
   */
private Node createInstructionNode(final ReilInstruction reilInstruction) {
    final Node node = m_internalGraph.createNode();
    m_nodesMap.put(node, new ReilInstructionGraphNode(reilInstruction));
    return node;
}
Also used : IInstructionGraphNode(com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.interfaces.IInstructionGraphNode) Node(y.base.Node) ReilInstructionGraphNode(com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.ReilInstructionGraphNode) ReilInstructionGraphNode(com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.ReilInstructionGraphNode)

Example 18 with Node

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

the class ZyDefaultProximityBrowser method deleteProximityBrowsingNodes.

/**
   * Removes all proximity browsing nodes from the graph.
   */
protected void deleteProximityBrowsingNodes() {
    // each node deletion triggers the selection state listener
    // which updates proximity browsing automatically
    // this is suppressed here by setting m_isActive temporarily to false
    m_internallyDisabled = true;
    for (final Node node : m_proximityMap.keySet()) {
        m_graph.getGraph().removeNode(node);
    }
    m_proximityMap.clear();
    for (final Entry<ZyProximityNode<?>, InternalNodeListener> entry : m_nodeListeners.entrySet()) {
        ((IViewNode<?>) entry.getKey().getRawNode().getAttachedNode()).removeListener(entry.getValue());
    }
    m_nodeListeners.clear();
    m_internallyDisabled = false;
}
Also used : IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) 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 19 with Node

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

the class CBreakpointTableTest method testAddedDebugger.

/**
   * This test is making sure that listeners are correctly attached to new debuggers.
   *
   * @throws CouldntSaveDataException
   * @throws FileReadException
   */
@Test
public void testAddedDebugger() throws CouldntSaveDataException, FileReadException {
    ConfigManager.instance().read();
    final INaviModule mockModule = new MockModule();
    final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final ZyGraphViewSettings settings = new ZyGraphViewSettings(new FlowGraphSettingsConfigItem());
    settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
    final ZyGraph graph = new ZyGraph(new MockView(), new LinkedHashMap<Node, NaviNode>(), new LinkedHashMap<Edge, NaviEdge>(), settings, new ZyGraph2DView());
    final IViewContainer viewContainer = new MockViewContainer();
    final CBreakpointTable table = new CBreakpointTable(debuggerProvider, graph, viewContainer);
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    final MockModule module = new MockModule();
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0)))));
    debuggerProvider.addDebugger(debugger);
    table.dispose();
}
Also used : FlowGraphSettingsConfigItem(com.google.security.zynamics.binnavi.config.FlowGraphSettingsConfigItem) IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) MockViewContainer(com.google.security.zynamics.binnavi.disassembly.MockViewContainer) ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Example 20 with Node

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

the class ZyGraphLayeredRenderer method isAnyParentNodeSelected.

/**
   * Determines whether any of the parent nodes of the given node is selected.
   */
private boolean isAnyParentNodeSelected(final Node n) {
    final Graph2D graph = (Graph2D) n.getGraph();
    final HierarchyManager hierarchy = graph.getHierarchyManager();
    if (hierarchy == null) {
        return false;
    }
    boolean result = false;
    Node parent = hierarchy.getParentNode(n);
    while (parent != null) {
        if (graph.isSelected(parent)) {
            result = true;
            break;
        }
        parent = hierarchy.getParentNode(parent);
    }
    return result;
}
Also used : HierarchyManager(y.view.hierarchy.HierarchyManager) Node(y.base.Node) Graph2D(y.view.Graph2D)

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