Search in sources :

Example 21 with ZyLabelContent

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

the class ZyCodeNodeBuilder method buildContent.

/**
   * Builds the visible content of a code node.
   * 
   * @param node The code node that provides the raw data.
   * @param graphSettings Provides settings that influence node formatting.
   * @param modifier Calculates the address strings. This argument can be null.
   * 
   * @return The content that was built from the information from the raw node.
   */
public static ZyLabelContent buildContent(final INaviCodeNode node, final ZyGraphViewSettings graphSettings, final INodeModifier modifier) {
    Preconditions.checkNotNull(node, "IE00897: Node argument can not be null");
    final ZyLabelContent content = new ZyLabelContent(new IZyEditableObject() {

        @Override
        public int getEnd() {
            throw new IllegalStateException();
        }

        @Override
        public int getLength() {
            throw new IllegalStateException();
        }

        @Override
        public Object getPersistentModel() {
            throw new IllegalStateException();
        }

        @Override
        public int getStart() {
            throw new IllegalStateException();
        }

        @Override
        public boolean isCommentDelimiter() {
            throw new IllegalStateException();
        }

        @Override
        public boolean isPlaceholder() {
            throw new IllegalStateException();
        }

        @Override
        public boolean update(final String newContent) {
            throw new IllegalStateException();
        }

        @Override
        public boolean updateComment(final String newContent, final ECommentPlacement placement) {
            throw new IllegalStateException();
        }
    }, true, false);
    buildContent(content, node, graphSettings, modifier);
    return content;
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ECommentPlacement(com.google.security.zynamics.zylib.gui.zygraph.realizers.ECommentPlacement)

Example 22 with ZyLabelContent

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

the class CNodeHoverer method nodeHovered.

/**
   * Updates the node hoverer.
   *
   * @param node Node over which the mouse hovered.
   * @param y Current y-coordinate of the mouse.
   */
public void nodeHovered(final NaviNode node, final double y) {
    // group nodes do not have any mouse to line matchings.
    if (node.getRawNode() instanceof CGroupNode) {
        return;
    }
    final double yPos = y - node.getY();
    final IZyNodeRealizer realizer = node.getRealizer();
    final int row = node.positionToRow(yPos);
    if (row == -1) {
        if (m_lastHoveredLine != null) {
            m_lastHoveredLine.clearHighlighting(1);
            m_lastHoveredLine = null;
        }
        return;
    }
    final ZyLabelContent content = realizer.getNodeContent();
    final ZyLineContent hoveredLine = content.getLineContent(row);
    if (hoveredLine.equals(m_lastHoveredLine)) {
        return;
    }
    setHoveredLine(content, hoveredLine, realizer.isSelected() ? realizer.getFillColor().darker().darker() : realizer.getFillColor().darker());
    if (m_lastHoveredLine != null) {
        m_lastHoveredLine.clearHighlighting(1);
    }
    m_lastHoveredLine = hoveredLine;
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode)

Example 23 with ZyLabelContent

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

the class TooltipGenerator method createTooltip.

/**
   * Creates the tooltip for a node in a graph.
   * 
   * @param <NodeType> Type of the nodes in the graph.
   * 
   * @param graph The graph the node belongs to.
   * @param node The node the tooltip is created for.
   * 
   * @return The created tooltip text.
   */
public static <NodeType extends ZyGraphNode<?>> String createTooltip(final AbstractZyGraph<NodeType, ?> graph, final Node node) {
    Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
    Preconditions.checkNotNull(node, "Error: Node argument can not be null");
    final IZyNodeRealizer realizer = (IZyNodeRealizer) graph.getGraph().getRealizer(node);
    if (realizer instanceof ZyProximityNodeRealizer<?>) {
        return generateProximityNodeRealizer(graph, (ZyProximityNode<?>) realizer.getUserData().getNode());
    } else {
        final ZyLabelContent content = realizer.getNodeContent();
        final boolean boldFirstLine = requiresBoldFirstLine(graph.getNode(node));
        return HtmlGenerator.getHtml(content, GuiHelper.getMonospaceFont(), boldFirstLine);
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) ZyProximityNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer)

Example 24 with ZyLabelContent

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

the class TooltipGenerator method generateProximityNodeRealizer.

private static <NodeType extends ZyGraphNode<?>> String generateProximityNodeRealizer(final AbstractZyGraph<NodeType, ?> graph, final ZyProximityNode<?> node) {
    final Set<String> strings = new LinkedHashSet<String>();
    final List<? extends Object> nodes = node.isIncoming() ? ((IGraphNode<?>) node.getRawNode().getAttachedNode()).getChildren() : ((IGraphNode<?>) node.getRawNode().getAttachedNode()).getParents();
    boolean cutoff = false;
    int counter = 0;
    final int invisibleNodesCount = CollectionHelpers.countIf(nodes, new ICollectionFilter<Object>() {

        @Override
        public boolean qualifies(final Object item) {
            return !((IViewNode<?>) item).isVisible();
        }
    });
    for (final Object child : nodes) {
        final IViewNode<?> childNode = (IViewNode<?>) child;
        if (childNode.isVisible()) {
            continue;
        }
        final IZyNodeRealizer realizer = (IZyNodeRealizer) graph.getGraph().getRealizer(graph.getYNode(child));
        final ZyLabelContent content = realizer.getNodeContent();
        if (child instanceof IFunctionNode<?, ?>) {
            final IFunctionNode<?, ?> fnode = (IFunctionNode<?, ?>) child;
            strings.add("F: " + fnode.getFunction().getName());
        } else if (child instanceof ICodeNode<?, ?, ?>) {
            final ICodeNode<?, ?, ?> cnode = (ICodeNode<?, ?, ?>) child;
            strings.add("B: " + cnode.getAddress().toHexString());
        } else {
            if (content.getLineCount() > 0) {
                strings.add(content.getLineContent(0).getText());
            }
        }
        ++counter;
        if (strings.size() == 25) {
            cutoff = counter != invisibleNodesCount;
            break;
        }
    }
    if (cutoff) {
        strings.add("...");
    }
    return HtmlGenerator.getHtml(strings, GuiHelper.getMonospaceFont(), false);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ICodeNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode) IFunctionNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IFunctionNode) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)

Example 25 with ZyLabelContent

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

the class ZyNodeRealizer method regenerate.

/**
   * Regenerates the content of the realizer.
   */
@Override
public void regenerate() {
    final ZyLabelContent content = getNodeContent();
    final double widthOld = content.getBounds().getWidth();
    final double heightOld = content.getBounds().getHeight();
    if (m_updater != null) {
        m_updater.generateContent(this, content);
    }
    final Rectangle2D bounds = content.getBounds();
    setSize(bounds.getWidth(), bounds.getHeight());
    scalePortCoordinates(getNode(), widthOld, bounds.getWidth(), heightOld, bounds.getHeight());
    notifyHasRegenerated();
    // TODO(jannewger): check if this method is redundant - it seems that client code often calls
    // regeneerate followe by a redraw operation. That would mean that we needlessly redraw two
    // times.
    repaint();
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) Rectangle2D(java.awt.geom.Rectangle2D)

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