Package org.eclipse.draw2d.graph

Examples of org.eclipse.draw2d.graph.Node


   
    protected DirectedGraph createDirectedGraph(Map<Long, Node> mapping) {
        DirectedGraph graph = new DirectedGraph();
        WorkflowProcess process = (WorkflowProcess) ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getProcess();
        for (org.drools.definition.process.Node processNode: process.getNodes()) {
            Node node = new Node();
            Integer width = (Integer) processNode.getMetaData("width");
            Integer height = (Integer) processNode.getMetaData("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.drools.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


   * @param parent
   *            Its parent subgraph.
   */
  @SuppressWarnings("unchecked")
  void addNodes(NodeList nodes, Subgraph parent) {
    node = new Node(this, parent);
    nodes.add(node);

    // Graphical stuff
    Figure figure = (Figure) getFigure();
    node.setSize(figure.getPreferredSize());
View Full Code Here

  private Diagram mapGraphCoordinatesToDiagram(CompoundDirectedGraph graph) {
    NodeList myNodes = new NodeList();
    myNodes.addAll(graph.nodes);
    myNodes.addAll(graph.subgraphs);
    for (Object object : myNodes) {
      Node node = (Node) object;
      Shape shape = (Shape) node.data;
      shape.getGraphicsAlgorithm().setX(node.x);
      shape.getGraphicsAlgorithm().setY(node.y);
      /**
       * We can also set the size of the elements, but I'd rather they
View Full Code Here

    CompoundDirectedGraph dg = new CompoundDirectedGraph();
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    EList<Shape> children = d.getChildren();
    for (Shape shape : children) {
      Node node = new Node();
      GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
      node.x = ga.getX();
      node.y = ga.getY();
      node.width = ga.getWidth();
      node.height = ga.getHeight();
      node.data = shape;
      shapeToNode.put(shape, node);
      nodeList.add(node);
    }
    EList<Connection> connections = d.getConnections();
    for (Connection connection : connections) {
     
      //Be wary about broken connections
      AnchorContainer source = null;
      if (connection.getStart() != null) {
        source = connection.getStart().getParent();
      }
     
      AnchorContainer target = null;
      if (connection.getEnd() != null) {
        target = connection.getEnd().getParent();
      }
     
      if (target == null || source == null) {
        break;
      }
     
      Node srcNode = shapeToNode.get(source);
      if (srcNode == null) {
        srcNode = shapeToNode.get(source.eContainer());
      }
     
      Node tgtNode = shapeToNode.get(target);
      if (tgtNode == null) {
        tgtNode = shapeToNode.get(target.eContainer());
      }
      Edge edge = new Edge(srcNode, tgtNode);
      edge.data = connection;
View Full Code Here

            addNodes(elementEditPart);
        }
    }

    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

            addEdges(connectionPart);
        }
    }

    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 bends = new ArrayList();
            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

        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.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

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.