in graphLayout/jetbrains.mps.graphLayout.orthogonalLayout/source_gen/jetbrains/mps/graphLayout/flowOrthogonalLayout/EmbeddedGraphModifier.java [439:489]
private void connectSpecialNodesInFace(Face face, Iterable<Node> specialNodes) {
List<Dart> darts = face.getDarts();
Direction2D prevDir = MapSequence.fromMap(myDartDirections).get(ListSequence.fromList(darts).last());
Node node = null;
Direction2D dir = null;
Dart dartToSplit = null;
for (Dart dart : ListSequence.fromList(darts)) {
node = dart.getSource();
dir = MapSequence.fromMap(myDartDirections).get(dart);
if (Sequence.fromIterable(specialNodes).contains(node) && prevDir == dir) {
Direction2D opposite = MapSequence.fromMap(myDartDirections).get(dart).opposite();
List<Dart> oppositeDarts = getDirectionDarts(face, opposite);
if (ListSequence.fromList(oppositeDarts).count() == 1) {
dartToSplit = ListSequence.fromList(oppositeDarts).first();
break;
}
}
prevDir = dir;
}
if (dartToSplit != null) {
Edge edgeToSplit = dartToSplit.getEdge();
for (Dart dart : ListSequence.fromList(myEmbeddedGraph.getDarts(edgeToSplit))) {
MapSequence.fromMap(myDartDirections).removeKey(dart);
}
List<Edge> newEdges = ListSequence.fromList(new ArrayList<Edge>());
Node newNode = myEmbeddedGraph.splitEdge(edgeToSplit, newEdges);
for (Dart dart : ListSequence.fromList(newEdges).translate(new ITranslator2<Edge, Dart>() {
public Iterable<Dart> translate(Edge it) {
return myEmbeddedGraph.getDarts(it);
}
})) {
if (myEmbeddedGraph.getFace(dart) == face) {
MapSequence.fromMap(myDartDirections).put(dart, dir.opposite());
} else {
MapSequence.fromMap(myDartDirections).put(dart, dir);
}
}
Edge splittingEdge = myGraph.connect(node, newNode);
List<Face> newFaces = myEmbeddedGraph.splitFace(face, ListSequence.fromListAndArray(new ArrayList<Edge>(), splittingEdge), node, newNode);
for (Dart dart : ListSequence.fromList(myEmbeddedGraph.getDarts(splittingEdge))) {
if (dart.getSource() == node) {
MapSequence.fromMap(myDartDirections).put(dart, dir.turnClockwise(1));
} else {
MapSequence.fromMap(myDartDirections).put(dart, dir.turnClockwise(1).opposite());
}
}
for (Face newFace : ListSequence.fromList(newFaces)) {
connectSpecialNodesInFace(newFace, specialNodes);
}
}
}