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