use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class CEditNodeHelper method setCaretEnd.
public static void setCaretEnd(final AbstractZyGraph<?, ?> graph, final Node node, final MouseEvent event) {
final double mouseX = graph.getEditMode().translateX(event.getX());
final double mouseY = graph.getEditMode().translateY(event.getY());
final IZyNodeRealizer realizer = (IZyNodeRealizer) graph.getGraph().getRealizer(node);
final ZyLabelContent labelContent = realizer.getNodeContent();
final CDefaultLabelEventHandler labelEventHandler = graph.getEditMode().getLabelEventHandler();
if (labelContent.isSelectable()) {
final double zoom = graph.getView().getZoom();
final double nodeX = realizer.getRealizer().getX();
final double nodeY = realizer.getRealizer().getY();
labelEventHandler.handleMouseReleasedEvent(nodeX, nodeY, mouseX, mouseY, zoom, event.getClickCount());
}
}
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());
}
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class CNodeHoverer method clear.
/**
* Clears all node hovering highlighting for a given node.
*
* @param node The node to clear.
*
* @return True, if there was highlighting to be cleared. False, otherwise.
*/
public boolean clear(final NaviNode node) {
final IZyNodeRealizer realizer = node.getRealizer();
boolean update = false;
for (final ZyLineContent line : realizer.getNodeContent()) {
update |= line.clearHighlighting(1);
}
m_lastHoveredLine = null;
return update;
}
Aggregations