Search in sources :

Example 1 with IViewNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode 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 IViewNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode in project binnavi by google.

the class ProximityRangeCalculator method getParentGroups.

private static <NodeType extends ZyGraphNode<? extends IViewNode<?>>> Set<ViewNodeAdapter> getParentGroups(final NodeType node) {
    final Set<ViewNodeAdapter> parentGroups = new HashSet<ViewNodeAdapter>();
    IGroupNode<?, ?> parentGroup = ((IViewNode<?>) node.getRawNode()).getParentGroup();
    while (parentGroup != null) {
        parentGroups.add(new ViewNodeAdapter(parentGroup));
        parentGroup = parentGroup.getParentGroup();
    }
    return parentGroups;
}
Also used : IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) ViewNodeAdapter(com.google.security.zynamics.zylib.gui.zygraph.wrappers.ViewNodeAdapter) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with IViewNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode in project binnavi by google.

the class AbstractZyGraph method showNodes.

public void showNodes(final Collection<NodeType> toShow, final Collection<NodeType> toHide, final boolean addNeighbours) {
    if (addNeighbours) {
        final IProximitySettings proxiSettings = getSettings().getProximitySettings();
        final Set<NodeType> neighbors = ProximityRangeCalculator.getNeighbors(this, toShow, proxiSettings.getProximityBrowsingChildren(), proxiSettings.getProximityBrowsingParents());
        toHide.removeAll(neighbors);
    }
    for (final NodeType node : sortLayers(toHide)) {
        Preconditions.checkNotNull(node, "Error: The list of nodes to hide contained an invalid node");
        ((IViewNode<?>) node.getRawNode()).setVisible(false);
    }
    if (addNeighbours) {
        showNeighbors(toShow);
    } else {
        for (final NodeType node : toShow) {
            Preconditions.checkNotNull(node, "The list of nodes to show contained an invalid node");
            ((IViewNode<?>) node.getRawNode()).setVisible(true);
        }
    }
    notifyVisibilityListeners();
}
Also used : IProximitySettings(com.google.security.zynamics.zylib.gui.zygraph.settings.IProximitySettings) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)

Example 4 with IViewNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode 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 5 with IViewNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode in project binnavi by google.

the class ZyDefaultProximityBrowser method deleteProximityBrowsingNodes.

/**
   * Removes all proximity browsing nodes from the graph.
   */
protected void deleteProximityBrowsingNodes() {
    // each node deletion triggers the selection state listener
    // which updates proximity browsing automatically
    // this is suppressed here by setting m_isActive temporarily to false
    m_internallyDisabled = true;
    for (final Node node : m_proximityMap.keySet()) {
        m_graph.getGraph().removeNode(node);
    }
    m_proximityMap.clear();
    for (final Entry<ZyProximityNode<?>, InternalNodeListener> entry : m_nodeListeners.entrySet()) {
        ((IViewNode<?>) entry.getKey().getRawNode().getAttachedNode()).removeListener(entry.getValue());
    }
    m_nodeListeners.clear();
    m_internallyDisabled = false;
}
Also used : IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) IViewNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node)

Aggregations

IViewNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IViewNode)6 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)2 IProximitySettings (com.google.security.zynamics.zylib.gui.zygraph.settings.IProximitySettings)2 ZyGraphNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode)2 LinkedHashSet (java.util.LinkedHashSet)2 Node (y.base.Node)2 ICodeNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode)1 IFunctionNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IFunctionNode)1 IGroupNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode)1 ZyNodeData (com.google.security.zynamics.zylib.gui.zygraph.nodes.ZyNodeData)1 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)1 ViewNodeAdapter (com.google.security.zynamics.zylib.gui.zygraph.wrappers.ViewNodeAdapter)1 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)1 ZyProximityNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyProximityNodeRealizer)1 Font (java.awt.Font)1 HashSet (java.util.HashSet)1