public GraphPointLayout getFlowLayout()

in graphLayout/jetbrains.mps.graphLayout.orthogonalLayout/source_gen/jetbrains/mps/graphLayout/internal/flowOrthogonalLayout/OrthogonalPointFlowLayouter.java [97:162]


  public GraphPointLayout getFlowLayout(EmbeddedGraph embeddedGraph, EdgesHistoryManager historyManager) {
    Graph graph = embeddedGraph.getGraph();
    List<Edge> oldEdges = ListSequence.fromList(new ArrayList<Edge>());
    ListSequence.fromList(oldEdges).addSequence(ListSequence.fromList(graph.getEdges()));
    List<Node> oldNodes = ListSequence.fromList(new ArrayList<Node>());
    ListSequence.fromList(oldNodes).addSequence(ListSequence.fromList(graph.getNodes()));
    Map<Dart, Integer> bends = MapSequence.fromMap(new HashMap<Dart, Integer>());
    Map<Dart, Integer> angles = MapSequence.fromMap(new HashMap<Dart, Integer>());
    QuasiOrthogonalRepresentation.getRepresentation(embeddedGraph, bends, angles);
    if (OrthogonalPointFlowLayouter.SHOW_lOG > 0) {
      System.out.println("bends:");
      System.out.println(bends);
    }
    if (OrthogonalPointFlowLayouter.SHOW_TIME > 0) {
      long newTime = System.currentTimeMillis();
      System.out.println("finding the representation: " + ((newTime - curTime) / OrthogonalPointFlowLayouter.MILLIS));
      curTime = newTime;
    }
    new QuasiRepresentationModifier(embeddedGraph, bends, angles).reduceToOrthogonalRepresentation();
    OrthogonalRepresentation.replaceBendsByNodes(embeddedGraph, bends, angles);
    Map<Dart, Direction2D> directions = OrthogonalRepresentation.getDirections(embeddedGraph, angles);
    EmbeddedGraphModifier modifier = new EmbeddedGraphModifier(embeddedGraph);
    modifier.setDartDirections(directions);
    modifier.makeRectangularFaces();
    if (OrthogonalPointFlowLayouter.SHOW_lOG > 0) {
      System.out.println("after making faces rectangular: ");
      printEmbeddedGraphWithDirections(embeddedGraph, directions);
    }
    if (OrthogonalPointFlowLayouter.SHOW_TIME > 0) {
      long newTime = System.currentTimeMillis();
      System.out.println("making faces rectangular: " + ((newTime - curTime) / OrthogonalPointFlowLayouter.MILLIS));
      System.out.println("graph now has " + ListSequence.fromList(graph.getNodes()).count() + " nodes and " + ListSequence.fromList(graph.getEdges()).count() + " edges");
      curTime = newTime;
    }
    Map<Edge, Integer> lengths = new EdgeLengthComputer().compute(embeddedGraph, directions);
    Map<Node, Point> coordinates;
    /*
      CoordinatePlacer placer = new CoordinatePlacer(embeddedGraph, lengths, directions);
      coordinates = placer.getCoordinates();
    */
    ConstraintsGraphProcessor processor = new ConstraintsGraphProcessor(embeddedGraph, directions);
    processor.constructGraph();
    coordinates = processor.getCoordinates();
    GraphPointLayout graphLayout = new GraphPointLayout(graph);
    for (Node node : ListSequence.fromList(oldNodes)) {
      graphLayout.setLayoutFor(node, MapSequence.fromMap(coordinates).get(node));
    }
    for (Edge edge : ListSequence.fromList(oldEdges)) {
      List<Edge> history = historyManager.getHistory(edge);
      List<Point> edgeLayout = ListSequence.fromList(new ArrayList<Point>());
      Node cur = edge.getSource();
      ListSequence.fromList(edgeLayout).addElement(MapSequence.fromMap(coordinates).get(cur));
      for (Edge historyEdge : ListSequence.fromList(history)) {
        Node next = historyEdge.getOpposite(cur);
        ListSequence.fromList(edgeLayout).addElement(MapSequence.fromMap(coordinates).get(next));
        cur = next;
      }
      graphLayout.setLayoutFor(edge, edgeLayout);
    }
    if (OrthogonalPointFlowLayouter.SHOW_TIME > 0) {
      long newTime = System.currentTimeMillis();
      System.out.println("finding layout: " + ((newTime - curTime) / OrthogonalPointFlowLayouter.MILLIS));
      curTime = newTime;
    }
    return graphLayout;
  }