Search in sources :

Example 1 with Port

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

Aggregations

Edge (y.base.Edge)1 YPoint (y.geom.YPoint)1 EdgeRealizer (y.view.EdgeRealizer)1 Graph2D (y.view.Graph2D)1 Port (y.view.Port)1