Search in sources :

Example 1 with Point

use of org.eclipse.elk.alg.layered.compaction.recthull.Point in project elk by eclipse.

the class ComponentsCompactor method componentHullPoints.

private Hullpoints componentHullPoints(final LGraph graph) {
    final Hullpoints pts = new Hullpoints();
    for (LNode n : graph.getLayerlessNodes()) {
        if (n.getType() == NodeType.EXTERNAL_PORT) {
            continue;
        }
        // Note that labels of nodes are already part of a node's margins
        // the same is true for ports and their labels
        addLGraphElementBounds(pts, n, new KVector());
        // add bend points of the edges
        for (LEdge edge : n.getOutgoingEdges()) {
            if (isExternalEdge(edge)) {
                continue;
            }
            for (KVector bp : edge.getBendPoints()) {
                KVector absolute = bp;
                pts.add(new Point(absolute.x, absolute.y));
            }
        }
    }
    return pts;
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LNode(org.eclipse.elk.alg.layered.graph.LNode) Point(org.eclipse.elk.alg.layered.compaction.recthull.Point) KVector(org.eclipse.elk.core.math.KVector)

Example 2 with Point

use of org.eclipse.elk.alg.layered.compaction.recthull.Point in project elk by eclipse.

the class ComponentsCompactor method addLGraphElementBounds.

private void addLGraphElementBounds(final List<Point> pts, final LShape element, final KVector offset) {
    // extract the relevant margins object.
    // there's LayoutOptions.MARGINS as well,
    // however, this is only used outside of elk layered.
    LMargin margins = null;
    if (element instanceof LNode) {
        margins = ((LNode) element).getMargin();
    } else if (element instanceof LPort) {
        margins = ((LPort) element).getMargin();
    } else if (element instanceof LLabel) {
        margins = new LMargin();
    }
    // add bounding box of the node
    pts.add(new Point(element.getPosition().x - margins.left + offset.x, element.getPosition().y - margins.top + offset.y));
    pts.add(new Point(element.getPosition().x - margins.left + offset.x, element.getPosition().y + element.getSize().y + margins.bottom + offset.y));
    pts.add(new Point(element.getPosition().x + element.getSize().x + margins.right + offset.x, element.getPosition().y - margins.top + offset.y));
    pts.add(new Point(element.getPosition().x + element.getSize().x + margins.right + offset.x, element.getPosition().y + element.getSize().y + margins.bottom + offset.y));
}
Also used : LMargin(org.eclipse.elk.alg.layered.graph.LMargin) LLabel(org.eclipse.elk.alg.layered.graph.LLabel) LPort(org.eclipse.elk.alg.layered.graph.LPort) LNode(org.eclipse.elk.alg.layered.graph.LNode) Point(org.eclipse.elk.alg.layered.compaction.recthull.Point)

Aggregations

Point (org.eclipse.elk.alg.layered.compaction.recthull.Point)2 LNode (org.eclipse.elk.alg.layered.graph.LNode)2 LEdge (org.eclipse.elk.alg.layered.graph.LEdge)1 LLabel (org.eclipse.elk.alg.layered.graph.LLabel)1 LMargin (org.eclipse.elk.alg.layered.graph.LMargin)1 LPort (org.eclipse.elk.alg.layered.graph.LPort)1 KVector (org.eclipse.elk.core.math.KVector)1