Search in sources :

Example 21 with ZyLineContent

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

the class ZyGraphNode method setBackgroundColor.

/**
   * Colorizes a complete line of the node in a given color.
   *
   * @param line The index of the line.
   * @param color The color of the line.
   */
public void setBackgroundColor(final int line, final Color color) {
    final ZyLineContent lineContent = m_realizer.getNodeContent().getLineContent(line);
    lineContent.setBackgroundColor(color);
    updateViews();
}
Also used : ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 22 with ZyLineContent

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

the class ProximityNodeCreator method createProximityNode.

/**
   * Creates a proximity browsing node.
   * 
   * @param graph The graph where the proximity node is added to.
   * @param attachedNode The graph node the proximity node is attached to.
   * @param degree The edge degree of the attached node (this is the number shown in the proximity
   *        node).
   * @param isIncoming True, to signal that the proximity node is incoming. False, if it is
   *        outcoming.
   * 
   * @param <NodeType> Raw node type of the real (e.g. not proximity nodes) nodes in the graph.
   * 
   * @return The created proximity node.
   */
public static <NodeType extends IViewNode<?>> ZyProximityNode<?> createProximityNode(final Graph2D graph, final ZyGraphNode<?> attachedNode, final int degree, final boolean isIncoming) {
    Preconditions.checkNotNull(graph, "Graph argument can not be null");
    Preconditions.checkNotNull(attachedNode, "Target node argument can not be null");
    final ZyLabelContent labelcontent = new ZyLabelContent(null);
    labelcontent.addLineContent(new ZyLineContent(String.valueOf(degree), new Font("New Courier", Font.PLAIN, 12), null));
    final ZyProximityNodeRealizer<NodeType> r = new ZyProximityNodeRealizer<NodeType>(labelcontent);
    final Node node = graph.createNode(r);
    @SuppressWarnings("unchecked") final ZyProximityNode<NodeType> infoNode = new ZyProximityNode<NodeType>(node, r, (ZyGraphNode<NodeType>) attachedNode, isIncoming);
    final ZyNodeData<ZyProximityNode<NodeType>> data = new ZyNodeData<ZyProximityNode<NodeType>>(infoNode);
    r.setUserData(data);
    return infoNode;
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyNodeData(com.google.security.zynamics.zylib.gui.zygraph.nodes.ZyNodeData) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) Node(y.base.Node) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) ZyProximityNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer) Font(java.awt.Font)

Example 23 with ZyLineContent

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

the class CElementSearcher method search.

/**
   * Performs a search on a label content.
   *
   * @param element The element to search through.
   * @param content The label content to search through.
   * @param searchString The string to search for.
   * @param regEx True, if regular expression search.
   * @param caseSensitive True, to signal case sensitive search.
   *
   * @return The start position for the next iteration or -1 if nothing was found.
   */
public static List<SearchResult> search(final Object element, final ZyLabelContent content, final String searchString, final boolean regEx, final boolean caseSensitive) {
    final ArrayList<SearchResult> results = new ArrayList<SearchResult>();
    if ("".equals(searchString)) {
        return results;
    }
    int lineCounter = 0;
    for (final ZyLineContent lineContent : content) {
        final String lineText = caseSensitive ? lineContent.getText() : lineContent.getText().toLowerCase();
        int startPosition = 0;
        do {
            startPosition = regEx ? CElementSearcher.doRegexSearch(element, lineText, lineCounter, searchString, startPosition, caseSensitive, results) : CElementSearcher.doTextSearch(element, lineText, lineCounter, searchString, startPosition, caseSensitive, results);
        } while (startPosition != -1);
        ++lineCounter;
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 24 with ZyLineContent

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

the class ZyCodeNodeBuilder method buildFunctionLine.

/**
   * Builds the function line of a code node. This line gives information about the function from
   * where the code node originally came from.
   * 
   * @param node The node that provides the raw data.
   * @param content The node content where the function line is added.
   * @param modifier Calculates the address strings. This argument can be null.
   */
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
    try {
        final INaviFunction parentFunction = node.getParentFunction();
        final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
        final String name = parentFunction.getName();
        content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
    } catch (final MaybeNullException exception) {
    // If there is no parent function, the parent function is not shown in the code node.
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 25 with ZyLineContent

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

the class GraphSearcherTest method testSimpleNoResult.

@Test
public void testSimpleNoResult() {
    final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
    final GraphSearcher searcher = new GraphSearcher();
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "mx");
    searcher.getCursor().next();
    assertNull(searcher.getCursor().current());
}
Also used : ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Aggregations

ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)56 IZyEditableObject (com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)24 Point (java.awt.Point)15 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)8 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)8 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)8 Test (org.junit.Test)8 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)5 CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)3 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 ArrayList (java.util.ArrayList)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 DefaultAddressConverter (com.google.security.zynamics.binnavi.debug.debugger.DefaultAddressConverter)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1