Search in sources :

Example 1 with ZyEdgeLabel

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

the class TooltipGenerator method createTooltip.

/**
   * Creates the tooltip for an edge in the graph.
   * 
   * @param <NodeType> Type of the nodes in the graph.
   * 
   * @param graph The graph the edge belongs to.
   * @param edge The edge the tooltip is created for.
   * 
   * @return The generated tooltip text for the edge.
   */
public static <NodeType extends ZyGraphNode<?>> String createTooltip(final AbstractZyGraph<NodeType, ?> graph, final Edge edge) {
    Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
    Preconditions.checkNotNull(edge, "Error: Edge argument can not be null");
    // The generated tooltip has the following form:
    //
    // 1. Content of the source node
    // 2. Content of the edge label
    // 3. Content of the target node
    String text = createTooltip(graph, edge.source()).replace("</html>", "");
    final ZyEdgeRealizer<?> realizer = (ZyEdgeRealizer<?>) graph.getGraph().getRealizer(edge);
    if (realizer.labelCount() > 0) {
        final ZyEdgeLabel edgeLabel = (ZyEdgeLabel) realizer.getLabel();
        final ZyLabelContent content = edgeLabel.getLabelContent();
        text += "<hr>" + HtmlGenerator.getHtml(content, GuiHelper.getMonospaceFont(), false).replace("<html>", "").replace("</html>", "");
    }
    text += "<hr>" + createTooltip(graph, edge.target()).replace("<html>", "");
    return text;
}
Also used : ZyEdgeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyEdgeLabel(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeLabel)

Aggregations

ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)1 ZyEdgeLabel (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeLabel)1 ZyEdgeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer)1