Search in sources :

Example 1 with NodeRealizer

use of y.view.NodeRealizer in project binnavi by google.

the class ZyGroupNodeRealizer method moveNodes.

private void moveNodes(final Graph2D graph, final NodeCursor nodes, final double dx, final double dy) {
    for (; nodes.ok(); nodes.next()) {
        final NodeRealizer nr = graph.getRealizer(nodes.node());
        if ((nr.getAutoBoundsFeature() != null) && nr.getAutoBoundsFeature().isAutoBoundsEnabled()) {
            continue;
        }
        // Only move the node, if it doesn't have the auto resize feature
        // (enabled).
        nr.moveBy(dx, dy);
    }
}
Also used : GroupNodeRealizer(y.view.hierarchy.GroupNodeRealizer) ShapeNodeRealizer(y.view.ShapeNodeRealizer) NodeRealizer(y.view.NodeRealizer)

Example 2 with NodeRealizer

use of y.view.NodeRealizer in project binnavi by google.

the class MoveFunctions method centerNode.

/**
   * Centers the graph on a single node.
   * 
   * Note that the node must be visible. Otherwise the centering operation has no effect.
   * 
   * @param node The node in question.
   */
public static <NodeType extends ZyGraphNode<?> & ISelectableNode & IViewableNode & IYNode & IRawNodeAccessible, EdgeType extends ZyGraphEdge<?, ?, ?>> void centerNode(final AbstractZyGraph<NodeType, ?> graph, final NodeType node) {
    Preconditions.checkNotNull(node, "Error: Node argument can't be null");
    final NodeRealizer realizer = graph.getGraph().getRealizer(node.getNode());
    if (realizer.isVisible()) {
        graph.getView().focusView(graph.getView().getZoom(), new Point2D.Double(realizer.getCenterX(), realizer.getCenterY()), graph.getSettings().getLayoutSettings().getAnimateLayout());
        graph.updateViews();
    }
}
Also used : Point2D(java.awt.geom.Point2D) NodeRealizer(y.view.NodeRealizer)

Example 3 with NodeRealizer

use of y.view.NodeRealizer in project binnavi by google.

the class ZoomFunctions method zoomToNode.

/**
   * Zooms to a single node.
   * 
   * @param node The node in question.
   */
public static <NodeType extends ZyGraphNode<?>> void zoomToNode(final AbstractZyGraph<NodeType, ?> graph, final NodeType node) {
    Preconditions.checkNotNull(node, "Error: Node argument can't be null");
    final NodeRealizer realizer = graph.getGraph().getRealizer(node.getNode());
    Preconditions.checkNotNull(realizer, "Error: Node does not belong to the graph");
    if (!node.isVisible()) {
        graph.showNode(node, true);
    }
    final double oldZoom = graph.getView().getZoom();
    final Point2D oldViewPoint = graph.getView().getViewPoint2D();
    graph.getView().zoomToArea(realizer.getCenterX() - realizer.getWidth(), realizer.getCenterY() - realizer.getHeight(), realizer.getWidth() * 2, realizer.getHeight() * 2);
    ZoomHelpers.keepZoomValid(graph.getView());
    final double newZoom = graph.getView().getZoom();
    final Point2D newCenter = graph.getView().getCenter();
    graph.getView().setZoom(oldZoom);
    graph.getView().setViewPoint((int) oldViewPoint.getX(), (int) oldViewPoint.getY());
    graph.getView().focusView(newZoom, newCenter, graph.getSettings().getLayoutSettings().getAnimateLayout());
    graph.updateViews();
}
Also used : Point2D(java.awt.geom.Point2D) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) NodeRealizer(y.view.NodeRealizer)

Example 4 with NodeRealizer

use of y.view.NodeRealizer in project binnavi by google.

the class ZyGraphDefaultRenderer method bringNodeToFront.

