Package org.eclipse.draw2d.graph

Examples of org.eclipse.draw2d.graph.EdgeList


   */
  private CompoundDirectedGraph mapDiagramToGraph() {
    Map<AnchorContainer, Node> shapeToNode = new HashMap<AnchorContainer, Node>();
    Diagram d = getDiagram();
    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;
      edgeList.add(edge);
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
  }
View Full Code Here


  {
    DiagramModel diagramModel = diagramEditor.getDiagramModel();
    Map<DiagramNodeModel, Node> shapeToNode = new HashMap<DiagramNodeModel, Node>();
    DirectedGraph dg = new DirectedGraph();
    dg.setDirection(getGraphDirection());
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    List<DiagramNodeModel> children = diagramModel.getNodes();
    for (DiagramNodeModel child : children)
    {
      Node node = new Node();
      Rectangle bounds = child.getShapePresentation().getFigure().getBounds();//child.getNodeBounds();
      node.x = bounds.x;
      node.y = bounds.y;
      node.width = bounds.width;
      node.height = bounds.height;
      node.data = child;
      shapeToNode.put(child, node);
      nodeList.add(node);
    }
    List<DiagramConnectionModel> connections = diagramModel.getConnections();
    for (DiagramConnectionModel connection : connections)
    {
      DiagramNodeModel sourceNode = connection.getSourceNode();
      DiagramNodeModel targetNode = connection.getTargetNode();
      if (sourceNode != targetNode)
      {
        Edge edge = new Edge(connection, shapeToNode.get(sourceNode), shapeToNode.get(targetNode));
        edge.weight = 2;
        edge.data = connection;
        edgeList.add(edge);
      }
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
View Full Code Here

  @SuppressWarnings("unchecked")
  private void mapGraphEdgeCoordinatesToDiagram(DirectedGraph graph,
      final SapphireDiagramEditor diagramEditor, final boolean autoLayout)
  {
    // add bend points generated by the graph layout
    EdgeList myEdges = new EdgeList();
    myEdges.addAll(graph.edges);
    DiagramConfigurationManager configManager = diagramEditor.getConfigurationManager();
   
    for (Object object : myEdges)
    {
      Edge edge = (Edge)object;
View Full Code Here

  private CompoundDirectedGraph mapDiagramToGraph() {
    Map<AnchorContainer, Node> shapeToNode = new HashMap<AnchorContainer, Node>();
    Diagram d = getDiagram();
    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) {
      AnchorContainer source = connection.getStart().getParent();
      AnchorContainer target = connection.getEnd().getParent();
      Edge edge = new Edge(shapeToNode.get(source), shapeToNode.get(target));
      edge.data = connection;
      edgeList.add(edge);
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
  }
View Full Code Here

    // Remove all unreferenced single beans and connect all unreferenced
    // subgraphs with a temporary root bean
    Bean root = new Bean();
    graph.nodes.add(root);

    EdgeList rootEdges = new EdgeList();
    List<Bean> orphanBeans = new ArrayList<Bean>();
    beans = getBeans().iterator();
    while (beans.hasNext()) {
      Bean bean = (Bean) beans.next();
      if (bean.incoming.isEmpty() && bean.outgoing.isEmpty()) {
        orphanBeans.add(bean);
        graph.nodes.remove(bean);
      }
      else {
        Reference reference = new Reference(BeanType.STANDARD, root, bean, false);
        reference.weight = 0;
        rootEdges.add(reference);
        graph.edges.add(reference);
      }
    }

    // Calculate position of all beans in graph
    try {
      new DirectedGraphLayout().visit(graph);

      // Re-invert edges inverted while breaking cycles; this only seems to be required on earlier GEF versions
      if (!SpringCoreUtils.isEclipseSameOrNewer(3, 6)) {
        for (int i = 0; i < graph.edges.size(); i++) {
          Edge e = graph.edges.getEdge(i);
          if (e.isFeedback()) {
            e.invert();
          }
        }
      }

      // Remove temporary root and root edges
      for (int i = 0; i < rootEdges.size(); i++) {
        Edge e = rootEdges.getEdge(i);
        e.source.outgoing.remove(e);
        e.target.incoming.remove(e);
        graph.edges.remove(e);
      }
      graph.nodes.remove(root);
View Full Code Here

TOP

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

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.