use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class ZyNodeContentHelpers method getObjectWrapper.
public static ZyLineContent.ObjectWrapper getObjectWrapper(final ZyGraphNode<?> node, final double x, final double y) {
final IZyNodeRealizer realizer = node.getRealizer();
final ZyLabelContent content = realizer.getNodeContent();
final Rectangle2D bounds = content.getBounds();
final double xScale = realizer.getWidth() / bounds.getWidth();
final double yPos = y - node.getY();
final int row = node.positionToRow(yPos);
if (row == -1) {
return null;
}
final ZyLineContent lineContent = content.getLineContent(row);
final double position = (((x - node.getX()) / xScale) - content.getPaddingLeft()) / lineContent.getCharWidth();
return lineContent.getObjectWrapper((int) position);
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class ZyGraphNodeBuilder method convertNode.
/**
* Creates a graph node from a raw node.
*
* @param node The raw node that provides the underlying data.
* @param graph2D The graph object where the node is created.
* @param graphSettings Graph settings used to build the graph.
*
* @return The created YNode/NaviNode pair.
*/
public static Pair<Node, NaviNode> convertNode(final INaviViewNode node, final Graph2D graph2D, final ZyGraphViewSettings graphSettings) {
Preconditions.checkNotNull(node, "IE00909: Node argument can not be null");
Preconditions.checkNotNull(graph2D, "IE00910: Graph2D argument can not be null");
// Create the node in the Graph2D
final Node yNode = createNode(graph2D, node);
final ZyLabelContent content = ZyGraphNodeBuilder.buildContent(node, graphSettings, null);
final IZyNodeRealizer realizer = createRealizer(node, content);
// Associate the user data with the Graph2D node
final NaviNode zyNode = new NaviNode(yNode, realizer, node);
realizer.setUserData(new ZyNodeData<NaviNode>(zyNode));
realizer.updateContentSelectionColor();
graph2D.setRealizer(yNode, realizer.getRealizer());
return new Pair<Node, NaviNode>(yNode, zyNode);
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class ClipboardCopier method copyToClipboard.
/**
* Copies the text of a line of a node to the clip board.
*
* @param node The node that contains the line.
* @param line Index of the line to copy to the clip board.
*/
public static void copyToClipboard(final ZyGraphNode<?> node, final int line) {
Preconditions.checkNotNull(node, "Error: Node argument can not be null");
final IZyNodeRealizer realizer = node.getRealizer();
final ZyLabelContent content = realizer.getNodeContent();
Preconditions.checkArgument((line >= 0) && (line < content.getLineCount()), "Error: Line argument is out of bounds");
if (content.isSelectable()) {
final ZyLabelContent zyContent = content;
ClipboardHelpers.copyToClipboard(zyContent.getLineContent(line).getText());
}
}
Aggregations