Package org.eclipse.draw2d.graph

Examples of org.eclipse.draw2d.graph.Node


        Map<Long, Node> mapping = new HashMap<Long, Node>();
        DirectedGraph graph = createDirectedGraph(mapping);
        DirectedGraphLayout layout = new DirectedGraphLayout();
        layout.visit(graph);
        for (Map.Entry<Long, Node> entry: mapping.entrySet()) {
            Node node = entry.getValue();
            DefaultElementWrapper elementWrapper = (DefaultElementWrapper)
                ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getElement(entry.getKey() + "");
            elementWrapper.setConstraint(new Rectangle(node.x, node.y, node.width, node.height));
        }
        // TODO: implement changes as a command, so we can support undo
View Full Code Here


   
    protected DirectedGraph createDirectedGraph(Map<Long, Node> mapping) {
        DirectedGraph graph = new DirectedGraph();
        WorkflowProcess process = (WorkflowProcess) ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getProcess();
        for (org.kie.definition.process.Node processNode: process.getNodes()) {
            Node node = new Node();
            Integer width = (Integer) processNode.getMetaData().get("width");
            Integer height = (Integer) processNode.getMetaData().get("height");
            if (width == null || width <= 0) {
                width = 80;
            }
            if (height == null || height <= 0) {
                height = 40;
            }
            node.setSize(new Dimension(width, height));
            graph.nodes.add(node);
            mapping.put(processNode.getId(), node);
        }
        for (org.kie.definition.process.Node processNode: process.getNodes()) {
            for (List<Connection> connections: processNode.getIncomingConnections().values()) {
                for (Connection connection: connections) {
                    Node source = mapping.get(connection.getFrom().getId());
                    Node target = mapping.get(connection.getTo().getId());
                    graph.edges.add(new Edge(source, target));
                }
            }
        }
        return graph;
View Full Code Here

        Map<Long, Node> mapping = new HashMap<Long, Node>();
        DirectedGraph graph = createDirectedGraph(mapping);
        DirectedGraphLayout layout = new DirectedGraphLayout();
        layout.visit(graph);
        for (Map.Entry<Long, Node> entry: mapping.entrySet()) {
            Node node = entry.getValue();
            DefaultElementWrapper elementWrapper = (DefaultElementWrapper)
                ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getElement(entry.getKey() + "");
            elementWrapper.setConstraint(new Rectangle(node.x, node.y, node.width, node.height));
        }
        // TODO: implement changes as a command, so we can support undo
View Full Code Here

    @SuppressWarnings("unchecked")
    protected DirectedGraph createDirectedGraph(Map<Long, Node> mapping) {
        DirectedGraph graph = new DirectedGraph();
        WorkflowProcess process = (WorkflowProcess) ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getProcess();
        for (org.kie.api.definition.process.Node processNode: process.getNodes()) {
            Node node = new Node();
            Integer width = (Integer) processNode.getMetaData().get("width");
            Integer height = (Integer) processNode.getMetaData().get("height");
            if (width == null || width <= 0) {
                width = 80;
            }
            if (height == null || height <= 0) {
                height = 40;
            }
            node.setSize(new Dimension(width, height));
            graph.nodes.add(node);
            mapping.put(processNode.getId(), node);
        }
        for (org.kie.api.definition.process.Node processNode: process.getNodes()) {
            for (List<Connection> connections: processNode.getIncomingConnections().values()) {
                for (Connection connection: connections) {
                    Node source = mapping.get(connection.getFrom().getId());
                    Node target = mapping.get(connection.getTo().getId());
                    graph.edges.add(new Edge(source, target));
                }
            }
        }
        return graph;
View Full Code Here

        }
    }

    @SuppressWarnings("unchecked")
    protected void addNodes(ElementEditPart elementEditPart) {
        Node n = new Node(elementEditPart);
        n.width = elementEditPart.getFigure().getPreferredSize(400, 300).width;
        n.height = elementEditPart.getFigure().getPreferredSize(400, 300).height;
        n.setPadding(new Insets(10, 8, 10, 12));
        partToNodesMap.put(elementEditPart, n);
        graph.nodes.add(n);
    }
View Full Code Here

        }
    }

    @SuppressWarnings("unchecked")
    protected void addEdges(ElementConnectionEditPart connectionPart) {
        Node source = (Node) partToNodesMap.get(connectionPart.getSource());
        Node target = (Node) partToNodesMap.get(connectionPart.getTarget());
        Edge e = new Edge(connectionPart, source, target);
        e.weight = 2;
        graph.edges.add(e);
        partToNodesMap.put(connectionPart, e);
    }
View Full Code Here

    protected void applyOwnResults(ProcessEditPart diagram) {
    }

    public void applyResults(ElementEditPart elementEditPart) {
        Node n = (Node) partToNodesMap.get(elementEditPart);
        ElementFigure elementFigure = (ElementFigure) elementEditPart.getFigure();
        Rectangle bounds = new Rectangle(n.x, n.y, elementFigure.getPreferredSize().width,
                elementFigure.getPreferredSize().height);
        elementFigure.setBounds(bounds);
        for (int i = 0; i < elementEditPart.getSourceConnections().size(); i++) {
View Full Code Here

        PolylineConnection conn = (PolylineConnection) connectionPart.getConnectionFigure();
        conn.setTargetDecoration(new PolygonDecoration());
        if (nodes != null) {
            List<Bendpoint> bends = new ArrayList<Bendpoint>();
            for (int i = 0; i < nodes.size(); i++) {
                Node vn = nodes.getNode(i);
                int x = vn.x;
                int y = vn.y;
                if (e.isFeedback()) {
                    bends.add(new AbsoluteBendpoint(x, y + vn.height));
                    bends.add(new AbsoluteBendpoint(x, y));
View Full Code Here

  protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight) {
    HashMap mapping = new HashMap(entitiesToLayout.length);
    DirectedGraph graph = new DirectedGraph();
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode internalNode = entitiesToLayout[i];
      Node node = new Node(internalNode);
      node.setSize(new Dimension(10, 10));
      mapping.put(internalNode, node);
      graph.nodes.add(node);
    }
    for (int i = 0; i < relationshipsToConsider.length; i++) {
      InternalRelationship relationship = relationshipsToConsider[i];
      Node source = (Node) mapping.get(relationship.getSource());
      Node dest = (Node) mapping.get(relationship.getDestination());
      Edge edge = new Edge(relationship, source, dest);
      graph.edges.add(edge);
    }
    DirectedGraphLayout directedGraphLayout = new ExtendedDirectedGraphLayout();
    directedGraphLayout.visit(graph);

    for (Iterator iterator = graph.nodes.iterator(); iterator.hasNext();) {
      Node node = (Node) iterator.next();
      InternalNode internalNode = (InternalNode) node.data;
      internalNode.setInternalLocation(node.x, node.y);
    }
    updateLayoutLocations(entitiesToLayout);
  }
View Full Code Here

        Map<Long, Node> mapping = new HashMap<Long, Node>();
        DirectedGraph graph = createDirectedGraph(mapping);
        DirectedGraphLayout layout = new DirectedGraphLayout();
        layout.visit(graph);
        for (Map.Entry<Long, Node> entry: mapping.entrySet()) {
            Node node = entry.getValue();
            DefaultElementWrapper elementWrapper = (DefaultElementWrapper)
                ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getElement(entry.getKey() + "");
            elementWrapper.setConstraint(new Rectangle(node.x, node.y, node.width, node.height));
        }
        // TODO: implement changes as a command, so we can support undo
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.graph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.