public void bringNodeToFront(final Node node) {
    final Graph2D g = (Graph2D) node.getGraph();
    final NodeRealizer r = g.getRealizer(node);
    if (r.isSelected()) {
        // This does not work properly! Why? NH
        for (final NodeCursor nc = g.selectedNodes(); nc.ok(); nc.next()) {
            m_nodesInDrawingOrder.remove(nc.node());
            m_nodesInDrawingOrder.add(nc.node());
        }
    } else {
        // This seems to work correctly.
        m_nodesInDrawingOrder.remove(node);
        m_nodesInDrawingOrder.add(node);
    }
}
Also used : ZyGroupNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyGroupNodeRealizer) NodeRealizer(y.view.NodeRealizer) NodeCursor(y.base.NodeCursor) Graph2D(y.view.Graph2D)

Example 5 with NodeRealizer

use of y.view.NodeRealizer in project binnavi by google.

the class CEdgeClickHandler method zoomEdgeNode.

/**
   * Zooms to the source or target of an edge depending on what is farther away from the visible
   * part of the graph.
   * 
   * @param graph The graph the edge belongs to.
   * @param edge The edge that provides the potential zoom targets.
   */
private static void zoomEdgeNode(final AbstractZyGraph<?, ?> graph, final Edge edge, final double mouseX, final double mouseY) {
    assert edge != null;
    final AbstractZyGraphSettings settings = graph.getSettings();
    final boolean animate = settings.getLayoutSettings().getAnimateLayout();
    final EdgeRealizer realizer = graph.getGraph().getRealizer(edge);
    final NodeRealizer sourceRealizer = graph.getGraph().getRealizer(edge.source());
    final NodeRealizer targetRealizer = graph.getGraph().getRealizer(edge.target());
    final double srcPortX = realizer.getSourcePort().getX(sourceRealizer);
    final double srcPortY = realizer.getSourcePort().getY(sourceRealizer);
    final double tarPortX = realizer.getSourcePort().getX(targetRealizer);
    final double tarPortY = realizer.getSourcePort().getY(targetRealizer);
    final double srcLengthA = Math.abs(srcPortX - mouseX);
    final double srcHeightB = Math.abs(srcPortY - mouseY);
    final double tarLengthA = Math.abs(tarPortX - mouseX);
    final double tarHeightB = Math.abs(tarPortY - mouseY);
    final double srcLengthC = Math.sqrt(Math.pow(srcLengthA, 2) + Math.pow(srcHeightB, 2));
    final double tarLengthC = Math.sqrt(Math.pow(tarLengthA, 2) + Math.pow(tarHeightB, 2));
    if (srcLengthC > tarLengthC) {
        final Point2D.Double center = new Point2D.Double(sourceRealizer.getCenterX(), sourceRealizer.getCenterY());
        graph.getView().focusView(graph.getView().getZoom(), center, animate);
    } else {
        final Point2D.Double center = new Point2D.Double(targetRealizer.getCenterX(), targetRealizer.getCenterY());
        graph.getView().focusView(graph.getView().getZoom(), center, animate);
    }
}
Also used : AbstractZyGraphSettings(com.google.security.zynamics.zylib.gui.zygraph.AbstractZyGraphSettings) Point2D(java.awt.geom.Point2D) NodeRealizer(y.view.NodeRealizer) EdgeRealizer(y.view.EdgeRealizer)

Aggregations

NodeRealizer (y.view.NodeRealizer)5 Point2D (java.awt.geom.Point2D)3 AbstractZyGraphSettings (com.google.security.zynamics.zylib.gui.zygraph.AbstractZyGraphSettings)1 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)1 ZyGroupNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyGroupNodeRealizer)1 NodeCursor (y.base.NodeCursor)1 EdgeRealizer (y.view.EdgeRealizer)1 Graph2D (y.view.Graph2D)1 ShapeNodeRealizer (y.view.ShapeNodeRealizer)1 GroupNodeRealizer (y.view.hierarchy.GroupNodeRealizer)1