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;
}
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;
}
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();
}
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);
}
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;
}
Aggregations