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 content of a node to the clip board.
*
* @param node The node to copy to the clip board.
*/
public static void copyToClipboard(final ZyGraphNode<?> node) {
Preconditions.checkNotNull(node, "Error: Node argument can not be null");
final IZyNodeRealizer realizer = node.getRealizer();
final ZyLabelContent content = realizer.getNodeContent();
if (content.isSelectable()) {
final ZyLabelContent zyContent = content;
final StringBuilder textBuilder = new StringBuilder();
for (final ZyLineContent zyLineContent : zyContent) {
textBuilder.append(zyLineContent.getText());
//$NON-NLS-1$
textBuilder.append("\n");
}
ClipboardHelpers.copyToClipboard(textBuilder.toString());
}
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class CEditNodeHelper method select.
public static void select(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.handleMouseDraggedEvent(nodeX, nodeY, mouseX, mouseY, zoom);
}
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class CEditNodeHelper method setCaretStart.
public static void setCaretStart(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();
graph.getEditMode().getLabelEventHandler().activateLabelContent(labelContent, new ZyRegenerateableNodeRealizer(realizer));
if (labelContent.isSelectable()) {
final double zoom = graph.getView().getZoom();
final double nodeX = realizer.getRealizer().getX();
final double nodeY = realizer.getRealizer().getY();
labelEventHandler.handleMousePressedEvent(nodeX, nodeY, mouseX, mouseY, zoom);
}
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class ZoomFunctions method zoomToNode.
public static <NodeType extends ZyGraphNode<?>> void zoomToNode(final AbstractZyGraph<NodeType, ?> graph, final NodeType node, final int line, final boolean animate) {
Preconditions.checkNotNull(node, "Error: Node argument can't be null");
final IZyNodeRealizer realizer = node.getRealizer();
Preconditions.checkNotNull(realizer, "Error: Node does not belong to the graph");
final double offset = realizer.getNodeContent().getLineHeight() * line;
final Point2D oldViewPoint = graph.getView().getViewPoint2D();
graph.getView().setCenter(realizer.getCenterX(), (realizer.getCenterY() - (realizer.getHeight() / 2)) + offset);
if (animate) {
final Point2D newCenter = graph.getView().getCenter();
graph.getView().setViewPoint((int) oldViewPoint.getX(), (int) oldViewPoint.getY());
graph.getView().focusView(graph.getView().getZoom(), newCenter, graph.getSettings().getLayoutSettings().getAnimateLayout());
}
graph.updateViews();
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer in project binnavi by google.
the class CNaviNodeFactory method get.
public static NaviNode get() {
final Graph2D graph = new Graph2D();
final CTextNode node = CTextNodeFactory.get();
final ZyLabelContent content = ZyTextNodeBuilder.buildContent(node);
final IZyNodeRealizer realizer = new ZyNormalNodeRealizer<NaviNode>(content);
return new NaviNode(graph.createNode(), realizer, node);
}
Aggregations