Search in sources :

Example 1 with ZyLabelContent

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

the class CSearchResultsDialog method setResults.

/**
   * Fills the search results table model with search results data.
   *
   * @param results The search results data.
   */
private void setResults(final List<SearchResult> results) {
    final Object[][] data = new Object[results.size()][1];
    int counter = 0;
    for (final SearchResult result : results) {
        if (result.getObject() instanceof NaviNode) {
            final NaviNode node = (NaviNode) result.getObject();
            final ZyLabelContent labelContent = node.getRealizer().getNodeContent();
            final String lineText = labelContent.getLineContent(result.getLine()).getText();
            data[counter++][0] = lineText;
        } else if (result.getObject() instanceof NaviEdge) {
            final NaviEdge edge = (NaviEdge) result.getObject();
            final ZyLabelContent labelContent = edge.getLabelContent();
            final String lineText = labelContent.getLineContent(result.getLine()).getText();
            data[counter++][0] = lineText;
        }
    }
    m_table.setModel(new CResultsTableModel(data, new String[] { "Result" }));
    m_resultsLabel.setText(String.format("%d search results", data.length));
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) SearchResult(com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)

Example 2 with ZyLabelContent

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

the class ZyEdgeBuilder method convertEdge.

/**
   * Creates a graph node from a raw edge.
   *
   * @param edge The raw edge that provides the underlying data.
   * @param sourceNode Source node of the edge.
   * @param targetNode Target node of the edge.
   * @param graph2D The graph object where the edge is created.
   * @param adjustColors Flag that indicates whether the initial color of all edges should be
   *        recalculated according to their type.
   *
   * @return The created YNode/NaviNode pair.
   */
public static Pair<Edge, NaviEdge> convertEdge(final INaviEdge edge, final NaviNode sourceNode, final NaviNode targetNode, final Graph2D graph2D, final boolean adjustColors) {
    // Build the edge label if necessary
    final ZyLabelContent content = ZyEdgeBuilder.buildContent(edge);
    // Create the edge realizer of the new edge
    final ZyEdgeRealizer<NaviEdge> realizer = new ZyEdgeRealizer<NaviEdge>(content, new CEdgeUpdater(edge));
    // Create the edge
    final Edge g2dEdge = graph2D.createEdge(sourceNode.getNode(), targetNode.getNode(), realizer);
    if (adjustColors) {
        EdgeInitializer.adjustColor(edge);
    }
    EdgeInitializer.initializeEdgeType(edge, realizer);
    graph2D.getRealizer(g2dEdge).setLineColor(edge.getColor());
    // Associate user data with the edge
    final NaviEdge zyEdge = new NaviEdge(sourceNode, targetNode, g2dEdge, realizer, edge);
    NaviNode.link(sourceNode, targetNode);
    final ZyEdgeData<NaviEdge> data = new ZyEdgeData<NaviEdge>(zyEdge);
    realizer.setUserData(data);
    return new Pair<Edge, NaviEdge>(g2dEdge, zyEdge);
}
Also used : ZyEdgeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) CEdgeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CEdgeUpdater) ZyEdgeData(com.google.security.zynamics.zylib.gui.zygraph.edges.ZyEdgeData) 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) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 3 with ZyLabelContent

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

the class CAbstractKeyBehavior method updateLabelSize.

private void updateLabelSize() {
    final ZyLabelContent labelContent = getLabelContent();
    final IZyEditableObject labelModel = labelContent.getModel();
    labelContent.getLineEditor().recreateLabelLines(labelContent, labelModel);
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)

Example 4 with ZyLabelContent

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

the class CCursorKeyBehavior method handleNotShiftAndNotCtrl.

