Search in sources :

Example 1 with EdgeRealizer

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

the class ZyNodeRealizer method scalePortCoordinates.

protected void scalePortCoordinates(final Node node, final double wOld, final double wNew, final double hOld, final double hNew) {
    final Graph2D graph = (Graph2D) node.getGraph();
    final double wScaling = wOld > 0 ? wNew / wOld : 1.0d;
    final double hScaling = hOld > 0 ? hNew / hOld : 1.0d;
    for (Edge e = node.firstOutEdge(); e != null; e = e.nextOutEdge()) {
        final EdgeRealizer er = graph.getRealizer(e);
        final Port port = er.getSourcePort();
        final double px = port.getOffsetX() * wScaling;
        final double py = port.getOffsetY() * hScaling;
        port.setOffsets(px, py);
        graph.setSourcePointRel(e, new YPoint(px, py));
    }
    for (Edge e = node.firstInEdge(); e != null; e = e.nextInEdge()) {
        final EdgeRealizer er = graph.getRealizer(e);
        final Port port = er.getTargetPort();
        final double px = port.getOffsetX() * wScaling;
        final double py = port.getOffsetY() * hScaling;
        port.setOffsets(px, py);
        graph.setTargetPointRel(e, new YPoint(px, py));
    }
}
Also used : Port(y.view.Port) EdgeRealizer(y.view.EdgeRealizer) Edge(y.base.Edge) YPoint(y.geom.YPoint) Graph2D(y.view.Graph2D)

Example 2 with EdgeRealizer

use of y.view.EdgeRealizer 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)

Example 3 with EdgeRealizer

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

the class CEdgeHighlighter method highlightEdgesOfNode.

/**
   * Highlights all edges of a node.
   * 
   * @param node The node whose edges are highlighted.
   * @param highlight True to add highlighting to the edges. False to remove it.
   */
public static void highlightEdgesOfNode(final Node node, final boolean highlight) {
    final EdgeCursor edges = node.edges();
    int edgeCount = node.degree();
    for (Edge edge = edges.edge(); edgeCount > 0; edgeCount--) {
        final EdgeRealizer edgeRealizer = ((Graph2D) node.getGraph()).getRealizer(edge);
        highlightEdge(edgeRealizer, highlight);
        edges.cyclicNext();
        edge = edges.edge();
    }
}
Also used : EdgeCursor(y.base.EdgeCursor) EdgeRealizer(y.view.EdgeRealizer) Edge(y.base.Edge) Graph2D(y.view.Graph2D)

Aggregations

EdgeRealizer (y.view.EdgeRealizer)3 Edge (y.base.Edge)2 Graph2D (y.view.Graph2D)2 AbstractZyGraphSettings (com.google.security.zynamics.zylib.gui.zygraph.AbstractZyGraphSettings)1 Point2D (java.awt.geom.Point2D)1 EdgeCursor (y.base.EdgeCursor)1 YPoint (y.geom.YPoint)1 NodeRealizer (y.view.NodeRealizer)1 Port (y.view.Port)1