Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

Eren Yilmaz 5 anni fa
parent
commit
10a9a5c14b

+ 18 - 6
src/bk/BKNodePlacement.java

@@ -56,7 +56,9 @@ public class BKNodePlacement {
      */
     public PseudoCodeNode createPseudocodeTree( JTree tree )
     {
+    	// Liste mit Variablen die eine andere Farbe im Code bekommen sollen
     	String[] vars = { "layout", "graph" };
+    	// Die Mainfunktion des BK Node Placement Algorithmus
     	PseudoCodeNode mainFunction = new PseudoCodeNode( "function bkNodePlacement( graph )", vars, tree, new FunctionDefinition( new String[]{"graph"} ) );
     	PseudoCodeNode root = new PseudoCodeNode( "-- BK Node Placement Algorithm --", vars, tree, new CodeLine() {
 
@@ -67,29 +69,35 @@ public class BKNodePlacement {
 					actions.push( (Memory mem) -> {} );
 					return new ControlFlow( ControlFlow.STEP_OVER );
 				}
-                m.declare( "param1", m.read( "graph", Visibility.GLOBAL ), Visibility.GLOBAL );
+                m.declare( "param1", m.read( "graph", Visibility.GLOBAL ), Visibility.GLOBAL ); // schreibe den Graph in die Globalen Parameter Register des Speichers
 				m.declare( "Called", true, Visibility.GLOBAL );
 				actions.push( (Memory mem) -> {
                     m.undeclare( "param1", Visibility.GLOBAL );
 	                m.undeclare( "Called", Visibility.GLOBAL );
 				} );
-				return new ControlFlow( mainFunction );
+				return new ControlFlow( mainFunction ); // Rufe die Hauptfunktion von BK auf (Jump to mainFunction)
+				// Diese lädt den Graph selbstständig aus dem globalen Speicher in ihr neues Stack Frame
 			}
 
         } );
         root.setSelected( true );
-
+        // Erzeuge die Conflict Detection Function
         PseudoCodeNode conflictDetectionFunction = ConflictDetection.mark_conflicts( tree );
+        // Funktion zum Berechnen der Layouts
         PseudoCodeNode calcLayout = new PseudoCodeNode( "function calcLayout( layout, graph )", vars, tree, new FunctionDefinition( vars ) );
+        // Erzeuge die Funktion zum Kombinieren der LKayouts
         PseudoCodeNode combine = Balancing.combine( tree );
         root.add( mainFunction );
+        // Ruft die Konflikt Detection Funktion auf
         mainFunction.add( new PseudoCodeNode( "call detectConflicts( graph )", vars, tree, new FunctionCall( conflictDetectionFunction, new String[]{ "graph" } ) ) );
+        // Setze das aktuelle Layout
         mainFunction.add( new PseudoCodeNode( "layout = 'RIGHTMOST_LOWER'", vars, tree, new DeclareVariable<String>( "layout" ) {
             @Override
             protected String value(ReadOnlyMemory m) {
                 return "RIGHTMOST_LOWER";
             }
         }) );
+        // Rufe die Funktion zum Berechnen des Layouts auf
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "layout = 'LEFTMOST_LOWER'", vars, tree, new SetVariable<String>( "layout" ) {
             @Override
@@ -112,6 +120,7 @@ public class BKNodePlacement {
             }
         }) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
