Search in sources :

Example 1 with ZyProximityNodeRealizer

use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer 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 2 with ZyProximityNodeRealizer

use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer 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)

Aggregations

ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)2 ZyProximityNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer)2 IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)1 ZyNodeData (com.google.security.zynamics.zylib.gui.zygraph.nodes.ZyNodeData)1 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)1 ZyGraphNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode)1 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)1 Font (java.awt.Font)1 Node (y.base.Node)1