Search in sources :

Example 11 with AbsoluteBendpoint

use of org.eclipse.draw2d.AbsoluteBendpoint in project whole by wholeplatform.

the class GraphLayoutStrategy method applyLayout.

public void applyLayout(DirectedGraph graph) {
    NodeList nodes = graph.nodes;
    for (int i = 0; i < nodes.size(); i++) {
        Node node = (Node) nodes.get(i);
        GraphicalEditPart part = (GraphicalEditPart) node.data;
        part.getFigure().setBounds(new Rectangle(node.x, node.y, node.width, node.height));
    }
    EdgeList edges = graph.edges;
    for (int i = 0; i < edges.size(); i++) {
        Edge edge = (Edge) edges.get(i);
        ConnectionEditPart connectionPart = (ConnectionEditPart) edge.data;
        nodes = edge.vNodes;
        PolylineConnection conn = (PolylineConnection) connectionPart.getFigure();
        if (nodes != null) {
            List<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
            for (int j = 0; j < nodes.size(); j++) {
                Node vn = nodes.getNode(j);
                if (edge.isFeedback) {
                    bends.add(new AbsoluteBendpoint(vn.x, vn.y + vn.height));
                    bends.add(new AbsoluteBendpoint(vn.x, vn.y));
                } else {
                    bends.add(new AbsoluteBendpoint(vn.x, vn.y));
                    bends.add(new AbsoluteBendpoint(vn.x, vn.y + vn.height));
                }
            }
            conn.setRoutingConstraint(bends);
        } else
            conn.setRoutingConstraint(Collections.EMPTY_LIST);
    }
}
Also used : AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) NodeList(org.eclipse.draw2d.graph.NodeList) Node(org.eclipse.draw2d.graph.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EdgeList(org.eclipse.draw2d.graph.EdgeList) Edge(org.eclipse.draw2d.graph.Edge) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Aggregations

AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)11 Point (org.eclipse.draw2d.geometry.Point)7 Bendpoint (org.eclipse.draw2d.Bendpoint)6 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 ArrayList (java.util.ArrayList)4 RelativeBendpoint (org.eclipse.draw2d.RelativeBendpoint)4 DBException (org.jkiss.dbeaver.DBException)4 XMLBuilder (org.jkiss.utils.xml.XMLBuilder)4 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)3 StringWriter (java.io.StringWriter)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 Edge (org.eclipse.draw2d.graph.Edge)2 Node (org.eclipse.draw2d.graph.Node)2 NodeList (org.eclipse.draw2d.graph.NodeList)2 List (java.util.List)1 PointList (org.eclipse.draw2d.geometry.PointList)1 EdgeList (org.eclipse.draw2d.graph.EdgeList)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 AssociationPart (org.jkiss.dbeaver.ext.erd.part.AssociationPart)1