|
@@ -13,9 +13,12 @@ import animation.Memory;
|
|
|
import animation.Memory.MemoryType;
|
|
|
import animation.Memory.ReadOnlyMemory;
|
|
|
import animation.PseudoCodeNode;
|
|
|
+import codelines.Comment;
|
|
|
import codelines.DeclareVariable;
|
|
|
import codelines.ForEachLoop;
|
|
|
+import codelines.FunctionCall;
|
|
|
import codelines.FunctionDefinition;
|
|
|
+import codelines.IfLoop;
|
|
|
import codelines.SetVariable;
|
|
|
import graph.LayeredGraphNode;
|
|
|
|
|
@@ -38,7 +41,7 @@ public class Combine {
|
|
|
return super.getDebugOutput( m );
|
|
|
}
|
|
|
};
|
|
|
- root.add( new PseudoCodeNode( "-- Align all Layouts to the one with the smallest width --", vars, tree, new CodeLine() {
|
|
|
+ root.add( new PseudoCodeNode( "-- Call combine of subgraphs --", vars, tree, new CodeLine() {
|
|
|
@Override
|
|
|
public ControlFlow runForward(Memory m) {
|
|
|
LayeredGraphNode graph = m.read( "graph", MemoryType.LOCAL );
|
|
@@ -51,6 +54,22 @@ public class Combine {
|
|
|
return new ControlFlow( ControlFlow.STEP_OVER );
|
|
|
}
|
|
|
}));
|
|
|
+ PseudoCodeNode recursiveLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
|
|
|
+ @Override
|
|
|
+ protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
|
|
|
+ return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedNodes();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ root.add( recursiveLoop );
|
|
|
+ PseudoCodeNode ifNode = new PseudoCodeNode( "if v has subgraph then", vars, tree, new IfLoop() {
|
|
|
+ @Override
|
|
|
+ protected boolean condition(ReadOnlyMemory m) {
|
|
|
+ return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getContainedNodes().size() > 0;
|
|
|
+ }
|
|
|
+ } );
|
|
|
+ recursiveLoop.add( ifNode );
|
|
|
+ ifNode.add( new PseudoCodeNode( "call combine( v );", vars, tree, new FunctionCall( root, new String[]{ "v" } ) ) );
|
|
|
+ root.add( new PseudoCodeNode( "-- Align all Layouts to the one with the smallest width --", vars, tree, new Comment()));
|
|
|
PseudoCodeNode firstLoop = new PseudoCodeNode( "foreach l in ['DOWN_RIGHT', 'DOWN_LEFT', 'UP_RIGHT', 'UP_LEFT'] do", vars, tree, new ForEachLoop<String>( "l" ) {
|
|
|
@Override
|
|
|
protected List<String> list(ReadOnlyMemory m) {
|