protected void handleNotShiftAndNotCtrl(final int xdelta, final int ydelta) {
    final ZyLabelContent labelContent = getLabelContent();
    int caretStartPos_X = getCaretStartPosX();
    int mousePressed_X = getCaretMousePressedX();
    int mousePressed_Y = getCaretMousePressedY();
    int caretEndPos_X = getCaretEndPosX();
    int mouseReleased_X = getCaretMouseReleasedX();
    int mouseReleased_Y = getCaretMouseReleasedY();
    if (isSelection() && (xdelta != 0) && (ydelta == 0)) {
        if ((mousePressed_Y <= mouseReleased_Y) && (mousePressed_X <= mouseReleased_X)) {
            if (xdelta < 0) {
                mouseReleased_X = mousePressed_X;
                caretEndPos_X = caretStartPos_X;
                mouseReleased_Y = mousePressed_Y;
            } else {
                mousePressed_X = mouseReleased_X;
                caretStartPos_X = mouseReleased_X;
                mousePressed_Y = mouseReleased_Y;
            }
        } else {
            if (xdelta > 0) {
                mouseReleased_X = mousePressed_X;
                caretEndPos_X = caretStartPos_X;
                mouseReleased_Y = mousePressed_Y;
            } else {
                mousePressed_X = mouseReleased_X;
                caretStartPos_X = mouseReleased_X;
                mousePressed_Y = mouseReleased_Y;
            }
        }
    } else {
        mousePressed_X = mouseReleased_X;
        mousePressed_Y = mouseReleased_Y;
        mousePressed_Y += ydelta;
        if (mousePressed_Y < 0) {
            mousePressed_Y = 0;
        }
        if (mousePressed_Y > (labelContent.getLineCount() - 1)) {
            mousePressed_Y = labelContent.getLineCount() - 1;
        }
        mouseReleased_Y = mousePressed_Y;
        mousePressed_X += xdelta;
        if (mousePressed_X < 0) {
            mousePressed_X = 0;
        }
        if (mousePressed_X > (labelContent.getLineContent(mouseReleased_Y).getTextLayout().getCharacterCount() - 1)) {
            mousePressed_X = labelContent.getLineContent(mouseReleased_Y).getTextLayout().getCharacterCount();
        }
        caretEndPos_X = mousePressed_X;
        mouseReleased_X = mousePressed_X;
        caretStartPos_X = caretEndPos_X;
    }
    mouseReleased_X = correctMouseReleasedX(mouseReleased_X, mouseReleased_Y, mousePressed_Y);
    setCaret(caretStartPos_X, mousePressed_X, mousePressed_Y, caretEndPos_X, mouseReleased_X, mouseReleased_Y);
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)

Example 5 with ZyLabelContent

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

the class CCursorKeyBehavior method handleNotShiftAndCtrl.

protected void handleNotShiftAndCtrl(final int xdelta, final int ydelta) {
    final ZyLabelContent labelContent = getLabelContent();
    int caretStartPos_X = getCaretStartPosX();
    int mousePressed_X = getCaretMousePressedX();
    final int mousePressed_Y = getCaretMousePressedY();
    int caretEndPos_X = getCaretEndPosX();
    int mouseReleased_X = getCaretMouseReleasedX();
    final int mouseReleased_Y = getCaretMouseReleasedY();
    if (xdelta != 0) {
        final ZyLineContent lineContent = labelContent.getLineContent(mouseReleased_Y);
        final String s = lineContent.getText() + " ";
        if (xdelta > 0) {
            final boolean firstIsSpace = s.charAt(caretEndPos_X) == ' ';
            int endindex = 0;
            for (int i = caretEndPos_X; i < s.length(); ++i) {
                endindex = i;
                if (firstIsSpace) {
                    if (s.charAt(i) != ' ') {
                        break;
                    }
                } else {
                    if (s.charAt(i) == ' ') {
                        break;
                    }
                }
            }
            if ((lineContent.getText().endsWith("\n") || lineContent.getText().endsWith("\r")) && (lineContent.getText().length() == endindex)) {
                endindex -= 1;
            }
            caretStartPos_X = endindex;
            mousePressed_X = endindex;
            mouseReleased_X = endindex;
            caretEndPos_X = endindex;
        } else if (xdelta < 0) {
            if (caretEndPos_X == 0) {
                return;
            }
            final boolean firstIsSpace = s.charAt(caretEndPos_X - 1) == ' ';
            int startindex = caretEndPos_X - 1;
            for (int i = caretEndPos_X - 1; i >= 0; --i) {
                if (firstIsSpace) {
                    if (s.charAt(i) != ' ') {
                        break;
                    }
                } else {
                    if (s.charAt(i) == ' ') {
                        break;
                    }
                }
                startindex = i;
            }
            caretStartPos_X = startindex;
            mousePressed_X = startindex;
            mouseReleased_X = startindex;
            caretEndPos_X = startindex;
        }
        mouseReleased_X = correctMouseReleasedX(mouseReleased_X, mouseReleased_Y, mousePressed_Y);
        setCaret(caretStartPos_X, mousePressed_X, mousePressed_Y, caretEndPos_X, mouseReleased_X, mouseReleased_Y);
    } else if (ydelta != 0) {
        handleNotShiftAndNotCtrl(0, ydelta);
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Aggregations

ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)33 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)10 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)6 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)5 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)5 ZyEdgeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer)5 Edge (y.base.Edge)4 Node (y.base.Node)4 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)3 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)3 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)3 CDefaultLabelEventHandler (com.google.security.zynamics.zylib.gui.zygraph.CDefaultLabelEventHandler)3 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)2 CallGraphSettingsConfigItem (com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem)2 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)2 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)2 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)2