Search in sources :

Example 11 with IZyNodeRealizer

use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.

the class ZyNodeContentHelpers method getObjectWrapper.

public static ZyLineContent.ObjectWrapper getObjectWrapper(final ZyGraphNode<?> node, final double x, final double y) {
    final IZyNodeRealizer realizer = node.getRealizer();
    final ZyLabelContent content = realizer.getNodeContent();
    final Rectangle2D bounds = content.getBounds();
    final double xScale = realizer.getWidth() / bounds.getWidth();
    final double yPos = y - node.getY();
    final int row = node.positionToRow(yPos);
    if (row == -1) {
        return null;
    }
    final ZyLineContent lineContent = content.getLineContent(row);
    final double position = (((x - node.getX()) / xScale) - content.getPaddingLeft()) / lineContent.getCharWidth();
    return lineContent.getObjectWrapper((int) position);
}
Also used : IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) Rectangle2D(java.awt.geom.Rectangle2D)

Example 12 with IZyNodeRealizer

use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.

the class ZyGraphNodeBuilder method convertNode.

/**
   * Creates a graph node from a raw node.
   * 
   * @param node The raw node that provides the underlying data.
   * @param graph2D The graph object where the node is created.
   * @param graphSettings Graph settings used to build the graph.
   * 
   * @return The created YNode/NaviNode pair.
   */
public static Pair<Node, NaviNode> convertNode(final INaviViewNode node, final Graph2D graph2D, final ZyGraphViewSettings graphSettings) {
    Preconditions.checkNotNull(node, "IE00909: Node argument can not be null");
    Preconditions.checkNotNull(graph2D, "IE00910: Graph2D argument can not be null");
    // Create the node in the Graph2D
    final Node yNode = createNode(graph2D, node);
    final ZyLabelContent content = ZyGraphNodeBuilder.buildContent(node, graphSettings, null);
    final IZyNodeRealizer realizer = createRealizer(node, content);
    // Associate the user data with the Graph2D node
    final NaviNode zyNode = new NaviNode(yNode, realizer, node);
    realizer.setUserData(new ZyNodeData<NaviNode>(zyNode));
    realizer.updateContentSelectionColor();
    graph2D.setRealizer(yNode, realizer.getRealizer());
    return new Pair<Node, NaviNode>(yNode, zyNode);
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Node(y.base.Node) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 13 with IZyNodeRealizer

use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.

the class ClipboardCopier method copyToClipboard.

/**
   * Copies the text of a line of a node to the clip board.
   * 
   * @param node The node that contains the line.
   * @param line Index of the line to copy to the clip board.
   */
public static void copyToClipboard(final ZyGraphNode<?> node, final int line) {
    Preconditions.checkNotNull(node, "Error: Node argument can not be null");
    final IZyNodeRealizer realizer = node.getRealizer();
    final ZyLabelContent content = realizer.getNodeContent();
    Preconditions.checkArgument((line >= 0) && (line < content.getLineCount()), "Error: Line argument is out of bounds");
    if (content.isSelectable()) {
        final ZyLabelContent zyContent = content;
        ClipboardHelpers.copyToClipboard(zyContent.getLineContent(line).getText());
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)

Aggregations

IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)13 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)10 CDefaultLabelEventHandler (com.google.security.zynamics.zylib.gui.zygraph.CDefaultLabelEventHandler)3 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)3 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)2 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)2 CGroupNode (com.google.security.zynamics.binnavi.disassembly.CGroupNode)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)1 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)1 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)1 Pair (com.google.security.zynamics.zylib.general.Pair)1 ICodeNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode)1 IFunctionNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IFunctionNode)1 IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)1 ZyRegenerateableNodeRealizer (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyRegenerateableNodeRealizer)1 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)1 ZyProximityNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer)1 Point2D (java.awt.geom.Point2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1