+        // Rufe die Funktion zum Berechnen des Kombinierten Layouts auf
         mainFunction.add( new PseudoCodeNode( "call combine( graph )", vars, tree, new FunctionCall( combine, new String[]{ "graph" } ) ) );
         PseudoCodeNode conflictsStage = new PseudoCodeNode( "-- mark type 1 conflicts --", vars, tree, new Comment() ) {
             private static final long serialVersionUID = 1041941539437672704L;
@@ -124,8 +133,11 @@ public class BKNodePlacement {
         };
         root.add( conflictsStage );
         conflictsStage.add( conflictDetectionFunction );
+        // Erzeuge die Funktion zum berechnen der Blöcke
         PseudoCodeNode blockCalc = VerticalAligment.calculateBlockGraph( tree, calcLayout );
+        // Erzeuge die Placeblock Function
         PseudoCodeNode placeBlock = PlaceBlock.place_block( tree );
+        // Erzeuge die Funktion zum zuweisen der Positionen
         PseudoCodeNode horizontalCompaction = HorizontalCompaction.horizontalCompaction( tree, placeBlock );
         calcLayout.add( new PseudoCodeNode( "call calculateBlockGraph( layout, graph )", vars, tree, new FunctionCall( blockCalc, vars ) ) );
         calcLayout.add( new PseudoCodeNode( "call horizontalCompaction( layout, graph )", vars, tree, new FunctionCall( horizontalCompaction, vars ) ) );
@@ -133,14 +145,14 @@ public class BKNodePlacement {
             private static final long serialVersionUID = 4141215748809071958L;
 
             @Override
-            public String getDebugOutput( Memory m ) {
+            public String getDebugOutput( Memory m ) { // Debug Text für die Layout Berechnungs Phase
                 if( !m.isSomewhereDefined( "graph", Visibility.COMPLETE_STACK ) || !m.isSomewhereDefined( "layout", Visibility.COMPLETE_STACK ) )
                     return "";
                 String info = "| Node | Shift | Sink | Root | Align |  x  |  xDef  |\n";
                 info +=       "|------|-------|------|------|-------|-----|--------|\n";
                 LayeredGraphNode graph = m.read( "graph", Visibility.COMPLETE_STACK );
                 LayoutType type = LayoutType.fromString( m.read( "layout", Visibility.COMPLETE_STACK ) );
-                switch( type ) {
+                switch( type ) { // Aktualisierung des aktuellen Zustandes des Algorithmus (Wird zum Zeichnen des richtigen Layouts benötigt)
                 case LEFTMOST_UPPER:
                     stage = Stage.LEFTMOST_UPPER;
                     break;
@@ -184,7 +196,7 @@ public class BKNodePlacement {
             private static final long serialVersionUID = 4212377075998840086L;
 
             @Override
-            public String getDebugOutput( Memory m ) {
+            public String getDebugOutput( Memory m ) { // Debug Text für die Berechnung des kombinierten Layouts
                 stage = Stage.COMBINE;
                 if( !m.isSomewhereDefined( "graph", Visibility.COMPLETE_STACK ) )
                     return "";

+ 26 - 4
src/bk/Balancing.java

@@ -39,30 +39,33 @@ public class Balancing {
     public static PseudoCodeNode combine( JTree tree ) {
         String[] vars = { "graph", "l", "l_min", "v", "positions", "min", "shift", "max", "width" };
 
+        // Der Pseudocode Knoten für die combine Funktion
         PseudoCodeNode root = new PseudoCodeNode( "function combine( graph )", vars, tree, new FunctionDefinition( new String[]{ "graph" } ) ){
             private static final long serialVersionUID = -3067185213650162055L;
 
             @Override
             public String getDebugOutput( Memory m )
             {
-                if( m.isSomewhereDefined( "v", Visibility.LOCAL ) )
+                if( m.isSomewhereDefined( "v", Visibility.LOCAL ) ) // Markiere den aktuell betrachteten Knoten
                     m.<LayeredGraphNode>read( "v", Visibility.LOCAL).setSelected( null );
                 return super.getDebugOutput( m );
             }
         };
+        // Pseudocode Kommentar
         root.add( new PseudoCodeNode( "-- Call combine of subgraphs --", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
                 LayeredGraphNode graph = m.read( "graph", Visibility.LOCAL );
                 if( graph.parent() == null )
-                    graph.setColor( Color.BLACK, null );
-                actions.add( (Memory mem) -> {
+                    graph.setColor( Color.BLACK, null ); // dieß macht das Combine Layout in der View sichtbar
+                actions.push( (Memory mem) -> { // schritt zum rückwärts machen merken
                     if( graph.parent() == null )
-                        graph.setColor( null, null );
+                        graph.setColor( null, null ); // macht das Combine Layout wieder unsichtbar
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // for schleife durch alle Knoten in dem betrachteten Graph
         PseudoCodeNode recursiveLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
@@ -70,6 +73,7 @@ public class Balancing {
             }
         });
         root.add( recursiveLoop );
+        // Prüfe ob der Knoten einen Subgraph hat
         PseudoCodeNode ifNode = new PseudoCodeNode( "if v has subgraph then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -77,8 +81,10 @@ public class Balancing {
             }
         } );
         recursiveLoop.add( ifNode );
+        // Ruft die Combine Funktion für den Subgraphen auf
         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()));
+        // Initialisiere Listen für die minimalen und maximalen X Koordinaten und der Breite aller Layouts
         root.add( new PseudoCodeNode( "max = [];", vars, tree, new DeclareVariable<HashMap<String,Integer>>( "max") {
             @Override
             protected HashMap<String,Integer> value(ReadOnlyMemory m) {
@@ -97,6 +103,7 @@ public class Balancing {
                 return new HashMap<String,Integer>();
             }
         }));
+        // Schleife durch alle Layouts
         PseudoCodeNode firstLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             protected List<String> list(ReadOnlyMemory m) {
@@ -109,6 +116,7 @@ public class Balancing {
             }
         });
         root.add( firstLoop );
+        // Ermittelt die minnimale X Koordinate des Layouts
         firstLoop.add( new PseudoCodeNode( "min[l] = minimum x coordinate in l;", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -120,6 +128,7 @@ public class Balancing {
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Ermittelt die maximale X Koordinate des Layouts
         firstLoop.add( new PseudoCodeNode( "max[l] = maximum x coordinate in l;", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -131,6 +140,7 @@ public class Balancing {
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Ermittelt die Breite des Layouts
         firstLoop.add( new PseudoCodeNode( "width[l] = max[l] - min[l];", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -142,6 +152,7 @@ public class Balancing {
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Ermittelt das Layout mit der minnimalen Breite
         root.add( new PseudoCodeNode( "l_min = l with width[l] == min(width);", vars, tree, new DeclareVariable<String>( "l_min" ) {
             @Override
             protected String value(ReadOnlyMemory m) {
@@ -158,12 +169,14 @@ public class Balancing {
                 return min;
             }
         }));
+        // Initialisiert eine Liste mit Offsets für alle Layouts
         root.add( new PseudoCodeNode( "shift = [];", vars, tree, new DeclareVariable<HashMap<String,Integer>>( "shift") {
             @Override
             protected HashMap<String,Integer> value(ReadOnlyMemory m) {
                 return new HashMap<String,Integer>();
             }
         }));
+        // Schleife durch alle Layouts
         PseudoCodeNode secondLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             protected List<String> list(ReadOnlyMemory m) {
@@ -176,6 +189,7 @@ public class Balancing {
             }
         });
         root.add( secondLoop );
+        // Berechne das Offset für das Layout
         secondLoop.add( new PseudoCodeNode( "shift[l] = l.contains('RIGHT') ? min[l_min] - min[l] : max[l_min] - max[l];", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -191,6 +205,7 @@ public class Balancing {
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Schleife durch alle Knoten des Graphen
         PseudoCodeNode thirdLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
@@ -198,12 +213,14 @@ public class Balancing {
             }
         });
         root.add( thirdLoop );
+        // Initialisiere Positionsliste für den Knoten
         thirdLoop.add( new PseudoCodeNode( "positions = [];", vars, tree, new DeclareVariable<ArrayList<Integer>>( "positions") {
             @Override
             protected ArrayList<Integer> value(ReadOnlyMemory m) {
                 return new ArrayList<Integer>();
             }
         }));
+        // Schleife durch alle Layouts
         PseudoCodeNode innerLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             protected List<String> list(ReadOnlyMemory m) {
@@ -215,6 +232,7 @@ public class Balancing {
                 return list;
             }
         });
+        // Füge die Position des Knotens in dem Layout der Liste hinzu
         innerLoop.add( new PseudoCodeNode( "positions.add(x[v] in l);", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -228,6 +246,7 @@ public class Balancing {
             }
         }));
         thirdLoop.add( innerLoop );
+        // Sortiere die Positionsliste
         thirdLoop.add( new PseudoCodeNode( "positions = sort( positions );", vars, tree, new SetVariable<ArrayList<Integer>>( "positions" ) {
             @Override
             public ArrayList<Integer> value(ReadOnlyMemory m) {
@@ -239,6 +258,7 @@ public class Balancing {
                 return neu;
             }
         }));
+        // Ermittle die Position des Knotens im Combine Layout
         thirdLoop.add( new PseudoCodeNode( "x[v] = (positions[1]+positions[2]) / 2;", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
@@ -255,6 +275,7 @@ public class Balancing {
         return root;
     }
 
+    // Berechnet die minimale X Koordinate für ein Layout eines Graphen
     private static int calcMinX( LayeredGraphNode graph, LayoutType layout )
     {
         int minX = 0;
@@ -265,6 +286,7 @@ public class Balancing {
         return minX;
     }
 
+    // Berechnet die Maximale X Koordinate für ein Layout eines Graphen
     private static int calcMaxX( LayeredGraphNode graph, LayoutType layout )
     {
         int maxX = 0;

+ 14 - 5
src/bk/ConflictDetection.java

@@ -103,9 +103,11 @@ public class ConflictDetection {
     public static PseudoCodeNode mark_conflicts(JTree tree) {
         String[] vars = { "i", "L", "k0", "l", "l1", "k1", "v", "graph", "n" };
         String[] params = { "graph" };
+        // Erstelle die mark Conflicts Funktion
         PseudoCodeNode root = new PseudoCodeNode( "function mark_conflicts( graph )", vars, tree, new FunctionDefinition( params ) );
         PseudoCodeNode text = new PseudoCodeNode( "-- mark conflicts in subgraphs --", vars, tree, new Comment() );
         root.add( text );
+        // Für jeden Knoten im Graphen
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach n in graph.getContainedNodes() do", vars, tree, new ForEachLoop<LayeredGraphNode>( "n" ) {
 			@Override
 			protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
@@ -113,6 +115,7 @@ public class ConflictDetection {
 			}
         } );
         root.add( foreach );
+        // Falls der Knoten einen Subgraphen hat
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
 			@Override
 			protected boolean condition(ReadOnlyMemory m) {
@@ -120,10 +123,12 @@ public class ConflictDetection {
 			}
         } );
         foreach.add( ifNode );
+        // Rufe die Funktion rekursiv für den Subgraphen auf
         PseudoCodeNode call = new PseudoCodeNode( "call mark_conflicts( n );", vars, tree, new FunctionCall( root, new String[]{ "n" } ) );
         ifNode.add( call );
         text = new PseudoCodeNode( "-- mark conflicts in graph --", vars, tree, new Comment() );
         root.add( text );
+        // Speichere die Layer in einer lokalen Variable
         PseudoCodeNode init = new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
@@ -131,6 +136,7 @@ public class ConflictDetection {
             }
         } );
         root.add( init );
+        // Für jeden Layerindex vom 2. bis zum vorletzten (nur hier können innere Segmente auftreten)
         PseudoCodeNode outerLoop = new PseudoCodeNode( "for i=1 to |L|-2 do", vars, tree, new ForLoop( "i" ) {
 			@Override
 			protected int minimum( ReadOnlyMemory m ) {
@@ -142,12 +148,13 @@ public class ConflictDetection {
 			}
         } );
         root.add( outerLoop );
+        // Initialisiere lokale Variablen
         PseudoCodeNode line = new PseudoCodeNode( "k0 = 0; l = 0;", vars, tree, new CodeLine() {
 			@Override
 			public ControlFlow runForward(Memory m) {
-				m.declare( "k0", 0, Visibility.LOCAL );
+				m.declare( "k0", 0, Visibility.LOCAL ); // deklariere die Variablen im aktuellen Stack Frame
 				m.declare( "l", 0, Visibility.LOCAL );
-				actions.push( (Memory mem) -> {
+				actions.push( (Memory mem) -> { // Merkt sich die Rückgängig-mach-Aktion
 					mem.undeclare( "k0", Visibility.LOCAL );
 					mem.undeclare( "l", Visibility.LOCAL );
 				} );
@@ -155,6 +162,7 @@ public class ConflictDetection {
 			}
         } );
         outerLoop.add( line );
+        // Für eine genauere Beschreibung des Algoritmus zum markieren von Konflikten siehe Karstens Paper (link in Dokumentation)
         PseudoCodeNode innerLoop = new PseudoCodeNode( "for l1=0 to |L[i+1]|-1 do", vars, tree, new ForLoop( "l1" ) {
 			@Override
 			protected int minimum(ReadOnlyMemory m) {
@@ -184,7 +192,7 @@ public class ConflictDetection {
         PseudoCodeNode innerIfNode = new PseudoCodeNode( "if L[i+1][l1] incident to inner segment between L[i+1] and L[i] then", vars, tree, new IfLoop() {
 			@Override
 			protected boolean condition(ReadOnlyMemory m) {
-				return incidentToInnerSegmentBetweenLiPlusOneAndLi( m );
+				return incidentToInnerSegmentBetweenLiPlusOneAndLi( m ); // Prüfe ob ein inneres Segment da ist
 			}
 		} );
         ifNode.add( innerIfNode );
@@ -224,9 +232,9 @@ public class ConflictDetection {
 			public ControlFlow runForward(Memory m) {
 				LayeredGraphEdge e = m.read( "v", Visibility.LOCAL );
 				boolean old = e.isConflicted( LayoutType.LEFTMOST_UPPER );
-				e.setConflicted( true, null );
+				e.setConflicted( true, null ); // Markiere die Kante als Konflicted
 				actions.add( (Memory mem) -> {
-					e.setConflicted( old, null );
+					e.setConflicted( old, null ); // Rückwärts
 				});
 				return new ControlFlow( ControlFlow.STEP_OVER );
 			}
@@ -249,6 +257,7 @@ public class ConflictDetection {
         return root;
     }
     
+    // Sucht nach Inneren Segmenten
     private static boolean incidentToInnerSegmentBetweenLiPlusOneAndLi( ReadOnlyMemory m ) {
         LayeredGraphNode curr = m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 ).get( m.read( "l1", Visibility.LOCAL ) );
         for (LayeredGraphEdge e : curr.getIncomingEdges()) {

+ 18 - 11
src/bk/HorizontalCompaction.java

@@ -34,7 +34,6 @@ public class HorizontalCompaction {
      */
     public static PseudoCodeNode horizontalCompaction( JTree tree, PseudoCodeNode placeBlock ) {
         String[] vars = { "i", "L", "layout", "graph", "k", "v" };
-
         PseudoCodeNode root = new PseudoCodeNode( "function horizontalCompaction( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
             private static final long serialVersionUID = -2594556212373706809L;
 
@@ -46,33 +45,36 @@ public class HorizontalCompaction {
                 return super.getDebugOutput( m );
             }
         };
+        // Speichert die Layer in einer lokalen Variable im aktuellen Stackframe
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
                 return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers();
             }
         } ) );
+        // Schleife durch die Layer (in richtiger Reihenfolge je nach Layout
         PseudoCodeNode firstLoop = new PseudoCodeNode( "for i=layout.contains('LOWER') ? 0 : |L|-1 to layout.contains('LOWER') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
             @Override
             protected Integer intialize(ReadOnlyMemory m) {
                 if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
-                    return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1;
+                    return 0; // begine mit dem ersten LAyer wenn das Layout lower beinhaltet
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1; // beginne mit dem letzten layer
             }
             @Override
-            protected Integer step(ReadOnlyMemory m) {
+            protected Integer step(ReadOnlyMemory m) { // berechnet nächsten wert der Schleifenvariable
                 if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                     return m.<Integer>read( "i", Visibility.LOCAL ) + 1;
                 return m.<Integer>read( "i", Visibility.LOCAL ) - 1;
             }
             @Override
-            protected boolean condition(ReadOnlyMemory m) {
+            protected boolean condition(ReadOnlyMemory m) { // Prüft ob Schleife fertig ist
                 if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                     return m.<Integer>read( "i", Visibility.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1;
                 return m.<Integer>read( "i", Visibility.LOCAL ) >= 0;
             }
         });
         root.add( firstLoop );
+        // Schleife durch die Knoten (Reihenfolge nach Layout)
         PseudoCodeNode nodeLoop = new PseudoCodeNode( "for k=layout.contains('RIGHT') ? 0 : |L[i]|-1 to layout.contains('RIGHT') ? |L[i]|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "k" ) {
             @Override
             protected Integer intialize( ReadOnlyMemory m) {
@@ -94,12 +96,14 @@ public class HorizontalCompaction {
             }
         });
         firstLoop.add( nodeLoop );
+        // Speichere den aktiuellen Knoten in einer Lokalen Variable
         nodeLoop.add( new PseudoCodeNode( "v = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "v" ) {
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
                 return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).get( m.read( "k", Visibility.LOCAL ) );
             }
         }));
+        // Falls der Knoten die Wurzel seines Blockes ist
         PseudoCodeNode ifRoot = new PseudoCodeNode( "if root[v] == v then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -107,7 +111,9 @@ public class HorizontalCompaction {
             }
         });
         nodeLoop.add( ifRoot );
+        // Rufe Place Block für den Knoten auf
         ifRoot.add( new PseudoCodeNode( "call place_block(v, layout);", vars, tree, new FunctionCall( placeBlock, new String[]{ "v", "layout" } ) ) );
+        // Schleife durch alle Layer (Reihenfolge je nach Layout)
         PseudoCodeNode secondLoop = new PseudoCodeNode( "for i=layout.contains('LOWER') ? 0 : |L|-1 to layout.contains('LOWER') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
             @Override
             protected Integer intialize(ReadOnlyMemory m) {
@@ -129,6 +135,7 @@ public class HorizontalCompaction {
             }
         });
         root.add( secondLoop );
+        // Schleife durch alle Knoten (Reihenfolge nicht Relewand)
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach v in L[i] do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
@@ -141,11 +148,11 @@ public class HorizontalCompaction {
             public ControlFlow runForward(Memory m) {
                 LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
-                double old = v.getX( layout );
+                double old = v.getX( layout ); // speichert die alte Koordinate
                 boolean oldDef = !v.isXUndefined( layout );
-                v.setX( v.getRoot( layout ).getX( layout ), true, layout );
+                v.setX( v.getRoot( layout ).getX( layout ), true, layout ); // Setzt die neue Koordinate
                 actions.push( (Memory mem) -> {
-                    v.setX( old, oldDef, layout );
+                    v.setX( old, oldDef, layout ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
@@ -165,11 +172,11 @@ public class HorizontalCompaction {
             public ControlFlow runForward(Memory m) {
                 LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
-                double old = v.getX( layout );
+                double old = v.getX( layout ); // speichert alte Koordinate
                 boolean oldDef = !v.isXUndefined( layout );
-                v.setX( old + v.getSink( layout ).getShift( layout ), true, layout );
+                v.setX( old + v.getSink( layout ).getShift( layout ), true, layout ); // Addiert den Schift des Knotens
                 actions.push( (Memory mem) -> {
-                    v.setX( old, oldDef, layout );
+                    v.setX( old, oldDef, layout ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }

+ 15 - 8
src/bk/PlaceBlock.java

@@ -33,12 +33,13 @@ public class PlaceBlock{
     public static PseudoCodeNode place_block(JTree tree) {
         String[] vars = { "v", "w", "layout", "x", "y", "graph", "u", "root", "align", "first" };
 
+        // Funktion zum Plazieren eines Knotens
         PseudoCodeNode root = new PseudoCodeNode( "function place_block( v, layout )", vars, tree, new FunctionDefinition(new String[]{ "v", "layout" } ) ) {
             private static final long serialVersionUID = 8208248088929356639L;
 
             @Override
             public String getDebugOutput( Memory m )
-            {
+            { // Markiere den aktuell betrachteten Knoten
                 if( m.isSomewhereDefined( "v", Visibility.LOCAL ) && !m.isSomewhereDefined( "w", Visibility.LOCAL ) )
                     m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).setSelected( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 if( m.isSomewhereDefined( "w", Visibility.LOCAL ) )
@@ -46,6 +47,7 @@ public class PlaceBlock{
                 return super.getDebugOutput( m );
             }
         };
+        // Prüfe ob x undefiniert ist
         PseudoCodeNode ifUndef = new PseudoCodeNode( "if x[v] == undefined then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -53,21 +55,23 @@ public class PlaceBlock{
             }
         });
         root.add( ifUndef );
+        // Initialisiere lokale Variablen
         ifUndef.add( new PseudoCodeNode( "x[v] = 0; w = v; first = true;", vars, tree, new CodeLine() {
             @Override
             public ControlFlow runForward(Memory m) {
-                m.declare( "w", m.read( "v", Visibility.LOCAL ), Visibility.LOCAL );
+                m.declare( "w", m.read( "v", Visibility.LOCAL ), Visibility.LOCAL ); // Erstellt Variablen im aktuellen Stack Frame
                 m.declare( "first", true, Visibility.LOCAL );
                 double oldX = m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getX( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).setX( 0, true, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 actions.push( (Memory mem) -> {
-                    mem.undeclare( "w", Visibility.LOCAL );
+                    mem.undeclare( "w", Visibility.LOCAL ); // Rückwärts
                     mem.undeclare( "first", Visibility.LOCAL );
                     m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).setX( oldX, false, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Solange w != v ist (eigentlich do while aber das ist nicht implementiert daher mit temporären boolen first)
         PseudoCodeNode whilewv = new PseudoCodeNode( "while w != v or first", vars, tree, new WhileLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -81,6 +85,7 @@ public class PlaceBlock{
                 return false;
             }
         }));
+        // Für eine genauere Beschreibung des Algoritmus siehe Karstens Paper (Link in Dokumentation)
         PseudoCodeNode ifPos = new PseudoCodeNode( "if (layout.contains('RIGHT') and pos(w)>0) or (layout.contains('LEFT') and pos(w)<|layerOf(w)|-1) then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -109,9 +114,9 @@ public class PlaceBlock{
                 LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
                 LayeredGraphNode old = v.getSink( layout );
-                v.setSink( old == v ? u.getSink( layout ) : old, layout );
+                v.setSink( old == v ? u.getSink( layout ) : old, layout ); // Setze neue Sink des Knotens
                 actions.push( (Memory mem) -> {
-                   v.setSink( old, layout ); 
+                   v.setSink( old, layout );  // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
@@ -132,11 +137,11 @@ public class PlaceBlock{
                 LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
                 LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
                 double old = u.getSink( layout ).getShift( layout );
-                u.getSink( layout ).setShift( lStr.contains( "RIGHT" ) ? 
+                u.getSink( layout ).setShift( lStr.contains( "RIGHT" ) ?  // Setzt neues Shift
                         Math.min( u.getSink( layout ).getShift( layout ), v.getX( layout ) - u.getX( layout ) - calcSpacing( u.parent(), layout ) ) : 
                             Math.max( u.getSink( layout ).getShift( layout ), v.getX( layout ) + u.getX( layout ) + calcSpacing( u.parent(), layout ) ), layout);
                 actions.push( (Memory mem) -> {
-                    u.getSink( layout ).setShift( old, layout );
+                    u.getSink( layout ).setShift( old, layout ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
@@ -158,13 +163,15 @@ public class PlaceBlock{
                 LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
                 double old = v.getX( layout );
                 boolean oldDef = !v.isXUndefined( layout );
+                // Setzt neue X Koordinate
                 v.setX( lStr.contains( "RIGHT" ) ? Math.max( v.getX( layout ), u.getX( layout ) + calcSpacing( u.parent(), layout ) ) : Math.min( v.getX( layout ), u.getX( layout ) - calcSpacing( u.parent(), layout ) ), true, layout );
                 actions.push( (Memory mem) -> {
-                    v.setX( old, oldDef, layout );
+                    v.setX( old, oldDef, layout ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }));
+        // Setze nächstes w für nächsten Schleifendurchlauf
         whilewv.add( new PseudoCodeNode( "w = align[w];", vars, tree, new SetVariable<LayeredGraphNode>( "w" ) {
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {

+ 19 - 5
src/bk/VerticalAligment.java

@@ -36,7 +36,7 @@ public class VerticalAligment {
      */
     public static PseudoCodeNode calculateBlockGraph( JTree tree, PseudoCodeNode calcLayout ) {
         String[] vars = { "graph", "L", "r", "neighbors", "layout", "m", "i", "k", "mids", "n" };
-
+        // Erstelle Funktion fürs berechnen des Blockgraphen
         PseudoCodeNode root = new PseudoCodeNode( "function calculateBlockGraph( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
             private static final long serialVersionUID = -839881272535733474L;
 
@@ -48,12 +48,14 @@ public class VerticalAligment {
                 return super.getDebugOutput( m );
             }
         };
+        // Speichere die Layer in lokaler Variable
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
                 return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers();
             }
         } ) );
+        // Schleife durch alle Layer in richtiger Reihenfolge
         PseudoCodeNode layerLoop = new PseudoCodeNode( "for i=layout.contains('LOWER') ? 0 : |L|-1 to layout.contains('LOWER') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
             @Override
             protected Integer intialize(ReadOnlyMemory m) {
@@ -75,6 +77,7 @@ public class VerticalAligment {
             }
         });
         root.add( layerLoop );
+        // Initialisiere lokale Variable je nach Layout
         layerLoop.add( new PseudoCodeNode( "r = layout.contains('RIGHT') ? -1 : INFINITY;", vars, tree, new DeclareVariable<Double>( "r" ) {
             @Override
             protected Double value(ReadOnlyMemory m) {
@@ -83,6 +86,7 @@ public class VerticalAligment {
                 return Double.POSITIVE_INFINITY;
             }
         } ) );
+        // Schleife durch alle Knoten des Layers (Richtung je nach Layout)
         PseudoCodeNode nodeLoop = new PseudoCodeNode( "for k=layout.contains('RIGHT') ? 0 : |L[i]|-1 to layout.contains('RIGHT') ? |L[i]|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "k" ) {
             @Override
             protected Integer intialize( ReadOnlyMemory m) {
@@ -103,12 +107,14 @@ public class VerticalAligment {
                 return m.<Integer>read( "k", Visibility.LOCAL ) >= 0;
             }
         });
+        // Speichert den aktuellen knoten in lokaler Variable
         nodeLoop.add( new PseudoCodeNode( "n = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "n" ) {
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
                 return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).get( m.read( "k", Visibility.LOCAL ) );
             }
         }));
+        // Prüfe ob der Knoten einen Subgraphen enthält
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
@@ -116,7 +122,9 @@ public class VerticalAligment {
             }
         } );
         nodeLoop.add( ifNode );
+        // Rufe die Funktion rekursiv für den Subgraphen auf
         ifNode.add( new PseudoCodeNode( "call calcLayout( layout, n );", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "n" } ) ) );
+        // Berechne die Nachbarknoten des Knotens (Je nach Layout im vorherigen oder nachfolgenden Layer)
         nodeLoop.add( new PseudoCodeNode( "neighbors = layout.contains('LOWER') ? predecessors(n) : successors(n)", vars, tree, new DeclareVariable<ArrayList<LayeredGraphNode>>( "neighbors" ) {
             @Override
             protected ArrayList<LayeredGraphNode> value(ReadOnlyMemory m) {
@@ -150,6 +158,7 @@ public class VerticalAligment {
                 }
             }
         } ) );
+        // Prüfe on Nachbarn vorhanden sind
         PseudoCodeNode ifNeighbors = new PseudoCodeNode( "if |neighbors| > 0 then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition( ReadOnlyMemory m) {
@@ -157,6 +166,7 @@ public class VerticalAligment {
             }
         });
         nodeLoop.add( ifNeighbors );
+        // Berechne mittlere Nachbarn
         ifNeighbors.add( new PseudoCodeNode( "mids = [roundDown((|neighbors|-1)/2),roundUp((|neighbors|-1)/2)]", vars, tree, new DeclareVariable<ArrayList<Integer>>( "mids" ) {
             @Override
             protected ArrayList<Integer> value(ReadOnlyMemory m) {
@@ -169,6 +179,7 @@ public class VerticalAligment {
                 return list;
             }
         } ) );
+        // Für alle Mittelpunkte (einer oder zwei verschiedene)
         PseudoCodeNode midLoop = new PseudoCodeNode( "foreach m in mids do", vars, tree, new ForEachLoop<Integer>( "m" ) {
             @Override
             protected List<Integer> list(ReadOnlyMemory m) {
@@ -211,9 +222,9 @@ public class VerticalAligment {
                 LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) );
                 LayeredGraphNode v = m.read( "n", Visibility.LOCAL );
                 LayeredGraphNode old = u.getAlign( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
-                u.setAlign( v, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                u.setAlign( v, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ); // Aktualisiere das Align des Knotens
                 actions.push( (Memory mem) -> {
-                    u.setAlign( old, LayoutType.fromString( mem.read( "layout", Visibility.LOCAL ) ) );
+                    u.setAlign( old, LayoutType.fromString( mem.read( "layout", Visibility.LOCAL ) ) ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
@@ -224,9 +235,10 @@ public class VerticalAligment {
                 LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) );
                 LayeredGraphNode v = m.read( "n", Visibility.LOCAL );
                 LayeredGraphNode old = v.getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                // Aktualisiere die Root des Blockes
                 v.setRoot( u.getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 actions.push( (Memory mem) -> {
-                    v.setRoot( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                    v.setRoot( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
@@ -236,13 +248,15 @@ public class VerticalAligment {
             public ControlFlow runForward(Memory m) {
                 LayeredGraphNode v = m.read( "n", Visibility.LOCAL );
                 LayeredGraphNode old = v.getAlign( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                // Setze Align vom Knoten
                 v.setAlign( v.getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 actions.push( (Memory mem) -> {
-                    v.setAlign( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                    v.setAlign( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ); // Rückwärts
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
         }) );
+        // aktualisiert lokale Variable
         ifMarked.add( new PseudoCodeNode( "r = pos(neighbors[m]);", vars, tree, new SetVariable<Double>( "r" ) {
             @Override
             protected Double value(ReadOnlyMemory m) {

+ 4 - 0
src/codeline/AbstractForLoop.java

@@ -17,6 +17,10 @@ public abstract class AbstractForLoop<T> extends CodeLine {
 
     private String loopVar;
 
+    /**
+     * Erstellt eine Abstrakte Forschleife
+     * @param varName Der Name der Schleifenvariable
+     */
     public AbstractForLoop( String varName )
     {
         this.loopVar = varName;

+ 1 - 1
src/codeline/CodeLine.java

@@ -50,7 +50,7 @@ public abstract class CodeLine {
     public void runBackward( Memory m )
     {
     	if( actions.size() != 0 )
-    	    actions.pop().backward( m );
+    	    actions.pop().backward( m ); // Arbeite den Stack von Rückwärts Aktionen ab
     }
 
     /**

+ 2 - 2
src/codeline/DeclareVariable.java

@@ -43,8 +43,8 @@ public abstract class DeclareVariable <T> extends CodeLine {
 		
 		oldExists = m.isDefined( name, vis );
 		T oldVal = m.read( name, vis );
-		m.declare( name, value( m.createReadOnlyMemory() ), vis );
-		actions.push( (Memory mem) -> {
+		m.declare( name, value( m.createReadOnlyMemory() ), vis ); // deklariere die Variable je nach Sichtbarkeit im aktuellen Stack oder im Globalen Speicher
+		actions.push( (Memory mem) -> { // Rückwärts machen
 			mem.undeclare( name, vis );
             if( oldExists )
 				mem.write( name, oldVal, vis );

+ 6 - 2
src/codeline/ForEachLoop.java

@@ -19,6 +19,10 @@ public abstract class ForEachLoop <T> extends CodeLine {
 
     private String loopVar;
 	
+    /**
+     * Erstelle eine for-each Schleife
+     * @param varName Der Name der Schleifenvariable
+     */
 	public ForEachLoop( String varName )
 	{
 		this.loopVar = varName;
@@ -42,7 +46,7 @@ public abstract class ForEachLoop <T> extends CodeLine {
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
             m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", Visibility.LOCAL ) ), Visibility.LOCAL ); // set loop variable
 			actions.push( (Memory mem) -> {
-				mem.removeFrame();
+				mem.removeFrame(); // remove Loop Stack Frame
 				mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			} );
 		}
@@ -64,7 +68,7 @@ public abstract class ForEachLoop <T> extends CodeLine {
 			m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", Visibility.LOCAL ) ), Visibility.LOCAL ); // update loop variable
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
-				mem.addFrame( old );
+				mem.addFrame( old ); // restore last loop stack
 				mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 			});
 		}

+ 2 - 2
src/codeline/ForLoop.java

@@ -39,7 +39,7 @@ public abstract class ForLoop extends CodeLine {
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
             m.declare( loopVar, minimum( m.createReadOnlyMemory() ), Visibility.LOCAL ); // set loop variable
 			actions.push( (Memory mem) -> {
-				mem.removeFrame();
+				mem.removeFrame(); // remove loop stack
 				mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			} );
 		}
@@ -62,7 +62,7 @@ public abstract class ForLoop extends CodeLine {
 			m.declare( loopVar, (int)m.read( "line_" + lineId + "_index", Visibility.LOCAL ), Visibility.LOCAL ); // update loop variable
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
-				mem.addFrame( old );
+				mem.addFrame( old ); // restore last loop stack
 				mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 			});
 		}

+ 8 - 3
src/codeline/FunctionCall.java

@@ -14,6 +14,11 @@ public class FunctionCall extends CodeLine {
 	private PseudoCodeNode target;
 	private String[] params;
 	
+	/**
+	 * Erstellt einen neuen Funktionsaufruf
+	 * @param function der PseudoCode Knoten der Funktion (sollte eine FunctionDefinition CodeLine beinhalten aber das ist nicht Pflicht)
+	 * @param params Liste mit namen von Lokalen variablen, welche als Parameter übergeben werden sollen
+	 */
 	public FunctionCall( PseudoCodeNode function, String[] params )
 	{
 		this.target = function;
@@ -24,11 +29,11 @@ public class FunctionCall extends CodeLine {
 	public ControlFlow runForward(Memory m) {
 		int index = 1;
 		for( String p : params )
-		{
+		{ // Schreibe die Parameter der Funktion in die dafür vorgesehenen Globalen Register
 			m.declare( "param" + index, m.read( p, Visibility.LOCAL ), Visibility.GLOBAL );
 			index++;
 		}
-		actions.push( (Memory mem) -> {
+		actions.push( (Memory mem) -> { // Rückwärtsaktion merken
 			int ind = 1;
 			for( @SuppressWarnings("unused") String p : params )
 			{
@@ -36,7 +41,7 @@ public class FunctionCall extends CodeLine {
 				ind++;
 			}
 		} );
-		return new ControlFlow( target );
+		return new ControlFlow( target ); // Gibt ein ControlFlow Object zurück, welches dem Prozessor die Anweisung gibt zu einem Bestimmten Knoten zu springen
 	}
 
 }

+ 11 - 7
src/codeline/FunctionDefinition.java

@@ -14,6 +14,10 @@ public class FunctionDefinition extends CodeLine {
 
 	private String[] params;
 	
+	/**
+	 * Erstellt eine neue Funktion
+	 * @param params Eine Liste mit Namen von Argumenten die automatisch beim Aufruf aus den Globalen Registern in das neue Stackframe geladen werden sollen
+	 */
 	public FunctionDefinition( String[] params )
 	{
 		this.params = params;
@@ -22,19 +26,19 @@ public class FunctionDefinition extends CodeLine {
 	@Override
 	public ControlFlow runForward(Memory m) {
 		if( !m.isDefined( "line_" + lineId + "_inside", Visibility.LOCAL ) )
-		{
-			m.addFrame( new StackFrame( FrameType.FUNCTION ) );
+		{ // Funktion wurde noch nicht aufgerufen
+			m.addFrame( new StackFrame( FrameType.FUNCTION ) ); // Füge neues Stackframe hinzu
 			m.declare( "line_" + lineId + "_inside", true, Visibility.LOCAL );
 			int index = 1;
 			Object[] olds = new Object[ params.length ];
 			for( String p : params )
-			{
+			{ // Lade alle Parameter aus den Globalen Registern
 				olds[ index - 1 ] = m.read( "param" + index, Visibility.GLOBAL );
-				m.declare( p, olds[ index - 1 ], Visibility.LOCAL );
+				m.declare( p, olds[ index - 1 ], Visibility.LOCAL ); // Speichere sie im Stack
 				m.undeclare( "param" + index, Visibility.GLOBAL );
 				index++;
 			}
-			actions.push( (Memory mem) -> {
+			actions.push( (Memory mem) -> { // merkt sich die Rückwärtsaktion
 				mem.removeFrame();
 				int i = 1;
 				for( @SuppressWarnings("unused") String p : params )
@@ -43,10 +47,10 @@ public class FunctionDefinition extends CodeLine {
 					i++;
 				}
 			} );
-			return new ControlFlow( ControlFlow.STEP_INTO );
+			return new ControlFlow( ControlFlow.STEP_INTO ); // springe in die Funktion
 		}
 		else
-		{
+		{ // Funktion ist bereits follständig ausgeführt worden
 			StackFrame frame = m.removeFrame();
 			actions.push( (Memory mem) -> {
 				mem.addFrame( frame );

+ 7 - 6
src/codeline/IfLoop.java

@@ -16,26 +16,27 @@ public abstract class IfLoop extends CodeLine {
 
 	@Override
 	public ControlFlow runForward(Memory m) {
+		// Prüfe ob die Kindknoten bereits ausgeführt wurden
 		if( m.isDefined( "line_" + lineId + "_inside", Visibility.LOCAL ) )
-		{
+		{ // Wurde bereits ausgeführt
 			StackFrame old = m.removeFrame();
 			actions.push( (Memory mem) -> {
 				mem.addFrame( old );
 			} );
-            return new ControlFlow( ControlFlow.STEP_OVER );
+            return new ControlFlow( ControlFlow.STEP_OVER ); // Springe zum nachfolgenden Knoten
 		}
 		else
-		{
-            if( condition( m.createReadOnlyMemory() ) ) {
+		{ // Wurde noch nicht ausgeführt
+            if( condition( m.createReadOnlyMemory() ) ) { // Prüfe ob die Bedingung erfüllt ist
             	m.addFrame( new StackFrame( FrameType.LOOP ) );
             	m.declare( "line_" + lineId + "_inside", true, Visibility.LOCAL );
             	actions.push( (Memory mem) -> {
             		mem.removeFrame();
             	} );
-            	return new ControlFlow( ControlFlow.STEP_INTO );
+            	return new ControlFlow( ControlFlow.STEP_INTO ); // Springe in das If rein
             } else {
             	actions.push( (Memory mem) -> {} );
-                return new ControlFlow( ControlFlow.STEP_OVER );
+                return new ControlFlow( ControlFlow.STEP_OVER ); // Springe zum nachfolgenden Knoten
             }
 		}
 	}

+ 6 - 2
src/codeline/SetVariable.java

@@ -16,6 +16,10 @@ public abstract class SetVariable <T> extends CodeLine {
 
     private String name;
     
+    /**
+     * 
+     * @param name Der Name der Variable, welche verändert werden soll
+     */
     public SetVariable( String name )
     {
         this.name = name;
@@ -25,9 +29,9 @@ public abstract class SetVariable <T> extends CodeLine {
     public ControlFlow runForward(Memory m) {
         
         T oldVal = m.read( name, Visibility.LOCAL );
-        m.write( name, value( m.createReadOnlyMemory() ), Visibility.LOCAL );
+        m.write( name, value( m.createReadOnlyMemory() ), Visibility.LOCAL ); // Schreibe in die VAriable
         actions.push( (Memory mem) -> {
-            mem.write( name, oldVal, Visibility.LOCAL );
+            mem.write( name, oldVal, Visibility.LOCAL ); // Rückwärts
         });
         return new ControlFlow( ControlFlow.STEP_OVER );
     }