Search in sources :

Example 1 with EdgeList

use of org.eclipse.draw2d.graph.EdgeList 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)

Example 2 with EdgeList

use of org.eclipse.draw2d.graph.EdgeList in project jbosstools-hibernate by jbosstools.

the class ClusterEdgeCreator method recursivelyAddToCluster.

private void recursivelyAddToCluster(Node node, int depth) {
    if (depth > 3)
        return;
    else {
        depth++;
        EdgeList incoming = node.incoming;
        for (Iterator<?> iter = incoming.iterator(); iter.hasNext(); ) {
            Edge edge = (Edge) iter.next();
            Node incomingNode = edge.source;
            if (!encountered.contains(incomingNode)) {
                encountered.add(incomingNode);
                currentCluster.set.add(incomingNode);
                // System.out.println("Adding to current cluster: " + incomingNode + ", cluster: " + currentCluster);
                recursivelyAddToCluster(incomingNode, depth);
            } else {
            // System.out.println("Already encountered: " + incomingNode);
            }
        }
        EdgeList outgoing = node.outgoing;
        for (Iterator<?> iter = outgoing.iterator(); iter.hasNext(); ) {
            Edge edge = (Edge) iter.next();
            Node outgoingNode = edge.target;
            if (!encountered.contains(outgoingNode)) {
                encountered.add(outgoingNode);
                currentCluster.set.add(outgoingNode);
                // System.out.println("Adding to current cluster: " + outgoingNode + ", cluster: " + currentCluster);
                recursivelyAddToCluster(outgoingNode, depth);
            } else {
            // System.out.println("Already encountered: " + outgoingNode);
            }
        }
    }
}
Also used : Node(org.eclipse.draw2d.graph.Node) EdgeList(org.eclipse.draw2d.graph.EdgeList) Edge(org.eclipse.draw2d.graph.Edge)

Aggregations

Edge (org.eclipse.draw2d.graph.Edge)2 EdgeList (org.eclipse.draw2d.graph.EdgeList)2 Node (org.eclipse.draw2d.graph.Node)2 ArrayList (java.util.ArrayList)1 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 NodeList (org.eclipse.draw2d.graph.NodeList)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1