Browse Source

work on javadoc and restructure and rename stuff

Eren Yilmaz 6 years ago
parent
commit
2277cde2b7
40 changed files with 1031 additions and 858 deletions
  1. 6 0
      .project
  2. 18 0
      src/algorithm/Action.java
  3. 25 5
      src/algorithm/Algorithm.java
  4. 11 1
      src/algorithm/AnimationController.java
  5. 62 0
      src/algorithm/CodeLine.java
  6. 0 18
      src/animation/Action.java
  7. 0 31
      src/animation/CodeLine.java
  8. 72 58
      src/bk/BKNodePlacement.java
  9. 62 54
      src/bk/Balancing.java
  10. 68 58
      src/bk/ConflictDetection.java
  11. 57 49
      src/bk/HorizontalCompaction.java
  12. 19 13
      src/bk/LayoutType.java
  13. 58 48
      src/bk/PlaceBlock.java
  14. 85 77
      src/bk/VerticalAligment.java
  15. 39 17
      src/codelines/AbstractForLoop.java
  16. 0 74
      src/codelines/BackwardForEachLoop.java
  17. 7 3
      src/codelines/Comment.java
  18. 36 16
      src/codelines/DeclareVariable.java
  19. 20 20
      src/codelines/ForEachLoop.java
  20. 20 20
      src/codelines/ForLoop.java
  21. 7 7
      src/codelines/FunctionCall.java
  22. 12 12
      src/codelines/FunctionDefinition.java
  23. 9 9
      src/codelines/IfLoop.java
  24. 10 10
      src/codelines/SetVariable.java
  25. 10 10
      src/codelines/WhileLoop.java
  26. 24 24
      src/graph/LayeredEdge.java
  27. 1 0
      src/graph/LayeredGraphEdge.java
  28. 5 5
      src/graph/LayeredGraphNode.java
  29. 121 121
      src/graph/LayeredNode.java
  30. 5 5
      src/lib/SimpleNodePlacement.java
  31. 1 1
      src/lib/TextLayoutHelper.java
  32. 10 2
      src/processor/ControlFlow.java
  33. 79 19
      src/processor/Memory.java
  34. 5 4
      src/processor/PseudoCodeNode.java
  35. 17 17
      src/processor/PseudoCodeProcessor.java
  36. 1 1
      src/processor/StackFrame.java
  37. 41 41
      src/view/MainView.java
  38. 2 2
      src/view/NodeView.java
  39. 1 1
      src/view/PseudoCodeLines.java
  40. 5 5
      src/view/PseudoCodeRenderer.java

+ 6 - 0
.project

@@ -10,8 +10,14 @@
 			<arguments>
 			<arguments>
 			</arguments>
 			</arguments>
 		</buildCommand>
 		</buildCommand>
+		<buildCommand>
+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	</buildSpec>
 	<natures>
 	<natures>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
 	</natures>
 	</natures>
 </projectDescription>
 </projectDescription>

+ 18 - 0
src/algorithm/Action.java

@@ -0,0 +1,18 @@
+package algorithm;
+
+/**
+ * An action some kind of command that can be send to the {@link Algorithm} from the {@link AnimationController}.
+ * {@code FORWARD} tells the {@link Algorithm} to perform one more step in the layout process.
+ * {@code BACKWARD} tells the {@link Algorithm} to undo the last step in the layout process.
+ * 
+ * @author kolja
+ *
+ */
+public enum Action {
+    FORWARD,
+    FORWARD_OVER,
+    FORWARD_OUT,
+    BACKWARD,
+    BACKWARD_OVER,
+    BACKWARD_OUT
+}

+ 25 - 5
src/animation/AnimatedAlgorithm.java → src/algorithm/Algorithm.java

@@ -1,4 +1,4 @@
-package animation;
+package algorithm;
 
 
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.awt.event.ComponentListener;
@@ -7,10 +7,17 @@ import javax.swing.JFrame;
 import javax.swing.JTree;
 import javax.swing.JTree;
 import javax.swing.SwingUtilities;
 import javax.swing.SwingUtilities;
 
 
-import animation.PseudoCodeProcessor.CodeStatus;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
+import processor.PseudoCodeNode;
+import processor.PseudoCodeProcessor;
+import processor.PseudoCodeProcessor.CodeStatus;
 
 
-public abstract class AnimatedAlgorithm extends Thread {
+/**
+ * represents an algorithm that can be run by an {@link PseudoCodeProcessor}
+ * @author kolja
+ *
+ */
+public abstract class Algorithm extends Thread {
 
 
     protected AnimationController ac;
     protected AnimationController ac;
     protected LayeredGraphNode graph;
     protected LayeredGraphNode graph;
@@ -19,7 +26,13 @@ public abstract class AnimatedAlgorithm extends Thread {
     protected PseudoCodeProcessor processor;
     protected PseudoCodeProcessor processor;
     private boolean renderImage = false;
     private boolean renderImage = false;
 
 
-    public AnimatedAlgorithm( AnimationController controller, LayeredGraphNode graph, JFrame view )
+    /**
+     * creates an {@link Algorithm} and initializes its fields
+     * @param controller The controller that this algorithm is controlled by
+     * @param graph The graph that this algorithm works with
+     * @param view The view where the progress is displayed
+     */
+    public Algorithm( AnimationController controller, LayeredGraphNode graph, JFrame view )
     {
     {
         this.ac = controller;
         this.ac = controller;
         this.graph = graph;
         this.graph = graph;
@@ -38,7 +51,7 @@ public abstract class AnimatedAlgorithm extends Thread {
                     for( ComponentListener l : view.getComponentListeners() )
                     for( ComponentListener l : view.getComponentListeners() )
                     {
                     {
                         l.componentResized( new ComponentEvent(view, 0) );
                         l.componentResized( new ComponentEvent(view, 0) );
-                        synchronized( AnimatedAlgorithm.this )
+                        synchronized( Algorithm.this )
                         {
                         {
                             renderImage = true;
                             renderImage = true;
                         }
                         }
@@ -79,6 +92,9 @@ public abstract class AnimatedAlgorithm extends Thread {
                     case BACKWARD_OVER:
                     case BACKWARD_OVER:
                         status = processor.backwardStepOver();
                         status = processor.backwardStepOver();
                         break;
                         break;
+                    default:
+                        assert false;
+                        break;
                     }
                     }
                 }
                 }
                 else
                 else
@@ -102,6 +118,10 @@ public abstract class AnimatedAlgorithm extends Thread {
         return processor;
         return processor;
     }
     }
     
     
+    /**
+     * returns a string with debugging information about the current status algorithm
+     * @return some information
+     */
     public String getDebugString()
     public String getDebugString()
     {
     {
         if( processor == null )
         if( processor == null )

+ 11 - 1
src/animation/AnimationController.java → src/algorithm/AnimationController.java

@@ -1,5 +1,11 @@
-package animation;
+package algorithm;
 
 
+/**
+ * controls the execution of an {@link Algorithm}.
+ * Do not use the same controller for multiple Algorithms!
+ * @author kolja
+ *
+ */
 public class AnimationController {
 public class AnimationController {
     public static final int DEFAULT_DELAY = 100;
     public static final int DEFAULT_DELAY = 100;
 
 
@@ -9,6 +15,9 @@ public class AnimationController {
     private long delay;
     private long delay;
     private int stepOption;
     private int stepOption;
 
 
+    /**
+     * creates a new {@link AnimationController} that can be used to control an {@link Algorithm}
+     */
     public AnimationController()
     public AnimationController()
     {
     {
         stepOption = 0;
         stepOption = 0;
@@ -80,6 +89,7 @@ public class AnimationController {
     /**
     /**
      * sets the next action and wakes up one thread waiting for an answer of the controller.
      * sets the next action and wakes up one thread waiting for an answer of the controller.
      * @param a
      * @param a
+     *   the action
      */
      */
     public void setNextAction( Action a )
     public void setNextAction( Action a )
     {
     {

+ 62 - 0
src/algorithm/CodeLine.java

@@ -0,0 +1,62 @@
+package algorithm;
+
+import java.util.Stack;
+
+import processor.ControlFlow;
+import processor.Memory;
+
+/**
+ * A line of pseudo code that can be executed.
+ * @author kolja
+ *
+ */
+public abstract class CodeLine {
+    /**
+     * an action that undoes what the {@link CodeLine} did
+     * @author kolja
+     *
+     */
+	public interface BackwardAction
+	{
+		public void backward( Memory m );
+	}
+	
+	protected Stack<BackwardAction> actions;
+	protected int lineId;
+	private static int nextLineId = 0;
+	
+	/**
+	 * creates a new line of code
+	 */
+	public CodeLine()
+	{
+		synchronized( CodeLine.class ) {
+			lineId = nextLineId++;
+		}
+		actions = new Stack<BackwardAction>();
+	}
+	
+	/**
+	 * executes the line of code
+	 * @param m the memory in which the variables are
+	 * @return what should be executed next
+	 */
+    public abstract ControlFlow runForward( Memory m );
+    
+    /**
+     * undo a call of {@code runForward}
+     * @param m the memory in which the variables are
+     */
+    public void runBackward( Memory m )
+    {
+    	if( actions.size() != 0 )
+    	    actions.pop().backward( m );
+    }
+
+    /**
+     * creates an empty backwards action and pushes it to the stack
+     */
+    public void createEmptyBackwardsAction() {
+        actions.push( (Memory mem) -> {} ); // add empty reverse function
+    }
+}

+ 0 - 18
src/animation/Action.java

@@ -1,18 +0,0 @@
-package animation;
-
-/**
- * An action some kind of command that can be send to the {@link AnimatedAlgorithm} from the {@link AnimationController}.
- * {@code FORWARD} tells the {@link AnimatedAlgorithm} to perform one more step in the layout process.
- * {@code BACKWARD} tells the {@link AnimatedAlgorithm} to undo the last step in the layout process.
- * 
- * @author kolja
- *
- */
-public enum Action {
-    FORWARD,
-    FORWARD_OVER,
-    FORWARD_OUT,
-    BACKWARD,
-    BACKWARD_OVER,
-    BACKWARD_OUT
-}

+ 0 - 31
src/animation/CodeLine.java

@@ -1,31 +0,0 @@
-package animation;
-
-import java.util.Stack;
-
-public abstract class CodeLine {
-
-	protected interface BackwardAction
-	{
-		public void backward( Memory m );
-	}
-	
-	protected Stack<BackwardAction> actions;
-	protected int lineId;
-	private static int nextLineId = 0;
-	
-	public CodeLine()
-	{
-		synchronized( CodeLine.class ) {
-			lineId = nextLineId++;
-		}
-		actions = new Stack<BackwardAction>();
-	}
-	
-    public abstract ControlFlow runForward( Memory m );
-    
-    public void runBackward( Memory m )
-    {
-    	if( actions.size() != 0 )
-    	    actions.pop().backward( m );
-    }
-}

+ 72 - 58
src/bk/BKNodePlacement.java

@@ -3,15 +3,9 @@ package bk;
 import javax.swing.JFrame;
 import javax.swing.JFrame;
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.AnimatedAlgorithm;
-import animation.AnimationController;
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.PseudoCodeNode;
-import animation.PseudoCodeProcessor;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
+import algorithm.Algorithm;
+import algorithm.AnimationController;
+import algorithm.CodeLine;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.FunctionCall;
 import codelines.FunctionCall;
 import codelines.FunctionDefinition;
 import codelines.FunctionDefinition;
@@ -19,37 +13,47 @@ import codelines.Comment;
 import codelines.SetVariable;
 import codelines.SetVariable;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
 import lib.TextLayoutHelper;
 import lib.TextLayoutHelper;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.PseudoCodeProcessor;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 /**
 /**
- * The main stage of the BK node placement algorithm.
+ * The BK node placement algorithm.
  * @author kolja
  * @author kolja
  *
  *
  */
  */
-public class BKNodePlacement extends AnimatedAlgorithm {
+public class BKNodePlacement extends Algorithm {
 
 
-    public enum State
+    /**
+     * A stage of the BK node placement algorithm.
+     * @author kolja
+     *
+     */
+    public enum Stage
     {
     {
-        CONFLICTS,
-        LAYOUT1,
-        LAYOUT2,
-        LAYOUT3,
-        LAYOUT4,
+        CONFLICT_DETECTION,
+        LEFTMOST_UPPER,
+        RIGHTMOST_UPPER,
+        LEFTMOST_LOWER,
+        RIGHTMOST_LOWER,
         COMBINE
         COMBINE
     }
     }
 
 
-    private State state;
+    private Stage stage;
 
 
     public BKNodePlacement(AnimationController controller, LayeredGraphNode graph, JFrame view) {
     public BKNodePlacement(AnimationController controller, LayeredGraphNode graph, JFrame view) {
         super(controller, graph, view);
         super(controller, graph, view);
-        state = State.CONFLICTS;
+        stage = Stage.CONFLICT_DETECTION;
     }
     }
     
     
-    public State getAlgorithmState()
+    public Stage getAlgorithmState()
     {
     {
-        return state;
+        return stage;
     }
     }
 
 
-    @SuppressWarnings("serial")
     @Override
     @Override
     public PseudoCodeNode createPseudocodeTree( JTree tree )
     public PseudoCodeNode createPseudocodeTree( JTree tree )
     {
     {
@@ -59,18 +63,18 @@ public class BKNodePlacement extends AnimatedAlgorithm {
 
 
 			@Override
 			@Override
 			public ControlFlow runForward(Memory m) {
 			public ControlFlow runForward(Memory m) {
-				m.declare( "param1", graph, MemoryType.GLOBAL );
-				if( m.isDefined( "Called", MemoryType.GLOBAL ) )
+				m.declare( "param1", graph, Visibility.GLOBAL );
+				if( m.isDefined( "Called", Visibility.GLOBAL ) )
 				{
 				{
 					actions.push( (Memory mem) -> {
 					actions.push( (Memory mem) -> {
-					    m.undeclare( "param1", MemoryType.GLOBAL );
+					    m.undeclare( "param1", Visibility.GLOBAL );
 					} );
 					} );
 					return new ControlFlow( ControlFlow.STEP_OVER );
 					return new ControlFlow( ControlFlow.STEP_OVER );
 				}
 				}
-				m.declare( "Called", true, MemoryType.GLOBAL );
+				m.declare( "Called", true, Visibility.GLOBAL );
 				actions.push( (Memory mem) -> {
 				actions.push( (Memory mem) -> {
-                    m.undeclare( "param1", MemoryType.GLOBAL );
-	                m.undeclare( "Called", MemoryType.GLOBAL );
+                    m.undeclare( "param1", Visibility.GLOBAL );
+	                m.undeclare( "Called", Visibility.GLOBAL );
 				} );
 				} );
 				return new ControlFlow( mainFunction );
 				return new ControlFlow( mainFunction );
 			}
 			}
@@ -80,75 +84,83 @@ public class BKNodePlacement extends AnimatedAlgorithm {
 
 
         PseudoCodeNode conflictDetectionFunction = ConflictDetection.mark_conflicts( tree );
         PseudoCodeNode conflictDetectionFunction = ConflictDetection.mark_conflicts( tree );
         PseudoCodeNode calcLayout = new PseudoCodeNode( "function calcLayout( layout, graph )", vars, tree, new FunctionDefinition( vars ) );
         PseudoCodeNode calcLayout = new PseudoCodeNode( "function calcLayout( layout, graph )", vars, tree, new FunctionDefinition( vars ) );
-        PseudoCodeNode combine = Combine.combine( tree );
+        PseudoCodeNode combine = Balancing.combine( tree );
         root.add( mainFunction );
         root.add( mainFunction );
         mainFunction.add( new PseudoCodeNode( "call detectConflicts( graph )", vars, tree, new FunctionCall( conflictDetectionFunction, new String[]{ "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call detectConflicts( graph )", vars, tree, new FunctionCall( conflictDetectionFunction, new String[]{ "graph" } ) ) );
-        mainFunction.add( new PseudoCodeNode( "layout = 'DOWN_RIGHT'", vars, tree, new DeclareVariable<String>( "layout" ) {
+        mainFunction.add( new PseudoCodeNode( "layout = 'RIGHTMOST_LOWER'", vars, tree, new DeclareVariable<String>( "layout" ) {
             @Override
             @Override
             protected String value(ReadOnlyMemory m) {
             protected String value(ReadOnlyMemory m) {
-                return "DOWN_RIGHT";
+                return "RIGHTMOST_LOWER";
             }
             }
         }) );
         }) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
-        mainFunction.add( new PseudoCodeNode( "layout = 'DOWN_LEFT'", vars, tree, new SetVariable<String>( "layout" ) {
+        mainFunction.add( new PseudoCodeNode( "layout = 'LEFTMOST_LOWER'", vars, tree, new SetVariable<String>( "layout" ) {
             @Override
             @Override
             protected String value(ReadOnlyMemory m) {
             protected String value(ReadOnlyMemory m) {
-                return "DOWN_LEFT";
+                return "LEFTMOST_LOWER";
             }
             }
         }));
         }));
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
-        mainFunction.add( new PseudoCodeNode( "layout = 'UP_RIGHT'", vars, tree, new SetVariable<String>( "layout" ) {
+        mainFunction.add( new PseudoCodeNode( "layout = 'RIGHTMOST_UPPER'", vars, tree, new SetVariable<String>( "layout" ) {
             @Override
             @Override
             protected String value(ReadOnlyMemory m) {
             protected String value(ReadOnlyMemory m) {
-                return "UP_RIGHT";
+                return "RIGHTMOST_UPPER";
             }
             }
         }) );
         }) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
-        mainFunction.add( new PseudoCodeNode( "layout = 'UP_LEFT'", vars, tree, new SetVariable<String>( "layout" ) {
+        mainFunction.add( new PseudoCodeNode( "layout = 'LEFTMOST_UPPER'", vars, tree, new SetVariable<String>( "layout" ) {
             @Override
             @Override
             protected String value(ReadOnlyMemory m) {
             protected String value(ReadOnlyMemory m) {
-                return "UP_LEFT";
+                return "LEFTMOST_UPPER";
             }
             }
         }) );
         }) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call calcLayout( layout, graph )", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "graph" } ) ) );
         mainFunction.add( new PseudoCodeNode( "call combine( graph )", vars, tree, new FunctionCall( combine, new String[]{ "graph" } ) ) );
         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() ) {
         PseudoCodeNode conflictsStage = new PseudoCodeNode( "-- mark type 1 conflicts --", vars, tree, new Comment() ) {
+            private static final long serialVersionUID = 1041941539437672704L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m ) {
             public String getDebugOutput( Memory m ) {
-                state = State.CONFLICTS;
+                stage = Stage.CONFLICT_DETECTION;
                 return ConflictDetection.buildDebugString( m );
                 return ConflictDetection.buildDebugString( m );
             }
             }
         };
         };
         root.add( conflictsStage );
         root.add( conflictsStage );
         conflictsStage.add( conflictDetectionFunction );
         conflictsStage.add( conflictDetectionFunction );
-        PseudoCodeNode blockCalc = BlockCalc.calculateBlockGraph( tree, calcLayout );
+        PseudoCodeNode blockCalc = VerticalAligment.calculateBlockGraph( tree, calcLayout );
         PseudoCodeNode placeBlock = PlaceBlock.place_block( tree );
         PseudoCodeNode placeBlock = PlaceBlock.place_block( tree );
-        PseudoCodeNode horizontalCompaction = Compaction.horizontalCompaction( tree, placeBlock );
+        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 calculateBlockGraph( layout, graph )", vars, tree, new FunctionCall( blockCalc, vars ) ) );
         calcLayout.add( new PseudoCodeNode( "call horizontalCompaction( layout, graph )", vars, tree, new FunctionCall( horizontalCompaction, vars ) ) );
         calcLayout.add( new PseudoCodeNode( "call horizontalCompaction( layout, graph )", vars, tree, new FunctionCall( horizontalCompaction, vars ) ) );
         PseudoCodeNode extremalLayoutStage = new PseudoCodeNode( "-- Compute an extremal layout --", vars, tree, new Comment() ) {
         PseudoCodeNode extremalLayoutStage = new PseudoCodeNode( "-- Compute an extremal layout --", vars, tree, new Comment() ) {
+            private static final long serialVersionUID = 4141215748809071958L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m ) {
             public String getDebugOutput( Memory m ) {
-                if( !m.isSomewhereDefined( "graph", MemoryType.COMPLETE_STACK ) || !m.isSomewhereDefined( "layout", MemoryType.COMPLETE_STACK ) )
+                if( !m.isSomewhereDefined( "graph", Visibility.COMPLETE_STACK ) || !m.isSomewhereDefined( "layout", Visibility.COMPLETE_STACK ) )
                     return "";
                     return "";
                 String info = "| Node | Shift | Sink | Root | Align |  x  |  xDef  |\n";
                 String info = "| Node | Shift | Sink | Root | Align |  x  |  xDef  |\n";
                 info +=       "|------|-------|------|------|-------|-----|--------|\n";
                 info +=       "|------|-------|------|------|-------|-----|--------|\n";
-                LayeredGraphNode graph = m.read( "graph", MemoryType.COMPLETE_STACK );
-                LayoutType type = LayoutType.fromString( m.read( "layout", MemoryType.COMPLETE_STACK ) );
+                LayeredGraphNode graph = m.read( "graph", Visibility.COMPLETE_STACK );
+                LayoutType type = LayoutType.fromString( m.read( "layout", Visibility.COMPLETE_STACK ) );
                 switch( type ) {
                 switch( type ) {
-                case TOP_BOTTOM_LEFT:
-                    state = State.LAYOUT1;
+                case LEFTMOST_UPPER:
+                    stage = Stage.LEFTMOST_UPPER;
                     break;
                     break;
-                case TOP_BOTTOM_RIGHT:
-                    state = State.LAYOUT2;
+                case RIGHTMOST_UPPER:
+                    stage = Stage.RIGHTMOST_UPPER;
                     break;
                     break;
-                case BOTTOM_TOP_LEFT:
-                    state = State.LAYOUT3;
+                case LEFTMOST_LOWER:
+                    stage = Stage.LEFTMOST_LOWER;
                     break;
                     break;
-                case BOTTOM_TOP_RIGHT:
-                    state = State.LAYOUT4;
+                case RIGHTMOST_LOWER:
+                    stage = Stage.RIGHTMOST_LOWER;
                     break;
                     break;
                 case COMBINED: // this will never happen here
                 case COMBINED: // this will never happen here
+                    assert false;
+                    break;
+                default:
+                    assert false;
                     break;
                     break;
                 }
                 }
                 for( LayeredGraphNode n : graph.getContainedNodes() )
                 for( LayeredGraphNode n : graph.getContainedNodes() )
@@ -172,21 +184,23 @@ public class BKNodePlacement extends AnimatedAlgorithm {
         extremalLayoutStage.add( horizontalCompaction );
         extremalLayoutStage.add( horizontalCompaction );
         extremalLayoutStage.add( placeBlock );
         extremalLayoutStage.add( placeBlock );
         PseudoCodeNode balancingStage = new PseudoCodeNode( "-- balancing --", vars, tree, new Comment() ) {
         PseudoCodeNode balancingStage = new PseudoCodeNode( "-- balancing --", vars, tree, new Comment() ) {
+            private static final long serialVersionUID = 4212377075998840086L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m ) {
             public String getDebugOutput( Memory m ) {
-                state = State.COMBINE;
-                if( !m.isSomewhereDefined( "graph", MemoryType.COMPLETE_STACK ) )
+                stage = Stage.COMBINE;
+                if( !m.isSomewhereDefined( "graph", Visibility.COMPLETE_STACK ) )
                     return "";
                     return "";
                 String info = "| Node | x BR | x BL | x UR | x UL | x CO |\n";
                 String info = "| Node | x BR | x BL | x UR | x UL | x CO |\n";
                 info +=       "|------|------|------|------|------|------|\n";
                 info +=       "|------|------|------|------|------|------|\n";
-                LayeredGraphNode graph = m.read( "graph", MemoryType.COMPLETE_STACK );
+                LayeredGraphNode graph = m.read( "graph", Visibility.COMPLETE_STACK );
                 for( LayeredGraphNode n : graph.getContainedNodes() )
                 for( LayeredGraphNode n : graph.getContainedNodes() )
                 {
                 {
                     info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
                     info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 6 ) +
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 6 ) +
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 6 ) +
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.LEFTMOST_UPPER ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.RIGHTMOST_UPPER ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.LEFTMOST_LOWER ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.RIGHTMOST_LOWER ) + "", 6 ) +
                             "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.COMBINED ) + "", 6 ) + "|\n";
                             "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.COMBINED ) + "", 6 ) + "|\n";
                 }
                 }
                 return info;
                 return info;

+ 62 - 54
src/bk/Combine.java → src/bk/Balancing.java

@@ -7,12 +7,7 @@ import java.util.List;
 
 
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.PseudoCodeNode;
+import algorithm.CodeLine;
 import codelines.Comment;
 import codelines.Comment;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.ForEachLoop;
 import codelines.ForEachLoop;
@@ -21,30 +16,43 @@ import codelines.FunctionDefinition;
 import codelines.IfLoop;
 import codelines.IfLoop;
 import codelines.SetVariable;
 import codelines.SetVariable;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 /**
 /**
  * The stage of the combination of the four extremal layouts.
  * The stage of the combination of the four extremal layouts.
  * @author kolja
  * @author kolja
  *
  *
  */
  */
-public class Combine {
+public class Balancing {
 
 
+
+    /**
+     * creates the pseudo code for the balancing stage
+     * @param tree the tree where the code will be displayed
+     * @return the code
+     */
     public static PseudoCodeNode combine( JTree tree ) {
     public static PseudoCodeNode combine( JTree tree ) {
         String[] vars = { "graph", "l", "l_min", "v", "positions" };
         String[] vars = { "graph", "l", "l_min", "v", "positions" };
-        @SuppressWarnings("serial")
+
         PseudoCodeNode root = new PseudoCodeNode( "function combine( graph )", vars, tree, new FunctionDefinition( new String[]{ "graph" } ) ){
         PseudoCodeNode root = new PseudoCodeNode( "function combine( graph )", vars, tree, new FunctionDefinition( new String[]{ "graph" } ) ){
+            private static final long serialVersionUID = -3067185213650162055L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m )
             public String getDebugOutput( Memory m )
             {
             {
-                if( m.isSomewhereDefined( "v", MemoryType.LOCAL ) )
-                    m.<LayeredGraphNode>read( "v", MemoryType.LOCAL).setSelected( null );
+                if( m.isSomewhereDefined( "v", Visibility.LOCAL ) )
+                    m.<LayeredGraphNode>read( "v", Visibility.LOCAL).setSelected( null );
                 return super.getDebugOutput( m );
                 return super.getDebugOutput( m );
             }
             }
         };
         };
         root.add( new PseudoCodeNode( "-- Call combine of subgraphs --", vars, tree, new CodeLine() {
         root.add( new PseudoCodeNode( "-- Call combine of subgraphs --", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode graph = m.read( "graph", MemoryType.LOCAL );
+                LayeredGraphNode graph = m.read( "graph", Visibility.LOCAL );
                 if( graph.parent() == null )
                 if( graph.parent() == null )
                     graph.setColor( Color.BLACK, null );
                     graph.setColor( Color.BLACK, null );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
@@ -57,27 +65,27 @@ public class Combine {
         PseudoCodeNode recursiveLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
         PseudoCodeNode recursiveLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedNodes();
+                return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedNodes();
             }
             }
         });
         });
         root.add( recursiveLoop );
         root.add( recursiveLoop );
         PseudoCodeNode ifNode = new PseudoCodeNode( "if v has subgraph then", vars, tree, new IfLoop() {
         PseudoCodeNode ifNode = new PseudoCodeNode( "if v has subgraph then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getContainedNodes().size() > 0;
+                return m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getContainedNodes().size() > 0;
             }
             }
         } );
         } );
         recursiveLoop.add( ifNode );
         recursiveLoop.add( ifNode );
         ifNode.add( new PseudoCodeNode( "call combine( v );", vars, tree, new FunctionCall( root, new String[]{ "v" } ) ) );
         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()));
         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" ) {
+        PseudoCodeNode firstLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             @Override
             protected List<String> list(ReadOnlyMemory m) {
             protected List<String> list(ReadOnlyMemory m) {
                 ArrayList< String > list = new ArrayList<String>();
                 ArrayList< String > list = new ArrayList<String>();
-                list.add( "DOWN_RIGHT" );
-                list.add( "DOWN_LEFT" );
-                list.add( "UP_RIGHT" );
-                list.add( "UP_LEFT" );
+                list.add( "RIGHTMOST_LOWER" );
+                list.add( "LEFTMOST_LOWER" );
+                list.add( "RIGHTMOST_UPPER" );
+                list.add( "LEFTMOST_UPPER" );
                 return list;
                 return list;
             }
             }
         });
         });
@@ -85,10 +93,10 @@ public class Combine {
         firstLoop.add( new PseudoCodeNode( "min[l] = minimum x coordinate in l;", vars, tree, new CodeLine() {
         firstLoop.add( new PseudoCodeNode( "min[l] = minimum x coordinate in l;", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String layout = m.read( "l", MemoryType.LOCAL );
-                m.declare( "min[" + layout + "]", calcMinX( m.read( "graph", MemoryType.LOCAL ), LayoutType.fromString( layout ) ), MemoryType.GLOBAL );
+                String layout = m.read( "l", Visibility.LOCAL );
+                m.declare( "min[" + layout + "]", calcMinX( m.read( "graph", Visibility.LOCAL ), LayoutType.fromString( layout ) ), Visibility.GLOBAL );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
-                    mem.undeclare( "min[" + layout + "]", MemoryType.GLOBAL );
+                    mem.undeclare( "min[" + layout + "]", Visibility.GLOBAL );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -96,10 +104,10 @@ public class Combine {
         firstLoop.add( new PseudoCodeNode( "max[l] = maximum x coordinate in l;", vars, tree, new CodeLine() {
         firstLoop.add( new PseudoCodeNode( "max[l] = maximum x coordinate in l;", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String layout = m.read( "l", MemoryType.LOCAL );
-                m.declare( "max[" + layout + "]", calcMaxX( m.read( "graph", MemoryType.LOCAL ), LayoutType.fromString( layout ) ), MemoryType.GLOBAL );
+                String layout = m.read( "l", Visibility.LOCAL );
+                m.declare( "max[" + layout + "]", calcMaxX( m.read( "graph", Visibility.LOCAL ), LayoutType.fromString( layout ) ), Visibility.GLOBAL );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
-                    mem.undeclare( "max[" + layout + "]", MemoryType.GLOBAL );
+                    mem.undeclare( "max[" + layout + "]", Visibility.GLOBAL );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -107,10 +115,10 @@ public class Combine {
         firstLoop.add( new PseudoCodeNode( "width[l] = max[l] - min[l];", vars, tree, new CodeLine() {
         firstLoop.add( new PseudoCodeNode( "width[l] = max[l] - min[l];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String layout = m.read( "l", MemoryType.LOCAL );
-                m.declare( "width[" + layout + "]", m.<Integer>read( "max[" + layout + "]", MemoryType.GLOBAL ) - m.<Integer>read( "min[" + layout + "]", MemoryType.GLOBAL ), MemoryType.GLOBAL );
+                String layout = m.read( "l", Visibility.LOCAL );
+                m.declare( "width[" + layout + "]", m.<Integer>read( "max[" + layout + "]", Visibility.GLOBAL ) - m.<Integer>read( "min[" + layout + "]", Visibility.GLOBAL ), Visibility.GLOBAL );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
-                    mem.undeclare( "width[" + layout + "]", MemoryType.GLOBAL );
+                    mem.undeclare( "width[" + layout + "]", Visibility.GLOBAL );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -118,27 +126,27 @@ public class Combine {
         root.add( new PseudoCodeNode( "l_min = l with width[l] == min(width);", vars, tree, new DeclareVariable<String>( "l_min" ) {
         root.add( new PseudoCodeNode( "l_min = l with width[l] == min(width);", vars, tree, new DeclareVariable<String>( "l_min" ) {
             @Override
             @Override
             protected String value(ReadOnlyMemory m) {
             protected String value(ReadOnlyMemory m) {
-                String min = "DOWN_RIGHT";
-                int minW = m.read( "width[DOWN_RIGHT]", MemoryType.GLOBAL );
-                for( String l : new String[]{ "DOWN_LEFT", "UP_RIGHT", "UP_LEFT" } )
+                String min = "RIGHTMOST_LOWER";
+                int minW = m.read( "width[RIGHTMOST_LOWER]", Visibility.GLOBAL );
+                for( String l : new String[]{ "LEFTMOST_LOWER", "RIGHTMOST_UPPER", "LEFTMOST_UPPER" } )
                 {
                 {
-                    if( minW > m.<Integer>read( "width[" + l + "]", MemoryType.GLOBAL ) )
+                    if( minW > m.<Integer>read( "width[" + l + "]", Visibility.GLOBAL ) )
                     {
                     {
-                        minW = m.<Integer>read( "width[" + l + "]", MemoryType.GLOBAL );
+                        minW = m.<Integer>read( "width[" + l + "]", Visibility.GLOBAL );
                         min = l;
                         min = l;
                     }
                     }
                 }
                 }
                 return min;
                 return min;
             }
             }
         }));
         }));
-        PseudoCodeNode secondLoop = new PseudoCodeNode( "foreach l in ['DOWN_RIGHT', 'DOWN_LEFT', 'UP_RIGHT', 'UP_LEFT'] do", vars, tree, new ForEachLoop<String>( "l" ) {
+        PseudoCodeNode secondLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             @Override
             protected List<String> list(ReadOnlyMemory m) {
             protected List<String> list(ReadOnlyMemory m) {
                 ArrayList< String > list = new ArrayList<String>();
                 ArrayList< String > list = new ArrayList<String>();
-                list.add( "DOWN_RIGHT" );
-                list.add( "DOWN_LEFT" );
-                list.add( "UP_RIGHT" );
-                list.add( "UP_LEFT" );
+                list.add( "RIGHTMOST_LOWER" );
+                list.add( "LEFTMOST_LOWER" );
+                list.add( "RIGHTMOST_UPPER" );
+                list.add( "LEFTMOST_UPPER" );
                 return list;
                 return list;
             }
             }
         });
         });
@@ -146,14 +154,14 @@ public class Combine {
         secondLoop.add( new PseudoCodeNode( "shift[l] = l.contains('RIGHT') ? min[l_min] - min[l] : max[l_min] - max[l];", vars, tree, new CodeLine() {
         secondLoop.add( new PseudoCodeNode( "shift[l] = l.contains('RIGHT') ? min[l_min] - min[l] : max[l_min] - max[l];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String layout = m.read( "l", MemoryType.LOCAL );
-                String lMin = m.read( "l_min", MemoryType.LOCAL );
+                String layout = m.read( "l", Visibility.LOCAL );
+                String lMin = m.read( "l_min", Visibility.LOCAL );
                 if( layout.contains( "RIGHT" ) )
                 if( layout.contains( "RIGHT" ) )
-                    m.declare( "shift[" + layout + "]", m.<Integer>read( "min[" + lMin + "]", MemoryType.GLOBAL ) - m.<Integer>read( "min[" + layout + "]", MemoryType.GLOBAL ), MemoryType.GLOBAL );
+                    m.declare( "shift[" + layout + "]", m.<Integer>read( "min[" + lMin + "]", Visibility.GLOBAL ) - m.<Integer>read( "min[" + layout + "]", Visibility.GLOBAL ), Visibility.GLOBAL );
                 else
                 else
-                    m.declare( "shift[" + layout + "]", m.<Integer>read( "max[" + lMin + "]", MemoryType.GLOBAL ) - m.<Integer>read( "max[" + layout + "]", MemoryType.GLOBAL ), MemoryType.GLOBAL );
+                    m.declare( "shift[" + layout + "]", m.<Integer>read( "max[" + lMin + "]", Visibility.GLOBAL ) - m.<Integer>read( "max[" + layout + "]", Visibility.GLOBAL ), Visibility.GLOBAL );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
-                    mem.undeclare( "shift[" + layout + "]", MemoryType.GLOBAL );
+                    mem.undeclare( "shift[" + layout + "]", Visibility.GLOBAL );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -161,7 +169,7 @@ public class Combine {
         PseudoCodeNode thirdLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
         PseudoCodeNode thirdLoop = new PseudoCodeNode( "foreach v in graph do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedNodes();
+                return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedNodes();
             }
             }
         });
         });
         root.add( thirdLoop );
         root.add( thirdLoop );
@@ -171,23 +179,23 @@ public class Combine {
                 return new ArrayList<Integer>();
                 return new ArrayList<Integer>();
             }
             }
         }));
         }));
-        PseudoCodeNode innerLoop = new PseudoCodeNode( "foreach l in ['DOWN_RIGHT', 'DOWN_LEFT', 'UP_RIGHT', 'UP_LEFT'] do", vars, tree, new ForEachLoop<String>( "l" ) {
+        PseudoCodeNode innerLoop = new PseudoCodeNode( "foreach l in ['RIGHTMOST_LOWER', 'LEFTMOST_LOWER', 'RIGHTMOST_UPPER', 'LEFTMOST_UPPER'] do", vars, tree, new ForEachLoop<String>( "l" ) {
             @Override
             @Override
             protected List<String> list(ReadOnlyMemory m) {
             protected List<String> list(ReadOnlyMemory m) {
                 ArrayList< String > list = new ArrayList<String>();
                 ArrayList< String > list = new ArrayList<String>();
-                list.add( "DOWN_RIGHT" );
-                list.add( "DOWN_LEFT" );
-                list.add( "UP_RIGHT" );
-                list.add( "UP_LEFT" );
+                list.add( "RIGHTMOST_LOWER" );
+                list.add( "LEFTMOST_LOWER" );
+                list.add( "RIGHTMOST_UPPER" );
+                list.add( "LEFTMOST_UPPER" );
                 return list;
                 return list;
             }
             }
         });
         });
         innerLoop.add( new PseudoCodeNode( "positions.add(x[v] in l);", vars, tree, new CodeLine() {
         innerLoop.add( new PseudoCodeNode( "positions.add(x[v] in l);", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String layout = m.read( "l", MemoryType.LOCAL );
-                ArrayList<Integer> positions = m.read( "positions", MemoryType.LOCAL );
-                positions.add( (int)m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getX( LayoutType.fromString( layout ) ) + m.<Integer>read( "shift[" + layout + "]", MemoryType.GLOBAL ) );
+                String layout = m.read( "l", Visibility.LOCAL );
+                ArrayList<Integer> positions = m.read( "positions", Visibility.LOCAL );
+                positions.add( (int)m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getX( LayoutType.fromString( layout ) ) + m.<Integer>read( "shift[" + layout + "]", Visibility.GLOBAL ) );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {
                     positions.remove( positions.size() - 1 );
                     positions.remove( positions.size() - 1 );
                 });
                 });
@@ -198,7 +206,7 @@ public class Combine {
         thirdLoop.add( new PseudoCodeNode( "positions = sort( positions );", vars, tree, new SetVariable<ArrayList<Integer>>( "positions" ) {
         thirdLoop.add( new PseudoCodeNode( "positions = sort( positions );", vars, tree, new SetVariable<ArrayList<Integer>>( "positions" ) {
             @Override
             @Override
             public ArrayList<Integer> value(ReadOnlyMemory m) {
             public ArrayList<Integer> value(ReadOnlyMemory m) {
-                ArrayList<Integer> positions = m.read( "positions", MemoryType.LOCAL );
+                ArrayList<Integer> positions = m.read( "positions", Visibility.LOCAL );
                 ArrayList<Integer> neu = new ArrayList<Integer>();
                 ArrayList<Integer> neu = new ArrayList<Integer>();
                 for( int p : positions )
                 for( int p : positions )
                     neu.add( p );
                     neu.add( p );
@@ -209,8 +217,8 @@ public class Combine {
         thirdLoop.add( new PseudoCodeNode( "x[v] = (positions[1]+positions[2]) / 2;", vars, tree, new CodeLine() {
         thirdLoop.add( new PseudoCodeNode( "x[v] = (positions[1]+positions[2]) / 2;", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                ArrayList<Integer> positions = m.read( "positions", MemoryType.LOCAL );
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
+                ArrayList<Integer> positions = m.read( "positions", Visibility.LOCAL );
+                LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
                 double old = v.getX( LayoutType.COMBINED );
                 double old = v.getX( LayoutType.COMBINED );
                 v.setX( (positions.get( 1 ) + positions.get( 2 )) / 2.0, true, LayoutType.COMBINED );
                 v.setX( (positions.get( 1 ) + positions.get( 2 )) / 2.0, true, LayoutType.COMBINED );
                 actions.add( (Memory mem) -> {
                 actions.add( (Memory mem) -> {

+ 68 - 58
src/bk/ConflictDetection.java

@@ -5,12 +5,7 @@ import java.util.List;
 
 
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.PseudoCodeNode;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
+import algorithm.CodeLine;
 import bk.LayoutType;
 import bk.LayoutType;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.ForEachLoop;
 import codelines.ForEachLoop;
@@ -24,6 +19,11 @@ import codelines.WhileLoop;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
 import lib.TextLayoutHelper;
 import lib.TextLayoutHelper;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 /**
 /**
  * the preprocessing stage of the bk node placement algorithm
  * the preprocessing stage of the bk node placement algorithm
@@ -33,29 +33,34 @@ import lib.TextLayoutHelper;
  */
  */
 public class ConflictDetection {
 public class ConflictDetection {
     
     
+    /**
+     * return a debug string containing a table of variables and their values
+     * @param m the memory which contains the variables
+     * @return the table
+     */
     public static String buildDebugString( Memory m ) {
     public static String buildDebugString( Memory m ) {
-        if( m.isSomewhereDefined( "l", MemoryType.LOCAL ) && m.isSomewhereDefined( "i", MemoryType.LOCAL ) && 
-                m.<Integer>read( "l", MemoryType.LOCAL ) < m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 ).size() )
-            m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.<Integer>read( "i", MemoryType.LOCAL ) + 1).get(m.<Integer>read( "l", MemoryType.LOCAL )).setSelected(null);
+        if( m.isSomewhereDefined( "l", Visibility.LOCAL ) && m.isSomewhereDefined( "i", Visibility.LOCAL ) && 
+                m.<Integer>read( "l", Visibility.LOCAL ) < m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 ).size() )
+            m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.<Integer>read( "i", Visibility.LOCAL ) + 1).get(m.<Integer>read( "l", Visibility.LOCAL )).setSelected(null);
         
         
-        if( m.isSomewhereDefined( "i", MemoryType.LOCAL ) && m.isSomewhereDefined( "l1", MemoryType.LOCAL ) &&
-                m.<Integer>read( "l1", MemoryType.LOCAL ) < m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.<Integer>read( "i", MemoryType.LOCAL ) + 1).size() ) {
-            m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.<Integer>read( "i", MemoryType.LOCAL ) + 1).get(m.<Integer>read( "l1", MemoryType.LOCAL )).setSelected(null);
+        if( m.isSomewhereDefined( "i", Visibility.LOCAL ) && m.isSomewhereDefined( "l1", Visibility.LOCAL ) &&
+                m.<Integer>read( "l1", Visibility.LOCAL ) < m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.<Integer>read( "i", Visibility.LOCAL ) + 1).size() ) {
+            m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.<Integer>read( "i", Visibility.LOCAL ) + 1).get(m.<Integer>read( "l1", Visibility.LOCAL )).setSelected(null);
         }
         }
         
         
-        if( m.isSomewhereDefined( "i", MemoryType.LOCAL ) && m.isSomewhereDefined( "k0", MemoryType.LOCAL ) && 
-                m.<Integer>read( "k0", MemoryType.LOCAL ) <  m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.read( "i", MemoryType.LOCAL )).size()) {
-            m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.read( "i", MemoryType.LOCAL )).get(m.<Integer>read( "k0", MemoryType.LOCAL )).setSelected(null);
+        if( m.isSomewhereDefined( "i", Visibility.LOCAL ) && m.isSomewhereDefined( "k0", Visibility.LOCAL ) && 
+                m.<Integer>read( "k0", Visibility.LOCAL ) <  m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.read( "i", Visibility.LOCAL )).size()) {
+            m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.read( "i", Visibility.LOCAL )).get(m.<Integer>read( "k0", Visibility.LOCAL )).setSelected(null);
         }
         }
         
         
-        if( m.isSomewhereDefined( "i", MemoryType.LOCAL ) && m.isSomewhereDefined( "k1", MemoryType.LOCAL ) && 
-                m.<Integer>read( "k1", MemoryType.LOCAL ) < m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.read( "i", MemoryType.LOCAL )).size() ) {
-            m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL).getContainedLayers().get(m.read( "i", MemoryType.LOCAL )).get(m.<Integer>read( "k1", MemoryType.LOCAL )).setSelected(null);
+        if( m.isSomewhereDefined( "i", Visibility.LOCAL ) && m.isSomewhereDefined( "k1", Visibility.LOCAL ) && 
+                m.<Integer>read( "k1", Visibility.LOCAL ) < m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.read( "i", Visibility.LOCAL )).size() ) {
+            m.<LayeredGraphNode>read( "graph", Visibility.LOCAL).getContainedLayers().get(m.read( "i", Visibility.LOCAL )).get(m.<Integer>read( "k1", Visibility.LOCAL )).setSelected(null);
         }
         }
         
         
-        if( m.isSomewhereDefined( "n", MemoryType.LOCAL ) )
+        if( m.isSomewhereDefined( "n", Visibility.LOCAL ) )
         {
         {
-            m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).setSelected( null );
+            m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).setSelected( null );
         }
         }
         String info = "| i  | l  | l1 | k0 | k1 |  v  |  n  |\n";
         String info = "| i  | l  | l1 | k0 | k1 |  v  |  n  |\n";
         info +=       "|----|----|----|----|----|-----|-----|\n";
         info +=       "|----|----|----|----|----|-----|-----|\n";
@@ -66,20 +71,20 @@ public class ConflictDetection {
         String k1 = "null";
         String k1 = "null";
         String v = "null";
         String v = "null";
         String n = "null";
         String n = "null";
-        if( m.isSomewhereDefined( "i", MemoryType.LOCAL ) )
-            i = "" + m.<Integer>read( "i", MemoryType.LOCAL );
-        if( m.isSomewhereDefined( "l", MemoryType.LOCAL ) )
-            l = "" + m.<Integer>read( "l", MemoryType.LOCAL );
-        if( m.isSomewhereDefined( "l1", MemoryType.LOCAL ) )
-            l1 = "" + m.<Integer>read( "l1", MemoryType.LOCAL );
-        if( m.isSomewhereDefined( "k0", MemoryType.LOCAL ) )
-            k0 = "" + m.<Integer>read( "k0", MemoryType.LOCAL );
-        if( m.isSomewhereDefined( "k1", MemoryType.LOCAL ) )
-            k1 = "" + m.<Integer>read( "k1", MemoryType.LOCAL );
-        if( m.isSomewhereDefined( "v", MemoryType.LOCAL ) && m.<LayeredGraphEdge>read( "v", MemoryType.LOCAL ).getSources().get( 0 ).getName() != null )
-            v = "" + m.<LayeredGraphEdge>read( "v", MemoryType.LOCAL ).getSources().get( 0 ).getName();
-        if( m.isSomewhereDefined( "n", MemoryType.LOCAL ) && m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getName() != null )
-            n = "" + m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getName();
+        if( m.isSomewhereDefined( "i", Visibility.LOCAL ) )
+            i = "" + m.<Integer>read( "i", Visibility.LOCAL );
+        if( m.isSomewhereDefined( "l", Visibility.LOCAL ) )
+            l = "" + m.<Integer>read( "l", Visibility.LOCAL );
+        if( m.isSomewhereDefined( "l1", Visibility.LOCAL ) )
+            l1 = "" + m.<Integer>read( "l1", Visibility.LOCAL );
+        if( m.isSomewhereDefined( "k0", Visibility.LOCAL ) )
+            k0 = "" + m.<Integer>read( "k0", Visibility.LOCAL );
+        if( m.isSomewhereDefined( "k1", Visibility.LOCAL ) )
+            k1 = "" + m.<Integer>read( "k1", Visibility.LOCAL );
+        if( m.isSomewhereDefined( "v", Visibility.LOCAL ) && m.<LayeredGraphEdge>read( "v", Visibility.LOCAL ).getSources().get( 0 ).getName() != null )
+            v = "" + m.<LayeredGraphEdge>read( "v", Visibility.LOCAL ).getSources().get( 0 ).getName();
+        if( m.isSomewhereDefined( "n", Visibility.LOCAL ) && m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getName() != null )
+            n = "" + m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getName();
         info += "|" + TextLayoutHelper.strToLen( i, 4 ) + 
         info += "|" + TextLayoutHelper.strToLen( i, 4 ) + 
                 "|" + TextLayoutHelper.strToLen( l, 4 ) + 
                 "|" + TextLayoutHelper.strToLen( l, 4 ) + 
                 "|" + TextLayoutHelper.strToLen( l1, 4 ) + 
                 "|" + TextLayoutHelper.strToLen( l1, 4 ) + 
@@ -90,23 +95,28 @@ public class ConflictDetection {
         return info;
         return info;
     }
     }
     
     
+    /**
+     * creates the pseudo code for the conflict detection stage
+     * @param tree the tree where the code will be displayed
+     * @return the code
+     */
     public static PseudoCodeNode mark_conflicts(JTree tree) {
     public static PseudoCodeNode mark_conflicts(JTree tree) {
-        String vars[] = { "i", "L", "k0", "l", "l1", "k1", "v", "graph", "n" };
-        String params[] = { "graph" };
+        String[] vars = { "i", "L", "k0", "l", "l1", "k1", "v", "graph", "n" };
+        String[] params = { "graph" };
         PseudoCodeNode root = new PseudoCodeNode( "function mark_conflicts( graph )", vars, tree, new FunctionDefinition( params ) );
         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() );
         PseudoCodeNode text = new PseudoCodeNode( "-- mark conflicts in subgraphs --", vars, tree, new Comment() );
         root.add( text );
         root.add( text );
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach n in graph.getContainedNodes() do", vars, tree, new ForEachLoop<LayeredGraphNode>( "n" ) {
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach n in graph.getContainedNodes() do", vars, tree, new ForEachLoop<LayeredGraphNode>( "n" ) {
 			@Override
 			@Override
 			protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
 			protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
-				return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedNodes();
+				return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedNodes();
 			}
 			}
         } );
         } );
         root.add( foreach );
         root.add( foreach );
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
 			@Override
 			@Override
 			protected boolean condition(ReadOnlyMemory m) {
 			protected boolean condition(ReadOnlyMemory m) {
-				return m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getContainedLayers().size() > 0;
+				return m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getContainedLayers().size() > 0;
 			}
 			}
         } );
         } );
         foreach.add( ifNode );
         foreach.add( ifNode );
@@ -117,7 +127,7 @@ public class ConflictDetection {
         PseudoCodeNode init = new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
         PseudoCodeNode init = new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers();
+                return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers();
             }
             }
         } );
         } );
         root.add( init );
         root.add( init );
@@ -128,18 +138,18 @@ public class ConflictDetection {
 			}
 			}
 			@Override
 			@Override
 			protected int maximum( ReadOnlyMemory m ) {
 			protected int maximum( ReadOnlyMemory m ) {
-				return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 2;
+				return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 2;
 			}
 			}
         } );
         } );
         root.add( outerLoop );
         root.add( outerLoop );
         PseudoCodeNode line = new PseudoCodeNode( "k0 = 0; l = 0;", vars, tree, new CodeLine() {
         PseudoCodeNode line = new PseudoCodeNode( "k0 = 0; l = 0;", vars, tree, new CodeLine() {
 			@Override
 			@Override
 			public ControlFlow runForward(Memory m) {
 			public ControlFlow runForward(Memory m) {
-				m.declare( "k0", 0, MemoryType.LOCAL );
-				m.declare( "l", 0, MemoryType.LOCAL );
+				m.declare( "k0", 0, Visibility.LOCAL );
+				m.declare( "l", 0, Visibility.LOCAL );
 				actions.push( (Memory mem) -> {
 				actions.push( (Memory mem) -> {
-					mem.undeclare( "k0", MemoryType.LOCAL );
-					mem.undeclare( "l", MemoryType.LOCAL );
+					mem.undeclare( "k0", Visibility.LOCAL );
+					mem.undeclare( "l", Visibility.LOCAL );
 				} );
 				} );
 				return new ControlFlow( ControlFlow.STEP_OVER );
 				return new ControlFlow( ControlFlow.STEP_OVER );
 			}
 			}
@@ -152,14 +162,14 @@ public class ConflictDetection {
 			}
 			}
 			@Override
 			@Override
 			protected int maximum(ReadOnlyMemory m) {
 			protected int maximum(ReadOnlyMemory m) {
-				return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 ).size() - 1;
+				return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 ).size() - 1;
 			}
 			}
         } );
         } );
         outerLoop.add( innerLoop );
         outerLoop.add( innerLoop );
         ifNode = new PseudoCodeNode( "if l1==|L[i+1]|-1 or L[i+1][l1] incident to inner segment between L[i+1] and L[i] then", vars, tree, new IfLoop() {
         ifNode = new PseudoCodeNode( "if l1==|L[i+1]|-1 or L[i+1][l1] incident to inner segment between L[i+1] and L[i] then", vars, tree, new IfLoop() {
 			@Override
 			@Override
 			protected boolean condition(ReadOnlyMemory m) {
 			protected boolean condition(ReadOnlyMemory m) {
-	            return m.<Integer>read( "l1", MemoryType.LOCAL ) == m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1).size() - 1 || 
+	            return m.<Integer>read( "l1", Visibility.LOCAL ) == m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", Visibility.LOCAL ) + 1).size() - 1 || 
 	            		incidentToInnerSegmentBetweenLiPlusOneAndLi( m );
 	            		incidentToInnerSegmentBetweenLiPlusOneAndLi( m );
 			}
 			}
         } );
         } );
@@ -167,7 +177,7 @@ public class ConflictDetection {
         line = new PseudoCodeNode( "k1 = |L[i]|-1;", vars, tree, new DeclareVariable<Integer>( "k1" ) {
         line = new PseudoCodeNode( "k1 = |L[i]|-1;", vars, tree, new DeclareVariable<Integer>( "k1" ) {
 			@Override
 			@Override
 			protected Integer value(ReadOnlyMemory m) {
 			protected Integer value(ReadOnlyMemory m) {
-				return (int)m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).size() - 1;
+				return (int)m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).size() - 1;
 			}
 			}
         } );
         } );
         ifNode.add( line );
         ifNode.add( line );
@@ -182,38 +192,38 @@ public class ConflictDetection {
         line = new PseudoCodeNode( "k1 = pos(pred(L[i+1][l1])[0]);", vars, tree, new SetVariable<Integer>( "k1" ) {
         line = new PseudoCodeNode( "k1 = pos(pred(L[i+1][l1])[0]);", vars, tree, new SetVariable<Integer>( "k1" ) {
 			@Override
 			@Override
 			protected Integer value(ReadOnlyMemory m) {
 			protected Integer value(ReadOnlyMemory m) {
-				return (int)m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.read( "i", MemoryType.LOCAL ) ).indexOf(
-						m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 ).get( m.read( "l1", MemoryType.LOCAL ) ).getSortedIncomingEdges().get( 0 ).getSources().get( 0 ) );
+				return (int)m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.read( "i", Visibility.LOCAL ) ).indexOf(
+						m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 ).get( m.read( "l1", Visibility.LOCAL ) ).getSortedIncomingEdges().get( 0 ).getSources().get( 0 ) );
 			}
 			}
         } );
         } );
         innerIfNode.add( line );
         innerIfNode.add( line );
         PseudoCodeNode whileLoop = new PseudoCodeNode( "while l <= l1 do", vars, tree, new WhileLoop() {
         PseudoCodeNode whileLoop = new PseudoCodeNode( "while l <= l1 do", vars, tree, new WhileLoop() {
 			@Override
 			@Override
 			protected boolean condition( ReadOnlyMemory m ) {
 			protected boolean condition( ReadOnlyMemory m ) {
-				return m.<Integer>read( "l", MemoryType.LOCAL ) <= m.<Integer>read( "l1", MemoryType.LOCAL );
+				return m.<Integer>read( "l", Visibility.LOCAL ) <= m.<Integer>read( "l1", Visibility.LOCAL );
 			}
 			}
         } );
         } );
         ifNode.add( whileLoop );
         ifNode.add( whileLoop );
         foreach = new PseudoCodeNode( "foreach v in pred(L[i+1][l]) do", vars, tree, new ForEachLoop<LayeredGraphEdge>( "v" ) {
         foreach = new PseudoCodeNode( "foreach v in pred(L[i+1][l]) do", vars, tree, new ForEachLoop<LayeredGraphEdge>( "v" ) {
 			@Override
 			@Override
 			protected List<LayeredGraphEdge> list(ReadOnlyMemory m) {
 			protected List<LayeredGraphEdge> list(ReadOnlyMemory m) {
-				return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 ).get( m.read( "l", MemoryType.LOCAL ) ).getIncomingEdges();
+				return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 ).get( m.read( "l", Visibility.LOCAL ) ).getIncomingEdges();
 			}
 			}
         } );
         } );
         whileLoop.add( foreach );
         whileLoop.add( foreach );
         innerIfNode = new PseudoCodeNode( "if pos(v) < k0 or pos(v) > k1 then", vars, tree, new IfLoop() {
         innerIfNode = new PseudoCodeNode( "if pos(v) < k0 or pos(v) > k1 then", vars, tree, new IfLoop() {
 			@Override
 			@Override
 			protected boolean condition(ReadOnlyMemory m) {
 			protected boolean condition(ReadOnlyMemory m) {
-			    int k = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.read( "i", MemoryType.LOCAL ) ).indexOf( m.<LayeredGraphEdge>read( "v", MemoryType.LOCAL ).getSources().get( 0 ) );
-				return k < m.<Integer>read( "k0", MemoryType.LOCAL ) || k > m.<Integer>read( "k1", MemoryType.LOCAL );
+			    int k = m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers().get( m.read( "i", Visibility.LOCAL ) ).indexOf( m.<LayeredGraphEdge>read( "v", Visibility.LOCAL ).getSources().get( 0 ) );
+				return k < m.<Integer>read( "k0", Visibility.LOCAL ) || k > m.<Integer>read( "k1", Visibility.LOCAL );
 			}
 			}
         } );
         } );
         foreach.add( innerIfNode );
         foreach.add( innerIfNode );
         line = new PseudoCodeNode( "mark segment (v,L[i+1][l]);", vars, tree, new CodeLine() {
         line = new PseudoCodeNode( "mark segment (v,L[i+1][l]);", vars, tree, new CodeLine() {
 			@Override
 			@Override
 			public ControlFlow runForward(Memory m) {
 			public ControlFlow runForward(Memory m) {
-				LayeredGraphEdge e = m.read( "v", MemoryType.LOCAL );
-				boolean old = e.isConflicted( LayoutType.TOP_BOTTOM_LEFT );
+				LayeredGraphEdge e = m.read( "v", Visibility.LOCAL );
+				boolean old = e.isConflicted( LayoutType.LEFTMOST_UPPER );
 				e.setConflicted( true, null );
 				e.setConflicted( true, null );
 				actions.add( (Memory mem) -> {
 				actions.add( (Memory mem) -> {
 					e.setConflicted( old, null );
 					e.setConflicted( old, null );
@@ -225,14 +235,14 @@ public class ConflictDetection {
         line = new PseudoCodeNode( "l = l+1;", vars, tree, new SetVariable<Integer>( "l" ) {
         line = new PseudoCodeNode( "l = l+1;", vars, tree, new SetVariable<Integer>( "l" ) {
 			@Override
 			@Override
 			protected Integer value(ReadOnlyMemory m) {
 			protected Integer value(ReadOnlyMemory m) {
-				return (int)m.<Integer>read( "l", MemoryType.LOCAL ) + 1;
+				return (int)m.<Integer>read( "l", Visibility.LOCAL ) + 1;
 			}
 			}
         } );
         } );
         whileLoop.add( line );
         whileLoop.add( line );
         line = new PseudoCodeNode( "k0 = k1;", vars, tree, new SetVariable<Integer>( "k0" ) {
         line = new PseudoCodeNode( "k0 = k1;", vars, tree, new SetVariable<Integer>( "k0" ) {
 			@Override
 			@Override
 			protected Integer value(ReadOnlyMemory m) {
 			protected Integer value(ReadOnlyMemory m) {
-				return (int)m.<Integer>read( "k1", MemoryType.LOCAL );
+				return (int)m.<Integer>read( "k1", Visibility.LOCAL );
 			}
 			}
         } );
         } );
         ifNode.add( line );
         ifNode.add( line );
@@ -240,7 +250,7 @@ public class ConflictDetection {
     }
     }
     
     
     private static boolean incidentToInnerSegmentBetweenLiPlusOneAndLi( ReadOnlyMemory m ) {
     private static boolean incidentToInnerSegmentBetweenLiPlusOneAndLi( ReadOnlyMemory m ) {
-        LayeredGraphNode curr = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers().get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 ).get( m.read( "l1", MemoryType.LOCAL ) );
+        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()) {
         for (LayeredGraphEdge e : curr.getIncomingEdges()) {
             if (e.isDummyEdge()) {
             if (e.isDummyEdge()) {
                 return true;
                 return true;

+ 57 - 49
src/bk/Compaction.java → src/bk/HorizontalCompaction.java

@@ -5,12 +5,7 @@ import java.util.List;
 
 
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.PseudoCodeNode;
+import algorithm.CodeLine;
 import codelines.AbstractForLoop;
 import codelines.AbstractForLoop;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.ForEachLoop;
 import codelines.ForEachLoop;
@@ -18,121 +13,134 @@ import codelines.FunctionCall;
 import codelines.FunctionDefinition;
 import codelines.FunctionDefinition;
 import codelines.IfLoop;
 import codelines.IfLoop;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 /**
 /**
  * The stage of compacting the layout.
  * The stage of compacting the layout.
  * @author kolja
  * @author kolja
  *
  *
  */
  */
-public class Compaction {
+public class HorizontalCompaction {
 
 
+    /**
+     * creates the pseudo code for the horizontal compaction stage
+     * @param tree the tree where the code will be displayed
+     * @param placeBlock the code for the placeBlock method for recursive calls
+     * @return the code
+     */
     public static PseudoCodeNode horizontalCompaction( JTree tree, PseudoCodeNode placeBlock ) {
     public static PseudoCodeNode horizontalCompaction( JTree tree, PseudoCodeNode placeBlock ) {
         String[] vars = { "i", "L", "layout", "graph", "k", "v" };
         String[] vars = { "i", "L", "layout", "graph", "k", "v" };
-        @SuppressWarnings("serial")
+
         PseudoCodeNode root = new PseudoCodeNode( "function horizontalCompaction( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
         PseudoCodeNode root = new PseudoCodeNode( "function horizontalCompaction( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
+            private static final long serialVersionUID = -2594556212373706809L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m )
             public String getDebugOutput( Memory m )
             {
             {
-                if( m.isSomewhereDefined( "v", MemoryType.LOCAL ) )
-                    m.<LayeredGraphNode>read( "v", MemoryType.LOCAL).setSelected( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                if( m.isSomewhereDefined( "v", Visibility.LOCAL ) )
+                    m.<LayeredGraphNode>read( "v", Visibility.LOCAL).setSelected( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 return super.getDebugOutput( m );
                 return super.getDebugOutput( m );
             }
             }
         };
         };
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers();
+                return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers();
             }
             }
         } ) );
         } ) );
-        PseudoCodeNode firstLoop = new PseudoCodeNode( "for i=layout.contains('DOWN') ? 0 : |L|-1 to layout.contains('DOWN') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
+        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
             @Override
-            protected Integer begin(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
+            protected Integer intialize(ReadOnlyMemory m) {
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                     return 0;
                     return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1;
             }
             }
             @Override
             @Override
             protected Integer step(ReadOnlyMemory m) {
             protected Integer step(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) + 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) - 1;
+                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
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) >= 0;
+                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 );
         root.add( firstLoop );
         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" ) {
         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
             @Override
-            protected Integer begin( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
+            protected Integer intialize( ReadOnlyMemory m) {
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
                     return 0;
                     return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).size() - 1;
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).size() - 1;
             }
             }
             @Override
             @Override
             protected Integer step( ReadOnlyMemory m) {
             protected Integer step( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
-                    return m.<Integer>read( "k", MemoryType.LOCAL ) + 1;
-                return m.<Integer>read( "k", MemoryType.LOCAL ) - 1;
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
+                    return m.<Integer>read( "k", Visibility.LOCAL ) + 1;
+                return m.<Integer>read( "k", Visibility.LOCAL ) - 1;
             }
             }
             @Override
             @Override
             protected boolean condition( ReadOnlyMemory m) {
             protected boolean condition( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
-                    return m.<Integer>read( "k", MemoryType.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).size() - 1;
-                return m.<Integer>read( "k", MemoryType.LOCAL ) >= 0;
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
+                    return m.<Integer>read( "k", Visibility.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).size() - 1;
+                return m.<Integer>read( "k", Visibility.LOCAL ) >= 0;
             }
             }
         });
         });
         firstLoop.add( nodeLoop );
         firstLoop.add( nodeLoop );
         nodeLoop.add( new PseudoCodeNode( "v = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "v" ) {
         nodeLoop.add( new PseudoCodeNode( "v = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "v" ) {
             @Override
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
             protected LayeredGraphNode value(ReadOnlyMemory m) {
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).get( m.read( "k", MemoryType.LOCAL ) );
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).get( m.read( "k", Visibility.LOCAL ) );
             }
             }
         }));
         }));
         PseudoCodeNode ifRoot = new PseudoCodeNode( "if root[v] == v then", vars, tree, new IfLoop() {
         PseudoCodeNode ifRoot = new PseudoCodeNode( "if root[v] == v then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getRoot( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ) == m.<LayeredGraphNode>read( "v", MemoryType.LOCAL );
+                return m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ) == m.<LayeredGraphNode>read( "v", Visibility.LOCAL );
             }
             }
         });
         });
         nodeLoop.add( ifRoot );
         nodeLoop.add( ifRoot );
         ifRoot.add( new PseudoCodeNode( "call place_block(v, layout);", vars, tree, new FunctionCall( placeBlock, new String[]{ "v", "layout" } ) ) );
         ifRoot.add( new PseudoCodeNode( "call place_block(v, layout);", vars, tree, new FunctionCall( placeBlock, new String[]{ "v", "layout" } ) ) );
-        PseudoCodeNode secondLoop = new PseudoCodeNode( "for i=layout.contains('DOWN') ? 0 : |L|-1 to layout.contains('DOWN') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
+        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
             @Override
-            protected Integer begin(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
+            protected Integer intialize(ReadOnlyMemory m) {
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                     return 0;
                     return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1;
             }
             }
             @Override
             @Override
             protected Integer step(ReadOnlyMemory m) {
             protected Integer step(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) + 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) - 1;
+                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
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) >= 0;
+                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( secondLoop );
         root.add( secondLoop );
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach v in L[i] do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
         PseudoCodeNode foreach = new PseudoCodeNode( "foreach v in L[i] do", vars, tree, new ForEachLoop<LayeredGraphNode>( "v" ) {
             @Override
             @Override
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
             protected List<LayeredGraphNode> list(ReadOnlyMemory m) {
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) );
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) );
             }
             }
         });
         });
         secondLoop.add( foreach );
         secondLoop.add( foreach );
         foreach.add( new PseudoCodeNode( "x[v] = x[root[v]];", vars, tree, new CodeLine() {
         foreach.add( new PseudoCodeNode( "x[v] = x[root[v]];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                LayoutType layout = LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) );
+                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 );
                 boolean oldDef = !v.isXUndefined( layout );
                 boolean oldDef = !v.isXUndefined( layout );
                 v.setX( v.getRoot( layout ).getX( layout ), true, layout );
                 v.setX( v.getRoot( layout ).getX( layout ), true, layout );
@@ -145,8 +153,8 @@ public class Compaction {
         PseudoCodeNode ifShift = new PseudoCodeNode( "if v == root[v] and ((layout.contains('RIGHT') and shift[sink[v]] < ∞ ) or (layout.contains('LEFT') and shift[sink[v]] > -∞ )) then", vars, tree, new IfLoop() {
         PseudoCodeNode ifShift = new PseudoCodeNode( "if v == root[v] and ((layout.contains('RIGHT') and shift[sink[v]] < ∞ ) or (layout.contains('LEFT') and shift[sink[v]] > -∞ )) then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                String lStr = m.read( "layout", MemoryType.LOCAL );
+                LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
+                String lStr = m.read( "layout", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( lStr );
                 LayoutType layout = LayoutType.fromString( lStr );
                 return v == v.getRoot( layout ) && ((lStr.contains( "RIGHT" ) && v.getSink( layout ).getShift( layout ) < Double.POSITIVE_INFINITY ) || (lStr.contains( "LEFT" ) && v.getSink( layout ).getShift( layout ) > Double.NEGATIVE_INFINITY ));
                 return v == v.getRoot( layout ) && ((lStr.contains( "RIGHT" ) && v.getSink( layout ).getShift( layout ) < Double.POSITIVE_INFINITY ) || (lStr.contains( "LEFT" ) && v.getSink( layout ).getShift( layout ) > Double.NEGATIVE_INFINITY ));
             }
             }
@@ -155,8 +163,8 @@ public class Compaction {
         ifShift.add( new PseudoCodeNode( "x[v] += shift[sink[v]];", vars, tree, new CodeLine() {
         ifShift.add( new PseudoCodeNode( "x[v] += shift[sink[v]];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                LayoutType layout = LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) );
+                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 );
                 boolean oldDef = !v.isXUndefined( layout );
                 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 );

+ 19 - 13
src/bk/LayoutType.java

@@ -7,24 +7,30 @@ package bk;
  *
  *
  */
  */
 public enum LayoutType{
 public enum LayoutType{
-    TOP_BOTTOM_LEFT,
-    TOP_BOTTOM_RIGHT,
-    BOTTOM_TOP_LEFT,
-    BOTTOM_TOP_RIGHT,
+    LEFTMOST_UPPER,
+    RIGHTMOST_UPPER,
+    LEFTMOST_LOWER,
+    RIGHTMOST_LOWER,
     COMBINED;
     COMBINED;
     
     
+    /**
+     * converts a {@link String} into an {@link LayoutType}
+     * @param s the {@link String}
+     * @return the {@link LayoutType}
+     */
     public static LayoutType fromString( String s )
     public static LayoutType fromString( String s )
     {
     {
         switch( s ) {
         switch( s ) {
-        case "DOWN_RIGHT":
-            return TOP_BOTTOM_LEFT;
-        case "DOWN_LEFT":
-            return TOP_BOTTOM_RIGHT;
-        case "UP_RIGHT":
-            return BOTTOM_TOP_LEFT;
-        case "UP_LEFT":
-            return BOTTOM_TOP_RIGHT;
+        case "RIGHTMOST_LOWER":
+            return LEFTMOST_UPPER;
+        case "LEFTMOST_LOWER":
+            return RIGHTMOST_UPPER;
+        case "RIGHTMOST_UPPER":
+            return LEFTMOST_LOWER;
+        case "LEFTMOST_UPPER":
+            return RIGHTMOST_LOWER;
+        default:
+            throw new IllegalArgumentException(s + " is not a valid LayoutType.");
         }
         }
-        return null;
     }
     }
 }
 }

+ 58 - 48
src/bk/PlaceBlock.java

@@ -2,12 +2,7 @@ package bk;
 
 
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.PseudoCodeNode;
+import algorithm.CodeLine;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.FunctionCall;
 import codelines.FunctionCall;
 import codelines.FunctionDefinition;
 import codelines.FunctionDefinition;
@@ -16,47 +11,59 @@ import codelines.SetVariable;
 import codelines.WhileLoop;
 import codelines.WhileLoop;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
 import graph.LayeredNode;
 import graph.LayeredNode;
-// PAPER = OUR
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 import view.NodeView;
 import view.NodeView;
 
 
-// DOWN = RIGHT
-// UP = LEFT
-// RIGHT = DOWN
-// LEFT = UP
+/**
+ * The stage of executing the place_block function
+ * @author kolja
+ *
+ */
 public class PlaceBlock{
 public class PlaceBlock{
 
 
+    /**
+     * creates the pseudo code for the place_block function
+     * @param tree the tree where the code will be displayed
+     * @return the code
+     */
     public static PseudoCodeNode place_block(JTree tree) {
     public static PseudoCodeNode place_block(JTree tree) {
-        String vars[] = { "v", "w", "layout", "x", "y", "graph", "u", "root", "align", "first" };
-        @SuppressWarnings("serial")
+        String[] vars = { "v", "w", "layout", "x", "y", "graph", "u", "root", "align", "first" };
+
         PseudoCodeNode root = new PseudoCodeNode( "function place_block( v, layout )", vars, tree, new FunctionDefinition(new String[]{ "v", "layout" } ) ) {
         PseudoCodeNode root = new PseudoCodeNode( "function place_block( v, layout )", vars, tree, new FunctionDefinition(new String[]{ "v", "layout" } ) ) {
+            private static final long serialVersionUID = 8208248088929356639L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m )
             public String getDebugOutput( Memory m )
             {
             {
-                if( m.isSomewhereDefined( "v", MemoryType.LOCAL ) && !m.isSomewhereDefined( "w", MemoryType.LOCAL ) )
-                    m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).setSelected( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
-                if( m.isSomewhereDefined( "w", MemoryType.LOCAL ) )
-                    m.<LayeredGraphNode>read( "w", MemoryType.LOCAL ).setSelected( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                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 ) )
+                    m.<LayeredGraphNode>read( "w", Visibility.LOCAL ).setSelected( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 return super.getDebugOutput( m );
                 return super.getDebugOutput( m );
             }
             }
         };
         };
         PseudoCodeNode ifUndef = new PseudoCodeNode( "if x[v] == undefined then", vars, tree, new IfLoop() {
         PseudoCodeNode ifUndef = new PseudoCodeNode( "if x[v] == undefined then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).isXUndefined( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                return m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).isXUndefined( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
             }
             }
         });
         });
         root.add( ifUndef );
         root.add( ifUndef );
         ifUndef.add( new PseudoCodeNode( "x[v] = 0; w = v; first = true;", vars, tree, new CodeLine() {
         ifUndef.add( new PseudoCodeNode( "x[v] = 0; w = v; first = true;", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                m.declare( "w", m.read( "v", MemoryType.LOCAL ), MemoryType.LOCAL );
-                m.declare( "first", true, MemoryType.LOCAL );
-                double oldX = m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getX( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
-                m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).setX( 0, true, LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                m.declare( "w", m.read( "v", Visibility.LOCAL ), Visibility.LOCAL );
+                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) -> {
                 actions.push( (Memory mem) -> {
-                    mem.undeclare( "w", MemoryType.LOCAL );
-                    mem.undeclare( "first", MemoryType.LOCAL );
-                    m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).setX( oldX, false, LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                    mem.undeclare( "w", Visibility.LOCAL );
+                    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 );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -64,7 +71,7 @@ public class PlaceBlock{
         PseudoCodeNode whilewv = new PseudoCodeNode( "while w != v or first", vars, tree, new WhileLoop() {
         PseudoCodeNode whilewv = new PseudoCodeNode( "while w != v or first", vars, tree, new WhileLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                return m.read( "w", MemoryType.LOCAL ) != m.read( "v", MemoryType.LOCAL ) || m.<Boolean>read( "first", MemoryType.LOCAL );
+                return m.read( "w", Visibility.LOCAL ) != m.read( "v", Visibility.LOCAL ) || m.<Boolean>read( "first", Visibility.LOCAL );
             }
             }
         });
         });
         ifUndef.add( whilewv );
         ifUndef.add( whilewv );
@@ -77,30 +84,30 @@ public class PlaceBlock{
         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() {
         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
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayeredGraphNode w = m.read( "w", MemoryType.LOCAL );
+                LayeredGraphNode w = m.read( "w", Visibility.LOCAL );
                 LayeredGraphNode graph = w.parent();
                 LayeredGraphNode graph = w.parent();
-                return (m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) && graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) > 0 ) ||
-                       (m.<String>read( "layout", MemoryType.LOCAL ).contains( "LEFT" ) && graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) < graph.getContainedLayers().get( w.getLayer() ).size() - 1 );
+                return (m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) && graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) > 0 ) ||
+                       (m.<String>read( "layout", Visibility.LOCAL ).contains( "LEFT" ) && graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) < graph.getContainedLayers().get( w.getLayer() ).size() - 1 );
             }
             }
         });
         });
         whilewv.add( ifPos );
         whilewv.add( ifPos );
         ifPos.add( new PseudoCodeNode( "u = layout.contains('RIGHT') ? root[fore(w)] : root[foll(w)];", vars, tree, new DeclareVariable<LayeredGraphNode>( "u" ){
         ifPos.add( new PseudoCodeNode( "u = layout.contains('RIGHT') ? root[fore(w)] : root[foll(w)];", vars, tree, new DeclareVariable<LayeredGraphNode>( "u" ){
             @Override
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
             protected LayeredGraphNode value(ReadOnlyMemory m) {
-                LayeredGraphNode w = m.read( "w", MemoryType.LOCAL );
+                LayeredGraphNode w = m.read( "w", Visibility.LOCAL );
                 LayeredGraphNode graph = w.parent();
                 LayeredGraphNode graph = w.parent();
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
-                    return graph.getContainedLayers().get( w.getLayer() ).get( graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) - 1 ).getRoot( LayoutType.fromString( m.<String>read( "layout", MemoryType.LOCAL ) ) );
-                return graph.getContainedLayers().get( w.getLayer() ).get( graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) + 1 ).getRoot( LayoutType.fromString( m.<String>read( "layout", MemoryType.LOCAL ) ) );
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
+                    return graph.getContainedLayers().get( w.getLayer() ).get( graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) - 1 ).getRoot( LayoutType.fromString( m.<String>read( "layout", Visibility.LOCAL ) ) );
+                return graph.getContainedLayers().get( w.getLayer() ).get( graph.getContainedLayers().get( w.getLayer() ).indexOf( w ) + 1 ).getRoot( LayoutType.fromString( m.<String>read( "layout", Visibility.LOCAL ) ) );
             }
             }
         } ));
         } ));
         ifPos.add( new PseudoCodeNode( "call place_block( u, layout );", vars, tree, new FunctionCall( root, new String[]{ "u", "layout" } ) ) );
         ifPos.add( new PseudoCodeNode( "call place_block( u, layout );", vars, tree, new FunctionCall( root, new String[]{ "u", "layout" } ) ) );
         ifPos.add( new PseudoCodeNode( "sink[v] = sink[v] == v ? sink[u] : sink[v];", vars, tree, new CodeLine() {
         ifPos.add( new PseudoCodeNode( "sink[v] = sink[v] == v ? sink[u] : sink[v];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                LayeredGraphNode u = m.read( "u", MemoryType.LOCAL );
-                LayoutType layout = LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) );
+                LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
+                LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
+                LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
                 LayeredGraphNode old = v.getSink( layout );
                 LayeredGraphNode old = v.getSink( layout );
                 v.setSink( old == v ? u.getSink( layout ) : old, layout );
                 v.setSink( old == v ? u.getSink( layout ) : old, layout );
                 actions.push( (Memory mem) -> {
                 actions.push( (Memory mem) -> {
@@ -112,18 +119,18 @@ public class PlaceBlock{
         PseudoCodeNode ifSink1 = new PseudoCodeNode( "if sink[v] != sink[u] then", vars, tree, new IfLoop() {
         PseudoCodeNode ifSink1 = new PseudoCodeNode( "if sink[v] != sink[u] then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayoutType layout = LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) );
-                return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getSink( layout ) != m.<LayeredGraphNode>read( "u", MemoryType.LOCAL ).getSink( layout );
+                LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
+                return m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getSink( layout ) != m.<LayeredGraphNode>read( "u", Visibility.LOCAL ).getSink( layout );
             }
             }
         });
         });
         ifPos.add( ifSink1 );
         ifPos.add( ifSink1 );
         ifSink1.add( new PseudoCodeNode( "shift[sink[u]] = layout.contains('RIGHT') ? min(shift[sink[u]], x[v] - x[u] - spacing) : max(shift[sink[u]], x[v] + x[u] + spacing);", vars, tree, new CodeLine() {
         ifSink1.add( new PseudoCodeNode( "shift[sink[u]] = layout.contains('RIGHT') ? min(shift[sink[u]], x[v] - x[u] - spacing) : max(shift[sink[u]], x[v] + x[u] + spacing);", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String lStr = m.read( "layout", MemoryType.LOCAL );
+                String lStr = m.read( "layout", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( lStr );
                 LayoutType layout = LayoutType.fromString( lStr );
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                LayeredGraphNode u = m.read( "u", MemoryType.LOCAL );
+                LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
+                LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
                 double old = u.getSink( layout ).getShift( layout );
                 double old = u.getSink( layout ).getShift( layout );
                 u.getSink( layout ).setShift( lStr.contains( "RIGHT" ) ? 
                 u.getSink( layout ).setShift( lStr.contains( "RIGHT" ) ? 
                         Math.min( u.getSink( layout ).getShift( layout ), v.getX( layout ) - u.getX( layout ) - calcSpacing( u.parent(), layout ) ) : 
                         Math.min( u.getSink( layout ).getShift( layout ), v.getX( layout ) - u.getX( layout ) - calcSpacing( u.parent(), layout ) ) : 
@@ -137,18 +144,18 @@ public class PlaceBlock{
         PseudoCodeNode ifSink2 = new PseudoCodeNode( "if sink[v] == sink[u] then", vars, tree, new IfLoop() {
         PseudoCodeNode ifSink2 = new PseudoCodeNode( "if sink[v] == sink[u] then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayoutType layout = LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) );
-                return m.<LayeredGraphNode>read( "v", MemoryType.LOCAL ).getSink( layout ) == m.<LayeredGraphNode>read( "u", MemoryType.LOCAL ).getSink( layout );
+                LayoutType layout = LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) );
+                return m.<LayeredGraphNode>read( "v", Visibility.LOCAL ).getSink( layout ) == m.<LayeredGraphNode>read( "u", Visibility.LOCAL ).getSink( layout );
             }
             }
         });
         });
         ifPos.add( ifSink2 );
         ifPos.add( ifSink2 );
         ifSink2.add( new PseudoCodeNode( "x[v] = layout.contains('RIGHT') ? max(x[v], x[u] + spacing) : max(x[v], x[u] - spacing);", vars, tree, new CodeLine() {
         ifSink2.add( new PseudoCodeNode( "x[v] = layout.contains('RIGHT') ? max(x[v], x[u] + spacing) : max(x[v], x[u] - spacing);", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                String lStr = m.read( "layout", MemoryType.LOCAL );
+                String lStr = m.read( "layout", Visibility.LOCAL );
                 LayoutType layout = LayoutType.fromString( lStr );
                 LayoutType layout = LayoutType.fromString( lStr );
-                LayeredGraphNode v = m.read( "v", MemoryType.LOCAL );
-                LayeredGraphNode u = m.read( "u", MemoryType.LOCAL );
+                LayeredGraphNode v = m.read( "v", Visibility.LOCAL );
+                LayeredGraphNode u = m.read( "u", Visibility.LOCAL );
                 double old = v.getX( layout );
                 double old = v.getX( layout );
                 boolean oldDef = !v.isXUndefined( layout );
                 boolean oldDef = !v.isXUndefined( layout );
                 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 );
                 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 );
@@ -161,7 +168,7 @@ public class PlaceBlock{
         whilewv.add( new PseudoCodeNode( "w = align[w];", vars, tree, new SetVariable<LayeredGraphNode>( "w" ) {
         whilewv.add( new PseudoCodeNode( "w = align[w];", vars, tree, new SetVariable<LayeredGraphNode>( "w" ) {
             @Override
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
             protected LayeredGraphNode value(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "w", MemoryType.LOCAL ).getAlign( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                return m.<LayeredGraphNode>read( "w", Visibility.LOCAL ).getAlign( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
             }
             }
         }));
         }));
         return root;
         return root;
@@ -169,7 +176,10 @@ public class PlaceBlock{
 
 
 
 
     /**
     /**
-     * calculates the minimum spacing needed between two left borders of nodes.
+     * 
+     * calculates the minimum spacing needed between two left borders of nodes in the given graph and layout.
+     * @param graph the graph
+     * @param layout the layout
      * @return the spacing
      * @return the spacing
      */
      */
     public static double calcSpacing( LayeredGraphNode graph, LayoutType layout )
     public static double calcSpacing( LayeredGraphNode graph, LayoutType layout )

+ 85 - 77
src/bk/BlockCalc.java → src/bk/VerticalAligment.java

@@ -5,12 +5,7 @@ import java.util.List;
 
 
 import javax.swing.JTree;
 import javax.swing.JTree;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.PseudoCodeNode;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
+import algorithm.CodeLine;
 import codelines.AbstractForLoop;
 import codelines.AbstractForLoop;
 import codelines.DeclareVariable;
 import codelines.DeclareVariable;
 import codelines.ForEachLoop;
 import codelines.ForEachLoop;
@@ -20,105 +15,118 @@ import codelines.IfLoop;
 import codelines.SetVariable;
 import codelines.SetVariable;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 /**
 /**
  * The stage of the BK node placement algorithm where the blocks are computed.
  * The stage of the BK node placement algorithm where the blocks are computed.
  * @author kolja
  * @author kolja
  *
  *
  */
  */
-public class BlockCalc {
+public class VerticalAligment {
 
 
-    public static PseudoCodeNode calculateBlockGraph( JTree tree, PseudoCodeNode claclLayout ) {
+    /**
+     * creates the pseudo code for calculating the block graph (stage vertical alignment)
+     * @param tree the tree where the code will be displayed
+     * @param calcLayout a pointer to a function that calculates an extremal layout (for recursive calls)
+     * @return the root of the code
+     */
+    public static PseudoCodeNode calculateBlockGraph( JTree tree, PseudoCodeNode calcLayout ) {
         String[] vars = { "graph", "L", "r", "neighbors", "layout", "m", "i", "k", "mids", "n" };
         String[] vars = { "graph", "L", "r", "neighbors", "layout", "m", "i", "k", "mids", "n" };
-        @SuppressWarnings("serial")
+
         PseudoCodeNode root = new PseudoCodeNode( "function calculateBlockGraph( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
         PseudoCodeNode root = new PseudoCodeNode( "function calculateBlockGraph( layout, graph )", vars, tree, new FunctionDefinition( new String[]{ "layout", "graph" } ) ) {
+            private static final long serialVersionUID = -839881272535733474L;
+
             @Override
             @Override
             public String getDebugOutput( Memory m )
             public String getDebugOutput( Memory m )
             {
             {
-                if( m.isSomewhereDefined( "n", MemoryType.LOCAL ) )
-                    m.<LayeredGraphNode>read( "n", MemoryType.LOCAL).setSelected( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                if( m.isSomewhereDefined( "n", Visibility.LOCAL ) )
+                    m.<LayeredGraphNode>read( "n", Visibility.LOCAL).setSelected( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 return super.getDebugOutput( m );
                 return super.getDebugOutput( m );
             }
             }
         };
         };
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
         root.add( new PseudoCodeNode( "L = graph.getContainedLayers();", vars, tree, new DeclareVariable<ArrayList<ArrayList<LayeredGraphNode>>>( "L" ) {
             @Override
             @Override
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
             protected ArrayList<ArrayList<LayeredGraphNode>> value(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).getContainedLayers();
+                return m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).getContainedLayers();
             }
             }
         } ) );
         } ) );
-        PseudoCodeNode layerLoop = new PseudoCodeNode( "for i=layout.contains('DOWN') ? 0 : |L|-1 to layout.contains('DOWN') ? |L|-1 : 0 do", vars, tree, new AbstractForLoop<Integer>( "i" ) {
+        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
             @Override
-            protected Integer begin(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
+            protected Integer intialize(ReadOnlyMemory m) {
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                     return 0;
                     return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).size() - 1;
             }
             }
             @Override
             @Override
             protected Integer step(ReadOnlyMemory m) {
             protected Integer step(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) + 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) - 1;
+                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
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    return m.<Integer>read( "i", MemoryType.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).size() - 1;
-                return m.<Integer>read( "i", MemoryType.LOCAL ) >= 0;
+                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( layerLoop );
         root.add( layerLoop );
         layerLoop.add( new PseudoCodeNode( "r = layout.contains('RIGHT') ? -1 : INFINITY;", vars, tree, new DeclareVariable<Double>( "r" ) {
         layerLoop.add( new PseudoCodeNode( "r = layout.contains('RIGHT') ? -1 : INFINITY;", vars, tree, new DeclareVariable<Double>( "r" ) {
             @Override
             @Override
             protected Double value(ReadOnlyMemory m) {
             protected Double value(ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
                     return -1.0;
                     return -1.0;
                 return Double.POSITIVE_INFINITY;
                 return Double.POSITIVE_INFINITY;
             }
             }
         } ) );
         } ) );
         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" ) {
         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
             @Override
-            protected Integer begin( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
+            protected Integer intialize( ReadOnlyMemory m) {
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
                     return 0;
                     return 0;
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).size() - 1;
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).size() - 1;
             }
             }
             @Override
             @Override
             protected Integer step( ReadOnlyMemory m) {
             protected Integer step( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
-                    return m.<Integer>read( "k", MemoryType.LOCAL ) + 1;
-                return m.<Integer>read( "k", MemoryType.LOCAL ) - 1;
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
+                    return m.<Integer>read( "k", Visibility.LOCAL ) + 1;
+                return m.<Integer>read( "k", Visibility.LOCAL ) - 1;
             }
             }
             @Override
             @Override
             protected boolean condition( ReadOnlyMemory m) {
             protected boolean condition( ReadOnlyMemory m) {
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
-                    return m.<Integer>read( "k", MemoryType.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).size() - 1;
-                return m.<Integer>read( "k", MemoryType.LOCAL ) >= 0;
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
+                    return m.<Integer>read( "k", Visibility.LOCAL ) <= m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).size() - 1;
+                return m.<Integer>read( "k", Visibility.LOCAL ) >= 0;
             }
             }
         });
         });
         nodeLoop.add( new PseudoCodeNode( "n = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "n" ) {
         nodeLoop.add( new PseudoCodeNode( "n = L[i][k];", vars, tree, new DeclareVariable<LayeredGraphNode>( "n" ) {
             @Override
             @Override
             protected LayeredGraphNode value(ReadOnlyMemory m) {
             protected LayeredGraphNode value(ReadOnlyMemory m) {
-                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.read( "i", MemoryType.LOCAL ) ).get( m.read( "k", MemoryType.LOCAL ) );
+                return m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.read( "i", Visibility.LOCAL ) ).get( m.read( "k", Visibility.LOCAL ) );
             }
             }
         }));
         }));
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
         PseudoCodeNode ifNode = new PseudoCodeNode( "if n has subgraph then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                return m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getContainedNodes().size() > 0;
+                return m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getContainedNodes().size() > 0;
             }
             }
         } );
         } );
         nodeLoop.add( ifNode );
         nodeLoop.add( ifNode );
-        ifNode.add( new PseudoCodeNode( "call calcLayout( layout, n );", vars, tree, new FunctionCall( claclLayout, new String[]{ "layout", "n" } ) ) );
-        nodeLoop.add( new PseudoCodeNode( "neighbors = layout.contains('DOWN') ? predecessors(n) : successors(n)", vars, tree, new DeclareVariable<ArrayList<LayeredGraphNode>>( "neighbors" ) {
+        ifNode.add( new PseudoCodeNode( "call calcLayout( layout, n );", vars, tree, new FunctionCall( calcLayout, new String[]{ "layout", "n" } ) ) );
+        nodeLoop.add( new PseudoCodeNode( "neighbors = layout.contains('LOWER') ? predecessors(n) : successors(n)", vars, tree, new DeclareVariable<ArrayList<LayeredGraphNode>>( "neighbors" ) {
             @Override
             @Override
             protected ArrayList<LayeredGraphNode> value(ReadOnlyMemory m) {
             protected ArrayList<LayeredGraphNode> value(ReadOnlyMemory m) {
-                ArrayList<LayeredGraphEdge> list = m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getSortedOutgoingEdges();
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    list = m.<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getSortedIncomingEdges();
+                ArrayList<LayeredGraphEdge> list = m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getSortedOutgoingEdges();
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
+                    list = m.<LayeredGraphNode>read( "n", Visibility.LOCAL ).getSortedIncomingEdges();
                 ArrayList<LayeredGraphNode> result = new ArrayList<LayeredGraphNode>();
                 ArrayList<LayeredGraphNode> result = new ArrayList<LayeredGraphNode>();
                 for( LayeredGraphEdge e : list )
                 for( LayeredGraphEdge e : list )
                 {
                 {
-                    if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
+                    if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
                         result.add( e.getSources().get( 0 ) );
                         result.add( e.getSources().get( 0 ) );
                     else
                     else
                         result.add( e.getTargets().get( 0 ) );
                         result.add( e.getTargets().get( 0 ) );
@@ -130,8 +138,8 @@ public class BlockCalc {
         nodeLoop.add( new PseudoCodeNode( "neighbors = layout.contains('RIGHT') ? neighbors : reverse( neighbors )", vars, tree, new SetVariable<ArrayList<LayeredGraphNode>>( "neighbors" ) {
         nodeLoop.add( new PseudoCodeNode( "neighbors = layout.contains('RIGHT') ? neighbors : reverse( neighbors )", vars, tree, new SetVariable<ArrayList<LayeredGraphNode>>( "neighbors" ) {
             @Override
             @Override
             protected ArrayList<LayeredGraphNode> value(ReadOnlyMemory m) {
             protected ArrayList<LayeredGraphNode> value(ReadOnlyMemory m) {
-                ArrayList<LayeredGraphNode> list = m.read( "neighbors", MemoryType.LOCAL );
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) )
+                ArrayList<LayeredGraphNode> list = m.read( "neighbors", Visibility.LOCAL );
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) )
                     return list;
                     return list;
                 else
                 else
                 {
                 {
@@ -145,14 +153,14 @@ public class BlockCalc {
         PseudoCodeNode ifNeighbors = new PseudoCodeNode( "if |neighbors| > 0 then", vars, tree, new IfLoop() {
         PseudoCodeNode ifNeighbors = new PseudoCodeNode( "if |neighbors| > 0 then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition( ReadOnlyMemory m) {
             protected boolean condition( ReadOnlyMemory m) {
-                return m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).size() > 0;
+                return m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).size() > 0;
             }
             }
         });
         });
         nodeLoop.add( ifNeighbors );
         nodeLoop.add( ifNeighbors );
         ifNeighbors.add( new PseudoCodeNode( "mids = [roundDown((|neighbors|-1)/2),roundUp((|neighbors|-1)/2)]", vars, tree, new DeclareVariable<ArrayList<Integer>>( "mids" ) {
         ifNeighbors.add( new PseudoCodeNode( "mids = [roundDown((|neighbors|-1)/2),roundUp((|neighbors|-1)/2)]", vars, tree, new DeclareVariable<ArrayList<Integer>>( "mids" ) {
             @Override
             @Override
             protected ArrayList<Integer> value(ReadOnlyMemory m) {
             protected ArrayList<Integer> value(ReadOnlyMemory m) {
-                int size = m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).size() - 1;
+                int size = m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).size() - 1;
                 int m1 = size / 2, m2 = (int)(size / 2.0 + 0.5);
                 int m1 = size / 2, m2 = (int)(size / 2.0 + 0.5);
                 ArrayList<Integer> list = new ArrayList<Integer>();
                 ArrayList<Integer> list = new ArrayList<Integer>();
                 list.add( m1 );
                 list.add( m1 );
@@ -164,48 +172,48 @@ public class BlockCalc {
         PseudoCodeNode midLoop = new PseudoCodeNode( "foreach m in mids do", vars, tree, new ForEachLoop<Integer>( "m" ) {
         PseudoCodeNode midLoop = new PseudoCodeNode( "foreach m in mids do", vars, tree, new ForEachLoop<Integer>( "m" ) {
             @Override
             @Override
             protected List<Integer> list(ReadOnlyMemory m) {
             protected List<Integer> list(ReadOnlyMemory m) {
-                return m.read( "mids", MemoryType.LOCAL );
+                return m.read( "mids", Visibility.LOCAL );
             }
             }
         } );
         } );
         ifNeighbors.add( midLoop );
         ifNeighbors.add( midLoop );
         PseudoCodeNode ifAlign = new PseudoCodeNode( "if align[n] == n then", vars, tree, new IfLoop() {
         PseudoCodeNode ifAlign = new PseudoCodeNode( "if align[n] == n then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayeredGraphNode n = m.read( "n", MemoryType.LOCAL );
-                return n.getAlign( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ) == n;
+                LayeredGraphNode n = m.read( "n", Visibility.LOCAL );
+                return n.getAlign( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ) == n;
             }
             }
         });
         });
         midLoop.add( ifAlign );
         midLoop.add( ifAlign );
         PseudoCodeNode ifMarked = new PseudoCodeNode( "if (neighbors[m],n) not conflicted and ((r < pos(neighbors[m]) and layout.contains('RIGHT')) or (r > pos(neighbors[m]) and layout.contains('LEFT'))) then", vars, tree, new IfLoop() {
         PseudoCodeNode ifMarked = new PseudoCodeNode( "if (neighbors[m],n) not conflicted and ((r < pos(neighbors[m]) and layout.contains('RIGHT')) or (r > pos(neighbors[m]) and layout.contains('LEFT'))) then", vars, tree, new IfLoop() {
             @Override
             @Override
             protected boolean condition(ReadOnlyMemory m) {
             protected boolean condition(ReadOnlyMemory m) {
-                LayeredGraphEdge e = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).findEdgeBetween(
-                        m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ),
-                        m.read( "n", MemoryType.LOCAL ) );
+                LayeredGraphEdge e = m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).findEdgeBetween(
+                        m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) ),
+                        m.read( "n", Visibility.LOCAL ) );
                 if( e == null )
                 if( e == null )
-                    e = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).findEdgeBetween( m.read( "n", MemoryType.LOCAL ),
-                            m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ) );
+                    e = m.<LayeredGraphNode>read( "graph", Visibility.LOCAL ).findEdgeBetween( m.read( "n", Visibility.LOCAL ),
+                            m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) ) );
                 ArrayList<LayeredGraphNode> layerBefore;
                 ArrayList<LayeredGraphNode> layerBefore;
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) - 1 );
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
+                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.<Integer>read( "i", Visibility.LOCAL ) - 1 );
                 else
                 else
-                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 );
-                int posU = layerBefore.indexOf( m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ) );
-                return !e.isConflicted( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ) &&
-                        ( ( m.<Double>read( "r", MemoryType.LOCAL ) < posU && m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) ) ||
-                                ( m.<Double>read( "r", MemoryType.LOCAL ) > posU && m.<String>read( "layout", MemoryType.LOCAL ).contains( "LEFT" ) ) );
+                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 );
+                int posU = layerBefore.indexOf( m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) ) );
+                return !e.isConflicted( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ) &&
+                        ( ( m.<Double>read( "r", Visibility.LOCAL ) < posU && m.<String>read( "layout", Visibility.LOCAL ).contains( "RIGHT" ) ) ||
+                                ( m.<Double>read( "r", Visibility.LOCAL ) > posU && m.<String>read( "layout", Visibility.LOCAL ).contains( "LEFT" ) ) );
             }
             }
         });
         });
         ifAlign.add( ifMarked );
         ifAlign.add( ifMarked );
         ifMarked.add( new PseudoCodeNode( "align[neighbors[m]] = n;", vars, tree, new CodeLine() {
         ifMarked.add( new PseudoCodeNode( "align[neighbors[m]] = n;", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) );
-                LayeredGraphNode v = m.read( "n", MemoryType.LOCAL );
-                LayeredGraphNode old = u.getAlign( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
-                u.setAlign( v, LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                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 ) ) );
                 actions.push( (Memory mem) -> {
                 actions.push( (Memory mem) -> {
-                    u.setAlign( old, LayoutType.fromString( mem.read( "layout", MemoryType.LOCAL ) ) );
+                    u.setAlign( old, LayoutType.fromString( mem.read( "layout", Visibility.LOCAL ) ) );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -213,12 +221,12 @@ public class BlockCalc {
         ifMarked.add( new PseudoCodeNode( "root[n] = root[neighbors[m]];", vars, tree, new CodeLine() {
         ifMarked.add( new PseudoCodeNode( "root[n] = root[neighbors[m]];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) );
-                LayeredGraphNode v = m.read( "n", MemoryType.LOCAL );
-                LayeredGraphNode old = v.getRoot( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
-                v.setRoot( u.getRoot( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                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 ) ) );
+                v.setRoot( u.getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 actions.push( (Memory mem) -> {
                 actions.push( (Memory mem) -> {
-                    v.setRoot( old, LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                    v.setRoot( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -226,11 +234,11 @@ public class BlockCalc {
         ifMarked.add( new PseudoCodeNode( "align[n] = root[n];", vars, tree, new CodeLine() {
         ifMarked.add( new PseudoCodeNode( "align[n] = root[n];", vars, tree, new CodeLine() {
             @Override
             @Override
             public ControlFlow runForward(Memory m) {
             public ControlFlow runForward(Memory m) {
-                LayeredGraphNode v = m.read( "n", MemoryType.LOCAL );
-                LayeredGraphNode old = v.getAlign( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
-                v.setAlign( v.getRoot( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                LayeredGraphNode v = m.read( "n", Visibility.LOCAL );
+                LayeredGraphNode old = v.getAlign( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
+                v.setAlign( v.getRoot( LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) ), LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 actions.push( (Memory mem) -> {
                 actions.push( (Memory mem) -> {
-                    v.setAlign( old, LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) );
+                    v.setAlign( old, LayoutType.fromString( m.read( "layout", Visibility.LOCAL ) ) );
                 });
                 });
                 return new ControlFlow( ControlFlow.STEP_OVER );
                 return new ControlFlow( ControlFlow.STEP_OVER );
             }
             }
@@ -239,11 +247,11 @@ public class BlockCalc {
             @Override
             @Override
             protected Double value(ReadOnlyMemory m) {
             protected Double value(ReadOnlyMemory m) {
                 ArrayList<LayeredGraphNode> layerBefore;
                 ArrayList<LayeredGraphNode> layerBefore;
-                if( m.<String>read( "layout", MemoryType.LOCAL ).contains( "DOWN" ) )
-                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) - 1 );
+                if( m.<String>read( "layout", Visibility.LOCAL ).contains( "LOWER" ) )
+                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.<Integer>read( "i", Visibility.LOCAL ) - 1 );
                 else
                 else
-                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 );
-                LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) );
+                    layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", Visibility.LOCAL ).get( m.<Integer>read( "i", Visibility.LOCAL ) + 1 );
+                LayeredGraphNode u = m.<ArrayList<LayeredGraphNode>>read( "neighbors", Visibility.LOCAL ).get( m.read( "m", Visibility.LOCAL ) );
                 return (double)layerBefore.indexOf( u );
                 return (double)layerBefore.indexOf( u );
             }
             }
         }) );
         }) );

+ 39 - 17
src/codelines/AbstractForLoop.java

@@ -1,13 +1,19 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
+/**
+ * the initial line of a for loop
+ * @author kolja
+ *
+ * @param <T> the type of the iteration variable
+ */
 public abstract class AbstractForLoop<T> extends CodeLine {
 public abstract class AbstractForLoop<T> extends CodeLine {
 
 
     String loopVar;
     String loopVar;
@@ -19,10 +25,10 @@ public abstract class AbstractForLoop<T> extends CodeLine {
     
     
     @Override
     @Override
     public ControlFlow runForward(Memory m) {
     public ControlFlow runForward(Memory m) {
-        if( !m.isDefined( loopVar, MemoryType.LOCAL ) )
+        if( !m.isDefined( loopVar, Visibility.LOCAL ) )
         { // first loop step
         { // first loop step
             m.addFrame( new StackFrame( FrameType.LOOP ) );
             m.addFrame( new StackFrame( FrameType.LOOP ) );
-            m.declare( loopVar, begin( m.createReadOnlyMemory() ), MemoryType.LOCAL ); // set loop variable
+            m.declare( loopVar, intialize( m.createReadOnlyMemory() ), Visibility.LOCAL ); // set loop variable
             if( !condition( m.createReadOnlyMemory() ) ) // prove if the loop has finished
             if( !condition( m.createReadOnlyMemory() ) ) // prove if the loop has finished
             {
             {
                 m.removeFrame();
                 m.removeFrame();
@@ -35,31 +41,47 @@ public abstract class AbstractForLoop<T> extends CodeLine {
             return new ControlFlow( ControlFlow.STEP_INTO );
             return new ControlFlow( ControlFlow.STEP_INTO );
         }
         }
         T next = step( m.createReadOnlyMemory() );
         T next = step( m.createReadOnlyMemory() );
-        T old = m.read( loopVar, MemoryType.LOCAL );
-        m.write( loopVar, next, MemoryType.LOCAL );
+        T old = m.read( loopVar, Visibility.LOCAL );
+        m.write( loopVar, next, Visibility.LOCAL );
         if( !condition( m.createReadOnlyMemory() ) ) // prove if loop was finished
         if( !condition( m.createReadOnlyMemory() ) ) // prove if loop was finished
         {
         {
             StackFrame sf = m.removeFrame(); // remove loop stack
             StackFrame sf = m.removeFrame(); // remove loop stack
             actions.add( (Memory mem) -> {
             actions.add( (Memory mem) -> {
                 mem.addFrame( sf ); // restore last loop stack
                 mem.addFrame( sf ); // restore last loop stack
-                mem.write( loopVar, old, MemoryType.LOCAL );
+                mem.write( loopVar, old, Visibility.LOCAL );
             });
             });
             return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
             return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
         }
         }
         StackFrame oldF = m.removeFrame(); // fresh stack frame for loop body
         StackFrame oldF = m.removeFrame(); // fresh stack frame for loop body
         m.addFrame( new StackFrame( FrameType.LOOP ) );
         m.addFrame( new StackFrame( FrameType.LOOP ) );
-        m.declare( loopVar, next, MemoryType.LOCAL );
+        m.declare( loopVar, next, Visibility.LOCAL );
         actions.push( (Memory mem) -> {
         actions.push( (Memory mem) -> {
             mem.removeFrame();
             mem.removeFrame();
             mem.addFrame( oldF );
             mem.addFrame( oldF );
-            mem.write( loopVar, old, MemoryType.LOCAL );
+            mem.write( loopVar, old, Visibility.LOCAL );
         });
         });
         return new ControlFlow( ControlFlow.STEP_INTO );
         return new ControlFlow( ControlFlow.STEP_INTO );
     }
     }
     
     
-    abstract protected T begin( ReadOnlyMemory m );
+    /**
+     * the initialization step of the loop.
+     * only executed if the loop variable is undefined.
+     * @param m the memory in which the variables are stored
+     * @return the initial value of the iteration variable
+     */
+    protected abstract T intialize( ReadOnlyMemory m );
     
     
-    abstract protected T step( ReadOnlyMemory m );
+    /**
+     * the statement executed after each iteration
+     * @param m the memory in which the variables are stored
+     * @return the next value of the iteration variable
+     */
+    protected abstract T step( ReadOnlyMemory m );
     
     
-    abstract protected boolean condition( final ReadOnlyMemory m );
+    /**
+     * the exit condition of the loop
+     * @param m the memory in which the variables are stored
+     * @return false if the loop is over
+     */
+    protected abstract boolean condition( final ReadOnlyMemory m );
 }
 }

+ 0 - 74
src/codelines/BackwardForEachLoop.java

@@ -1,74 +0,0 @@
-package codelines;
-
-import java.util.List;
-
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.StackFrame.FrameType;
-
-public class BackwardForEachLoop <T> extends CodeLine {
-
-	String listVar;
-	String loopVar;
-	
-	public BackwardForEachLoop( String listName, String varName )
-	{
-		this.listVar = listName;
-		this.loopVar = varName;
-	}
-	
-	@Override
-	public ControlFlow runForward(Memory m) {
-		boolean declared = false; // prove if it is the first step in the loop
-		if( !m.isSomewhereDefined( "line_" + lineId + "_index", MemoryType.LOCAL ) )
-		{ // first loop step
-			m.declare( "line_" + lineId + "_index", m.<List<T>>read( listVar, MemoryType.LOCAL ).size() - 1, MemoryType.LOCAL );
-			declared = true;
-		}
-		if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) < 0 ) // prove if the loop has finished
-		{
-			m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
-			actions.push( (Memory mem) -> {});
-			return new ControlFlow( ControlFlow.STEP_OVER ); // don't execute the loop body
-		}
-		if( declared )
-		{
-			m.declare( loopVar, m.<List<T>>read( listVar, MemoryType.LOCAL ).get( m.read( "line_" + lineId + "_index", MemoryType.LOCAL ) ), MemoryType.LOCAL ); // set loop variable
-			m.addFrame( new StackFrame( FrameType.LOOP ) );
-			actions.push( (Memory mem) -> {
-				mem.removeFrame();
-				mem.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
-			} );
-		}
-		else
-		{
-			int oldIndex = m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL );
-			m.write( "line_" + lineId + "_index", oldIndex - 1, MemoryType.LOCAL ); // count index down
-			if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) < 0 ) // prove if loop was finished
-			{
-				StackFrame sf = m.removeFrame(); // remove loop stack
-                T old = m.read( loopVar, MemoryType.LOCAL );
-                m.undeclare( loopVar, MemoryType.LOCAL );
-				m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
-				actions.push( (Memory mem) -> {
-	                m.declare( loopVar, old, MemoryType.LOCAL );
-					mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
-					mem.addFrame( sf ); // restore last loop stack
-				});
-				return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
-			}
-			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
-			m.addFrame( new StackFrame( FrameType.LOOP ) );
-			m.write( loopVar, m.<List<T>>read( listVar, MemoryType.LOCAL ).get( m.read( "line_" + lineId + "_index", MemoryType.LOCAL ) ), MemoryType.LOCAL ); // update loop variable
-			actions.push( (Memory mem) -> {
-				mem.removeFrame();
-				mem.addFrame( old );
-				mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
-			});
-		}
-		return new ControlFlow( ControlFlow.STEP_INTO );
-	}
-}

+ 7 - 3
src/codelines/Comment.java

@@ -1,9 +1,13 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
 
 
+/**
+ * a comment in the pseudo code
+ * @author kolja
+ */
 public class Comment extends CodeLine{
 public class Comment extends CodeLine{
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {

+ 36 - 16
src/codelines/DeclareVariable.java

@@ -1,42 +1,62 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
+/**
+ * a line of code that declares a new variable
+ * @author kolja
+ *
+ * @param <T> the type of the variable
+ */
 public abstract class DeclareVariable <T> extends CodeLine {
 public abstract class DeclareVariable <T> extends CodeLine {
 
 
 	private boolean oldExists;
 	private boolean oldExists;
 	private String name;
 	private String name;
-	private MemoryType mt;
+	private Visibility vis;
     
     
+	/**
+	 * create the line of pseudo code (not the variable)
+	 * @param name the name of the variable
+	 */
     public DeclareVariable( String name )
     public DeclareVariable( String name )
     {
     {
         this.name = name;
         this.name = name;
-        this.mt = MemoryType.LOCAL;
+        this.vis = Visibility.LOCAL;
     }
     }
-	
-	public DeclareVariable( String name, MemoryType mt )
+
+    /**
+     * create the line of pseudo code (not the variable)
+     * @param name the name of the variable
+     * @param vis the visibility of the variable
+     */
+	public DeclareVariable( String name, Visibility vis )
 	{
 	{
 		this.name = name;
 		this.name = name;
-		this.mt = mt;
+		this.vis = vis;
 	}
 	}
 
 
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
 		
 		
-		oldExists = m.isDefined( name, mt );
-		T oldVal = m.read( name, mt );
-		m.declare( name, value( m.createReadOnlyMemory() ), mt );
+		oldExists = m.isDefined( name, vis );
+		T oldVal = m.read( name, vis );
+		m.declare( name, value( m.createReadOnlyMemory() ), vis );
 		actions.push( (Memory mem) -> {
 		actions.push( (Memory mem) -> {
-			mem.undeclare( name, mt );
+			mem.undeclare( name, vis );
             if( oldExists )
             if( oldExists )
-				mem.write( name, oldVal, mt );
+				mem.write( name, oldVal, vis );
 		});
 		});
 		return new ControlFlow( ControlFlow.STEP_OVER );
 		return new ControlFlow( ControlFlow.STEP_OVER );
 	}
 	}
 	
 	
-	abstract protected T value( ReadOnlyMemory m );
+	/**
+	 * returns the value that will be stored in the variable
+     * @param m the memory in which the variables are stored
+	 * @return the value
+	 */
+	protected abstract T value( ReadOnlyMemory m );
 }
 }

+ 20 - 20
src/codelines/ForEachLoop.java

@@ -2,13 +2,13 @@ package codelines;
 
 
 import java.util.List;
 import java.util.List;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 public abstract class ForEachLoop <T> extends CodeLine {
 public abstract class ForEachLoop <T> extends CodeLine {
 
 
@@ -22,47 +22,47 @@ public abstract class ForEachLoop <T> extends CodeLine {
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
 		boolean declared = false; // prove if it is the first step in the loop
 		boolean declared = false; // prove if it is the first step in the loop
-		if( !m.isSomewhereDefined( "line_" + lineId + "_index", MemoryType.LOCAL ) )
+		if( !m.isSomewhereDefined( "line_" + lineId + "_index", Visibility.LOCAL ) )
 		{ // first loop step
 		{ // first loop step
-			m.declare( "line_" + lineId + "_index", 0, MemoryType.LOCAL );
+			m.declare( "line_" + lineId + "_index", 0, Visibility.LOCAL );
 			declared = true;
 			declared = true;
 		}
 		}
-		if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) > list( m.createReadOnlyMemory() ).size() - 1 ) // prove if the loop has finished
+		if( m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL ) > list( m.createReadOnlyMemory() ).size() - 1 ) // prove if the loop has finished
 		{
 		{
-			m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+			m.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			actions.push( (Memory mem) -> {});
 			actions.push( (Memory mem) -> {});
 			return new ControlFlow( ControlFlow.STEP_OVER ); // don't execute the loop body
 			return new ControlFlow( ControlFlow.STEP_OVER ); // don't execute the loop body
 		}
 		}
 		if( declared )
 		if( declared )
 		{
 		{
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-            m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", MemoryType.LOCAL ) ), MemoryType.LOCAL ); // set loop variable
+            m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", Visibility.LOCAL ) ), Visibility.LOCAL ); // set loop variable
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
-				mem.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+				mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			} );
 			} );
 		}
 		}
 		else
 		else
 		{
 		{
-			int oldIndex = m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL );
-			m.write( "line_" + lineId + "_index", oldIndex + 1, MemoryType.LOCAL ); // count index down
-			if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) > list( m.createReadOnlyMemory() ).size() - 1 ) // prove if loop was finished
+			int oldIndex = m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL );
+			m.write( "line_" + lineId + "_index", oldIndex + 1, Visibility.LOCAL ); // count index down
+			if( m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL ) > list( m.createReadOnlyMemory() ).size() - 1 ) // prove if loop was finished
 			{
 			{
 				StackFrame sf = m.removeFrame(); // remove loop stack
 				StackFrame sf = m.removeFrame(); // remove loop stack
-				m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+				m.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 				actions.push( (Memory mem) -> {
 				actions.push( (Memory mem) -> {
-					mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
+					mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 					mem.addFrame( sf ); // restore last loop stack
 					mem.addFrame( sf ); // restore last loop stack
 				});
 				});
 				return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
 				return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
 			}
 			}
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-			m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", MemoryType.LOCAL ) ), MemoryType.LOCAL ); // update loop variable
+			m.declare( loopVar, list( m.createReadOnlyMemory() ).get( m.read( "line_" + lineId + "_index", Visibility.LOCAL ) ), Visibility.LOCAL ); // update loop variable
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
 				mem.addFrame( old );
 				mem.addFrame( old );
-				mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
+				mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 			});
 			});
 		}
 		}
 		return new ControlFlow( ControlFlow.STEP_INTO );
 		return new ControlFlow( ControlFlow.STEP_INTO );

+ 20 - 20
src/codelines/ForLoop.java

@@ -1,12 +1,12 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 public abstract class ForLoop extends CodeLine {
 public abstract class ForLoop extends CodeLine {
 
 
@@ -20,50 +20,50 @@ public abstract class ForLoop extends CodeLine {
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
 		boolean declared = false; // prove if it is the first step in the loop
 		boolean declared = false; // prove if it is the first step in the loop
-		if( !m.isSomewhereDefined( "line_" + lineId + "_index", MemoryType.LOCAL ) )
+		if( !m.isSomewhereDefined( "line_" + lineId + "_index", Visibility.LOCAL ) )
 		{ // first loop step
 		{ // first loop step
-			m.declare( "line_" + lineId + "_index", minimum( m.createReadOnlyMemory() ), MemoryType.LOCAL );
+			m.declare( "line_" + lineId + "_index", minimum( m.createReadOnlyMemory() ), Visibility.LOCAL );
 			declared = true;
 			declared = true;
 		}
 		}
-		if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) > maximum( m.createReadOnlyMemory() ) ) // prove if the loop has finished
+		if( m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL ) > maximum( m.createReadOnlyMemory() ) ) // prove if the loop has finished
 		{
 		{
-			m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+			m.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			actions.push( (Memory mem) -> {});
 			actions.push( (Memory mem) -> {});
 			return new ControlFlow( ControlFlow.STEP_OVER ); // don't execute the loop body
 			return new ControlFlow( ControlFlow.STEP_OVER ); // don't execute the loop body
 		}
 		}
 		if( declared )
 		if( declared )
 		{
 		{
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-            m.declare( loopVar, minimum( m.createReadOnlyMemory() ), MemoryType.LOCAL ); // set loop variable
+            m.declare( loopVar, minimum( m.createReadOnlyMemory() ), Visibility.LOCAL ); // set loop variable
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
-				mem.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+				mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
 			} );
 			} );
 		}
 		}
 		else
 		else
 		{
 		{
-			int oldIndex = m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL );
-			m.write( "line_" + lineId + "_index", oldIndex + 1, MemoryType.LOCAL ); // count index down
-			if( m.<Integer>read( "line_" + lineId + "_index", MemoryType.LOCAL ) > maximum( m.createReadOnlyMemory() ) ) // prove if loop was finished
+			int oldIndex = m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL );
+			m.write( "line_" + lineId + "_index", oldIndex + 1, Visibility.LOCAL ); // count index down
+			if( m.<Integer>read( "line_" + lineId + "_index", Visibility.LOCAL ) > maximum( m.createReadOnlyMemory() ) ) // prove if loop was finished
 			{
 			{
 				StackFrame sf = m.removeFrame(); // remove loop stack
 				StackFrame sf = m.removeFrame(); // remove loop stack
-				m.undeclare( "line_" + lineId + "_index", MemoryType.LOCAL );
+				m.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
                 //int old = m.read( loopVar, false );
                 //int old = m.read( loopVar, false );
                 //m.undeclare( loopVar, false );
                 //m.undeclare( loopVar, false );
 				actions.add( (Memory mem) -> {
 				actions.add( (Memory mem) -> {
 	                //m.declare( loopVar, old, false );
 	                //m.declare( loopVar, old, false );
-					mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
+					mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 					mem.addFrame( sf ); // restore last loop stack
 					mem.addFrame( sf ); // restore last loop stack
 				});
 				});
 				return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
 				return new ControlFlow( ControlFlow.STEP_OVER ); // step out of the loop
 			}
 			}
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-			m.declare( loopVar, (int)m.read( "line_" + lineId + "_index", MemoryType.LOCAL ), MemoryType.LOCAL ); // update loop variable
+			m.declare( loopVar, (int)m.read( "line_" + lineId + "_index", Visibility.LOCAL ), Visibility.LOCAL ); // update loop variable
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
 				mem.addFrame( old );
 				mem.addFrame( old );
-				mem.write( "line_" + lineId + "_index", oldIndex, MemoryType.LOCAL );
+				mem.write( "line_" + lineId + "_index", oldIndex, Visibility.LOCAL );
 			});
 			});
 		}
 		}
 		return new ControlFlow( ControlFlow.STEP_INTO );
 		return new ControlFlow( ControlFlow.STEP_INTO );

+ 7 - 7
src/codelines/FunctionCall.java

@@ -1,10 +1,10 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.PseudoCodeNode;
-import animation.Memory.MemoryType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.Visibility;
 
 
 public class FunctionCall extends CodeLine {
 public class FunctionCall extends CodeLine {
 
 
@@ -22,14 +22,14 @@ public class FunctionCall extends CodeLine {
 		int index = 1;
 		int index = 1;
 		for( String p : params )
 		for( String p : params )
 		{
 		{
-			m.declare( "param" + index, m.read( p, MemoryType.LOCAL ), MemoryType.GLOBAL );
+			m.declare( "param" + index, m.read( p, Visibility.LOCAL ), Visibility.GLOBAL );
 			index++;
 			index++;
 		}
 		}
 		actions.push( (Memory mem) -> {
 		actions.push( (Memory mem) -> {
 			int ind = 1;
 			int ind = 1;
 			for( @SuppressWarnings("unused") String p : params )
 			for( @SuppressWarnings("unused") String p : params )
 			{
 			{
-				m.undeclare( "param" + ind, MemoryType.GLOBAL );
+				m.undeclare( "param" + ind, Visibility.GLOBAL );
 				ind++;
 				ind++;
 			}
 			}
 		} );
 		} );

+ 12 - 12
src/codelines/FunctionDefinition.java

@@ -1,11 +1,11 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.StackFrame;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 public class FunctionDefinition extends CodeLine {
 public class FunctionDefinition extends CodeLine {
 
 
@@ -18,17 +18,17 @@ public class FunctionDefinition extends CodeLine {
 	
 	
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
-		if( !m.isDefined( "line_" + lineId + "_inside", MemoryType.LOCAL ) )
+		if( !m.isDefined( "line_" + lineId + "_inside", Visibility.LOCAL ) )
 		{
 		{
 			m.addFrame( new StackFrame( FrameType.FUNCTION ) );
 			m.addFrame( new StackFrame( FrameType.FUNCTION ) );
-			m.declare( "line_" + lineId + "_inside", true, MemoryType.LOCAL );
+			m.declare( "line_" + lineId + "_inside", true, Visibility.LOCAL );
 			int index = 1;
 			int index = 1;
 			Object olds[] = new Object[ params.length ];
 			Object olds[] = new Object[ params.length ];
 			for( String p : params )
 			for( String p : params )
 			{
 			{
-				olds[ index - 1 ] = m.read( "param" + index, MemoryType.GLOBAL );
-				m.declare( p, olds[ index - 1 ], MemoryType.LOCAL );
-				m.undeclare( "param" + index, MemoryType.GLOBAL );
+				olds[ index - 1 ] = m.read( "param" + index, Visibility.GLOBAL );
+				m.declare( p, olds[ index - 1 ], Visibility.LOCAL );
+				m.undeclare( "param" + index, Visibility.GLOBAL );
 				index++;
 				index++;
 			}
 			}
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
@@ -36,7 +36,7 @@ public class FunctionDefinition extends CodeLine {
 				int i = 1;
 				int i = 1;
 				for( @SuppressWarnings("unused") String p : params )
 				for( @SuppressWarnings("unused") String p : params )
 				{
 				{
-					mem.declare( "param" + i, olds[ i - 1], MemoryType.GLOBAL );
+					mem.declare( "param" + i, olds[ i - 1], Visibility.GLOBAL );
 					i++;
 					i++;
 				}
 				}
 			} );
 			} );

+ 9 - 9
src/codelines/IfLoop.java

@@ -1,12 +1,12 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 /**
 /**
  * Yey, IF is a LOOP.
  * Yey, IF is a LOOP.
@@ -17,7 +17,7 @@ public abstract class IfLoop extends CodeLine {
 
 
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
-		if( m.isDefined( "line_" + lineId + "_inside", MemoryType.LOCAL ) )
+		if( m.isDefined( "line_" + lineId + "_inside", Visibility.LOCAL ) )
 		{
 		{
 			StackFrame old = m.removeFrame();
 			StackFrame old = m.removeFrame();
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
@@ -29,7 +29,7 @@ public abstract class IfLoop extends CodeLine {
 		{
 		{
             if( condition( m.createReadOnlyMemory() ) ) {
             if( condition( m.createReadOnlyMemory() ) ) {
             	m.addFrame( new StackFrame( FrameType.LOOP ) );
             	m.addFrame( new StackFrame( FrameType.LOOP ) );
-            	m.declare( "line_" + lineId + "_inside", true, MemoryType.LOCAL );
+            	m.declare( "line_" + lineId + "_inside", true, Visibility.LOCAL );
             	actions.push( (Memory mem) -> {
             	actions.push( (Memory mem) -> {
             		mem.removeFrame();
             		mem.removeFrame();
             	} );
             	} );

+ 10 - 10
src/codelines/SetVariable.java

@@ -1,10 +1,10 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
 
 
 public abstract class SetVariable <T> extends CodeLine {
 public abstract class SetVariable <T> extends CodeLine {
 
 
@@ -19,14 +19,14 @@ public abstract class SetVariable <T> extends CodeLine {
     @Override
     @Override
     public ControlFlow runForward(Memory m) {
     public ControlFlow runForward(Memory m) {
         
         
-        oldExists = m.isDefined( name, MemoryType.LOCAL );
-        T oldVal = m.read( name, MemoryType.LOCAL );
-        m.write( name, value( m.createReadOnlyMemory() ), MemoryType.LOCAL );
+        oldExists = m.isDefined( name, Visibility.LOCAL );
+        T oldVal = m.read( name, Visibility.LOCAL );
+        m.write( name, value( m.createReadOnlyMemory() ), Visibility.LOCAL );
         actions.push( (Memory mem) -> {
         actions.push( (Memory mem) -> {
             if( !oldExists )
             if( !oldExists )
-                mem.undeclare( name, MemoryType.LOCAL );
+                mem.undeclare( name, Visibility.LOCAL );
             else
             else
-                mem.write( name, oldVal, MemoryType.LOCAL ); // TODO write in correct stack frame
+                mem.write( name, oldVal, Visibility.LOCAL );
         });
         });
         return new ControlFlow( ControlFlow.STEP_OVER );
         return new ControlFlow( ControlFlow.STEP_OVER );
     }
     }

+ 10 - 10
src/codelines/WhileLoop.java

@@ -1,19 +1,19 @@
 package codelines;
 package codelines;
 
 
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
-import animation.StackFrame;
-import animation.Memory.MemoryType;
-import animation.Memory.ReadOnlyMemory;
-import animation.StackFrame.FrameType;
+import algorithm.CodeLine;
+import processor.ControlFlow;
+import processor.Memory;
+import processor.StackFrame;
+import processor.Memory.ReadOnlyMemory;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 public abstract class WhileLoop extends CodeLine {
 public abstract class WhileLoop extends CodeLine {
 
 
 	@Override
 	@Override
 	public ControlFlow runForward(Memory m) {
 	public ControlFlow runForward(Memory m) {
 		boolean declared = false; // prove if it is the first step in the loop
 		boolean declared = false; // prove if it is the first step in the loop
-		if( !m.isDefined( "line_" + lineId + "_index", MemoryType.LOCAL ) )
+		if( !m.isDefined( "line_" + lineId + "_index", Visibility.LOCAL ) )
 		{ // first loop step
 		{ // first loop step
 			declared = true;
 			declared = true;
 		}
 		}
@@ -35,7 +35,7 @@ public abstract class WhileLoop extends CodeLine {
 		if( declared )
 		if( declared )
 		{
 		{
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-            m.declare( "line_" + lineId + "_index", 0, MemoryType.LOCAL );
+            m.declare( "line_" + lineId + "_index", 0, Visibility.LOCAL );
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
 			} );
 			} );
@@ -44,7 +44,7 @@ public abstract class WhileLoop extends CodeLine {
 		{
 		{
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			StackFrame old = m.removeFrame(); // fresh stack frame for loop body
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
 			m.addFrame( new StackFrame( FrameType.LOOP ) );
-            m.declare( "line_" + lineId + "_index", 0, MemoryType.LOCAL );
+            m.declare( "line_" + lineId + "_index", 0, Visibility.LOCAL );
 			actions.push( (Memory mem) -> {
 			actions.push( (Memory mem) -> {
 				mem.removeFrame();
 				mem.removeFrame();
 				mem.addFrame( old );
 				mem.addFrame( old );

+ 24 - 24
src/graph/LayeredEdge.java

@@ -52,13 +52,13 @@ public class LayeredEdge implements LayeredGraphEdge {
     @Override
     @Override
     public boolean isConflicted( LayoutType layout )
     public boolean isConflicted( LayoutType layout )
     {
     {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             return conflicted[ 0 ];
             return conflicted[ 0 ];
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             return conflicted[ 1 ];
             return conflicted[ 1 ];
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             return conflicted[ 2 ];
             return conflicted[ 2 ];
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             return conflicted[ 3 ];
             return conflicted[ 3 ];
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             return conflicted[ 4 ];
             return conflicted[ 4 ];
@@ -103,13 +103,13 @@ public class LayeredEdge implements LayeredGraphEdge {
             this.conflicted[ 3 ] = conflicted;
             this.conflicted[ 3 ] = conflicted;
             this.conflicted[ 4 ] = conflicted;
             this.conflicted[ 4 ] = conflicted;
         }
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             this.conflicted[ 0 ] = conflicted;
             this.conflicted[ 0 ] = conflicted;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             this.conflicted[ 1 ] = conflicted;
             this.conflicted[ 1 ] = conflicted;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             this.conflicted[ 2 ] = conflicted;
             this.conflicted[ 2 ] = conflicted;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             this.conflicted[ 3 ] = conflicted;
             this.conflicted[ 3 ] = conflicted;
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             this.conflicted[ 4 ] = conflicted;
             this.conflicted[ 4 ] = conflicted;
@@ -126,13 +126,13 @@ public class LayeredEdge implements LayeredGraphEdge {
             bindPoints[ 3 ].set( 0, new Point( x, y ) );
             bindPoints[ 3 ].set( 0, new Point( x, y ) );
             bindPoints[ 4 ].set( 0, new Point( x, y ) );
             bindPoints[ 4 ].set( 0, new Point( x, y ) );
         }
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             bindPoints[ 0 ].set( 0, new Point( x, y ) );
             bindPoints[ 0 ].set( 0, new Point( x, y ) );
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             bindPoints[ 1 ].set( 0, new Point( x, y ) );
             bindPoints[ 1 ].set( 0, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             bindPoints[ 2 ].set( 0, new Point( x, y ) );
             bindPoints[ 2 ].set( 0, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             bindPoints[ 3 ].set( 0, new Point( x, y ) );
             bindPoints[ 3 ].set( 0, new Point( x, y ) );
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             bindPoints[ 4 ].set( 0, new Point( x, y ) );
             bindPoints[ 4 ].set( 0, new Point( x, y ) );
@@ -149,13 +149,13 @@ public class LayeredEdge implements LayeredGraphEdge {
             bindPoints[ 3 ].add( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 3 ].add( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].add( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].add( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
         }
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             bindPoints[ 0 ].add( bindPoints[ 0 ].size() - 1, new Point( x, y ) );
             bindPoints[ 0 ].add( bindPoints[ 0 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             bindPoints[ 1 ].add( bindPoints[ 1 ].size() - 1, new Point( x, y ) );
             bindPoints[ 1 ].add( bindPoints[ 1 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             bindPoints[ 2 ].add( bindPoints[ 2 ].size() - 1, new Point( x, y ) );
             bindPoints[ 2 ].add( bindPoints[ 2 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             bindPoints[ 3 ].add( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 3 ].add( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             bindPoints[ 4 ].add( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].add( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
@@ -172,13 +172,13 @@ public class LayeredEdge implements LayeredGraphEdge {
             bindPoints[ 3 ].set( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 3 ].set( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].set( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].set( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
         }
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             bindPoints[ 0 ].set( bindPoints[ 0 ].size() - 1, new Point( x, y ) );
             bindPoints[ 0 ].set( bindPoints[ 0 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             bindPoints[ 1 ].set( bindPoints[ 1 ].size() - 1, new Point( x, y ) );
             bindPoints[ 1 ].set( bindPoints[ 1 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             bindPoints[ 2 ].set( bindPoints[ 2 ].size() - 1, new Point( x, y ) );
             bindPoints[ 2 ].set( bindPoints[ 2 ].size() - 1, new Point( x, y ) );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             bindPoints[ 3 ].set( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
             bindPoints[ 3 ].set( bindPoints[ 3 ].size() - 1, new Point( x, y ) );
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             bindPoints[ 4 ].set( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
             bindPoints[ 4 ].set( bindPoints[ 4 ].size() - 1, new Point( x, y ) );
@@ -191,13 +191,13 @@ public class LayeredEdge implements LayeredGraphEdge {
         NodeView targetView = ((LayeredNode)targets.get( 0 )).getView( layout );
         NodeView targetView = ((LayeredNode)targets.get( 0 )).getView( layout );
         setStartPoint( sourceView.getVirtualX() + sourceView.getVirtualWidth() / 2, sourceView.getVirtualY() + sourceView.getVirtualHeight(), layout );
         setStartPoint( sourceView.getVirtualX() + sourceView.getVirtualWidth() / 2, sourceView.getVirtualY() + sourceView.getVirtualHeight(), layout );
         setEndPoint( targetView.getVirtualX() + targetView.getVirtualWidth() / 2, targetView.getVirtualY(), layout );
         setEndPoint( targetView.getVirtualX() + targetView.getVirtualWidth() / 2, targetView.getVirtualY(), layout );
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             return bindPoints[ 0 ];
             return bindPoints[ 0 ];
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             return bindPoints[ 1 ];
             return bindPoints[ 1 ];
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             return bindPoints[ 2 ];
             return bindPoints[ 2 ];
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             return bindPoints[ 3 ];
             return bindPoints[ 3 ];
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             return bindPoints[ 4 ];
             return bindPoints[ 4 ];

+ 1 - 0
src/graph/LayeredGraphEdge.java

@@ -15,6 +15,7 @@ import bk.LayoutType;
 public interface LayeredGraphEdge {
 public interface LayeredGraphEdge {
 
 
     /**
     /**
+     * Gibt die originale Kante des Elk Graphen zur�ck
      * @return Gibt die originale Kante des Elk Graphen zur�ck
      * @return Gibt die originale Kante des Elk Graphen zur�ck
      */
      */
     public ElkEdge getOriginalEdge();
     public ElkEdge getOriginalEdge();

+ 5 - 5
src/graph/LayeredGraphNode.java

@@ -20,7 +20,7 @@ public interface LayeredGraphNode {
   /**
   /**
    * Gibt den originalen Elk Knoten zur�ck
    * Gibt den originalen Elk Knoten zur�ck
    * 
    * 
-   * @return
+   * @return den originalen Elk Knoten
    */
    */
   public ElkNode getOriginalNode();
   public ElkNode getOriginalNode();
 
 
@@ -171,14 +171,14 @@ public interface LayeredGraphNode {
   /**
   /**
    * mark the node as "selected" in the given layout
    * mark the node as "selected" in the given layout
    * or in all layouts if the argument is null.
    * or in all layouts if the argument is null.
-   * @param layout
+   * @param layout the layout
    */
    */
   public void setSelected(LayoutType layout);
   public void setSelected(LayoutType layout);
 
 
   /**
   /**
    * checks if the node is selected in the given layout
    * checks if the node is selected in the given layout
-   * @param layout
-   * @return
+   * @param layout the layout
+   * @return true, iff it is selected
    */
    */
   public boolean isSelected(LayoutType layout);
   public boolean isSelected(LayoutType layout);
 
 
@@ -191,7 +191,7 @@ public interface LayeredGraphNode {
 
 
   /**
   /**
    * checks whether this node is a dummy node
    * checks whether this node is a dummy node
-   * @param dummy is it?
+   * @return is it?
    */
    */
   public boolean isDummyNode();
   public boolean isDummyNode();
 
 

+ 121 - 121
src/graph/LayeredNode.java

@@ -34,7 +34,7 @@ public class LayeredNode implements LayeredGraphNode {
         // Block Calculation
         // Block Calculation
         public LayeredGraphNode align;
         public LayeredGraphNode align;
         public LayeredGraphNode root;
         public LayeredGraphNode root;
-        // Compaction
+        // HorizontalCompaction
         public LayeredGraphNode sink;
         public LayeredGraphNode sink;
         public double shift;
         public double shift;
         private NodeView view;
         private NodeView view;
@@ -136,26 +136,26 @@ public class LayeredNode implements LayeredGraphNode {
     }
     }
 
 
     public void setView(NodeView view, LayoutType layout) {
     public void setView(NodeView view, LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].view = view;
             this.layouts[0].view = view;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].view = view;
             this.layouts[1].view = view;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].view = view;
             this.layouts[2].view = view;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].view = view;
             this.layouts[3].view = view;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             this.combined.view = view;
             this.combined.view = view;
     }
     }
 
 
     public NodeView getView(LayoutType layout) {
     public NodeView getView(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return layouts[0].view;
             return layouts[0].view;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return layouts[1].view;
             return layouts[1].view;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return layouts[2].view;
             return layouts[2].view;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return layouts[3].view;
             return layouts[3].view;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             return combined.view;
             return combined.view;
@@ -180,25 +180,25 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[2].shift = shift;
             this.layouts[2].shift = shift;
             this.layouts[3].shift = shift;
             this.layouts[3].shift = shift;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].shift = shift;
             this.layouts[0].shift = shift;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].shift = shift;
             this.layouts[1].shift = shift;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].shift = shift;
             this.layouts[2].shift = shift;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].shift = shift;
             this.layouts[3].shift = shift;
     }
     }
 
 
     @Override
     @Override
     public double getShift(LayoutType layout) {
     public double getShift(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].shift;
             return this.layouts[0].shift;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].shift;
             return this.layouts[1].shift;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].shift;
             return this.layouts[2].shift;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].shift;
             return this.layouts[3].shift;
         return 0;
         return 0;
     }
     }
@@ -211,38 +211,38 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[2].sink = sink;
             this.layouts[2].sink = sink;
             this.layouts[3].sink = sink;
             this.layouts[3].sink = sink;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].sink = sink;
             this.layouts[0].sink = sink;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].sink = sink;
             this.layouts[1].sink = sink;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].sink = sink;
             this.layouts[2].sink = sink;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].sink = sink;
             this.layouts[3].sink = sink;
     }
     }
 
 
     @Override
     @Override
     public LayeredGraphNode getSink(LayoutType layout) {
     public LayeredGraphNode getSink(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].sink;
             return this.layouts[0].sink;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].sink;
             return this.layouts[1].sink;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].sink;
             return this.layouts[2].sink;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].sink;
             return this.layouts[3].sink;
         return null;
         return null;
     }
     }
 
 
     @Override
     @Override
     public boolean isXUndefined(LayoutType layout) {
     public boolean isXUndefined(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].xUndef;
             return this.layouts[0].xUndef;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].xUndef;
             return this.layouts[1].xUndef;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].xUndef;
             return this.layouts[2].xUndef;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].xUndef;
             return this.layouts[3].xUndef;
         return true;
         return true;
     }
     }
@@ -255,25 +255,25 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[2].align = align;
             this.layouts[2].align = align;
             this.layouts[3].align = align;
             this.layouts[3].align = align;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].align = align;
             this.layouts[0].align = align;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].align = align;
             this.layouts[1].align = align;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].align = align;
             this.layouts[2].align = align;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].align = align;
             this.layouts[3].align = align;
     }
     }
 
 
     @Override
     @Override
     public LayeredGraphNode getAlign(LayoutType layout) {
     public LayeredGraphNode getAlign(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].align;
             return this.layouts[0].align;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].align;
             return this.layouts[1].align;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].align;
             return this.layouts[2].align;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].align;
             return this.layouts[3].align;
         return null;
         return null;
     }
     }
@@ -286,25 +286,25 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[2].root = root;
             this.layouts[2].root = root;
             this.layouts[3].root = root;
             this.layouts[3].root = root;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].root = root;
             this.layouts[0].root = root;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].root = root;
             this.layouts[1].root = root;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].root = root;
             this.layouts[2].root = root;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].root = root;
             this.layouts[3].root = root;
     }
     }
 
 
     @Override
     @Override
     public LayeredGraphNode getRoot(LayoutType layout) {
     public LayeredGraphNode getRoot(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].root;
             return this.layouts[0].root;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].root;
             return this.layouts[1].root;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].root;
             return this.layouts[2].root;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].root;
             return this.layouts[3].root;
         return null;
         return null;
     }
     }
@@ -318,13 +318,13 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[3].selected = true;
             this.layouts[3].selected = true;
             combined.selected = true;
             combined.selected = true;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].selected = true;
             this.layouts[0].selected = true;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].selected = true;
             this.layouts[1].selected = true;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].selected = true;
             this.layouts[2].selected = true;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].selected = true;
             this.layouts[3].selected = true;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             combined.selected = true;
             combined.selected = true;
@@ -344,16 +344,16 @@ public class LayeredNode implements LayeredGraphNode {
 
 
     @Override
     @Override
     public boolean isSelected(LayoutType layout) {
     public boolean isSelected(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT) {
+        if (layout == LayoutType.LEFTMOST_UPPER) {
             return layouts[0].selected;
             return layouts[0].selected;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT) {
+        if (layout == LayoutType.RIGHTMOST_UPPER) {
             return layouts[1].selected;
             return layouts[1].selected;
         }
         }
-        if (layout == LayoutType.BOTTOM_TOP_LEFT) {
+        if (layout == LayoutType.LEFTMOST_LOWER) {
             return layouts[2].selected;
             return layouts[2].selected;
         }
         }
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT) {
+        if (layout == LayoutType.RIGHTMOST_LOWER) {
             return layouts[3].selected;
             return layouts[3].selected;
         }
         }
         if (layout == LayoutType.COMBINED) {
         if (layout == LayoutType.COMBINED) {
@@ -372,13 +372,13 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[ 2 ].color = c;
             this.layouts[ 2 ].color = c;
             this.layouts[ 3 ].color = c;
             this.layouts[ 3 ].color = c;
         }
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
+        if( layout == LayoutType.LEFTMOST_UPPER )
             this.layouts[ 0 ].color = c;
             this.layouts[ 0 ].color = c;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_UPPER )
             this.layouts[ 1 ].color = c;
             this.layouts[ 1 ].color = c;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
+        if( layout == LayoutType.LEFTMOST_LOWER )
             this.layouts[ 2 ].color = c;
             this.layouts[ 2 ].color = c;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             this.layouts[ 3 ].color = c;
             this.layouts[ 3 ].color = c;
     }
     }
 
 
@@ -395,29 +395,29 @@ public class LayeredNode implements LayeredGraphNode {
 
 
     @Override
     @Override
     public Color getClassColor(LayoutType layout) {
     public Color getClassColor(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].sink == this && calcClassSize(this, layout) == 1)
+        if (layout == LayoutType.LEFTMOST_UPPER && this.layouts[0].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].sink == this)
+        if (layout == LayoutType.LEFTMOST_UPPER && this.layouts[0].sink == this)
             return this.layouts[0].color;
             return this.layouts[0].color;
-        else if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        else if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].sink.getClassColor(layout);
             return this.layouts[0].sink.getClassColor(layout);
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].sink == this && calcClassSize(this, layout) == 1)
+        if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].sink == this)
+        if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].sink == this)
             return this.layouts[1].color;
             return this.layouts[1].color;
-        else if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        else if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].sink.getClassColor(layout);
             return this.layouts[1].sink.getClassColor(layout);
-        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].sink == this && calcClassSize(this, layout) == 1)
+        if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].sink == this)
+        if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].sink == this)
             return this.layouts[2].color;
             return this.layouts[2].color;
-        else if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        else if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].sink.getClassColor(layout);
             return this.layouts[2].sink.getClassColor(layout);
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].sink == this && calcClassSize(this, layout) == 1)
+        if (layout == LayoutType.RIGHTMOST_LOWER && this.layouts[3].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].sink == this )
+        if( layout == LayoutType.RIGHTMOST_LOWER && this.layouts[ 3 ].sink == this )
             return this.layouts[ 3 ].color;
             return this.layouts[ 3 ].color;
-        else if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        else if( layout == LayoutType.RIGHTMOST_LOWER )
             return this.layouts[ 3 ].sink.getClassColor( layout );
             return this.layouts[ 3 ].sink.getClassColor( layout );
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
@@ -429,29 +429,29 @@ public class LayeredNode implements LayeredGraphNode {
     {
     {
         if( layout == null )
         if( layout == null )
             return this.layouts[ 0 ].color;
             return this.layouts[ 0 ].color;
-        if( layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[ 0 ].root == this && this.layouts[ 0 ].align == this )
+        if( layout == LayoutType.LEFTMOST_UPPER && this.layouts[ 0 ].root == this && this.layouts[ 0 ].align == this )
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].root != this)
+        if (layout == LayoutType.LEFTMOST_UPPER && this.layouts[0].root != this)
             return this.layouts[0].root.getColor(layout);
             return this.layouts[0].root.getColor(layout);
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].color;
             return this.layouts[0].color;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].root == this && this.layouts[1].align == this)
+        if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].root == this && this.layouts[1].align == this)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].root != this)
+        if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].root != this)
             return this.layouts[1].root.getColor(layout);
             return this.layouts[1].root.getColor(layout);
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].color;
             return this.layouts[1].color;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].root == this && this.layouts[2].align == this)
+        if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].root == this && this.layouts[2].align == this)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].root != this)
+        if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].root != this)
             return this.layouts[2].root.getColor(layout);
             return this.layouts[2].root.getColor(layout);
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].color;
             return this.layouts[2].color;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].root == this && this.layouts[3].align == this)
+        if (layout == LayoutType.RIGHTMOST_LOWER && this.layouts[3].root == this && this.layouts[3].align == this)
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].root != this )
+        if( layout == LayoutType.RIGHTMOST_LOWER && this.layouts[ 3 ].root != this )
             return this.layouts[ 3 ].root.getColor( layout );
             return this.layouts[ 3 ].root.getColor( layout );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+        if( layout == LayoutType.RIGHTMOST_LOWER )
             return this.layouts[ 3 ].color;
             return this.layouts[ 3 ].color;
         if( layout == LayoutType.COMBINED )
         if( layout == LayoutType.COMBINED )
             return Color.LIGHT_GRAY;
             return Color.LIGHT_GRAY;
@@ -502,19 +502,19 @@ public class LayeredNode implements LayeredGraphNode {
             layouts[3].x = x;
             layouts[3].x = x;
             combined.x = x;
             combined.x = x;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT) {
+        if (layout == LayoutType.LEFTMOST_UPPER) {
             layouts[0].xUndef = !def;
             layouts[0].xUndef = !def;
             layouts[0].x = x;
             layouts[0].x = x;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT) {
+        if (layout == LayoutType.RIGHTMOST_UPPER) {
             layouts[1].xUndef = !def;
             layouts[1].xUndef = !def;
             layouts[1].x = x;
             layouts[1].x = x;
         }
         }
-        if (layout == LayoutType.BOTTOM_TOP_LEFT) {
+        if (layout == LayoutType.LEFTMOST_LOWER) {
             layouts[2].xUndef = !def;
             layouts[2].xUndef = !def;
             layouts[2].x = x;
             layouts[2].x = x;
         }
         }
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT) {
+        if (layout == LayoutType.RIGHTMOST_LOWER) {
             layouts[3].xUndef = !def;
             layouts[3].xUndef = !def;
             layouts[3].x = x;
             layouts[3].x = x;
         }
         }
@@ -531,13 +531,13 @@ public class LayeredNode implements LayeredGraphNode {
             layouts[3].y = y;
             layouts[3].y = y;
             combined.y = y;
             combined.y = y;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             layouts[0].y = y;
             layouts[0].y = y;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             layouts[1].y = y;
             layouts[1].y = y;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             layouts[2].y = y;
             layouts[2].y = y;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             layouts[3].y = y;
             layouts[3].y = y;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             combined.y = y;
             combined.y = y;
@@ -545,13 +545,13 @@ public class LayeredNode implements LayeredGraphNode {
 
 
     @Override
     @Override
     public double getX(LayoutType layout) {
     public double getX(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].x;
             return this.layouts[0].x;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].x;
             return this.layouts[1].x;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].x;
             return this.layouts[2].x;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].x;
             return this.layouts[3].x;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             return combined.x;
             return combined.x;
@@ -560,13 +560,13 @@ public class LayeredNode implements LayeredGraphNode {
 
 
     @Override
     @Override
     public double getY(LayoutType layout) {
     public double getY(LayoutType layout) {
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return this.layouts[0].y;
             return this.layouts[0].y;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return this.layouts[1].y;
             return this.layouts[1].y;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return this.layouts[2].y;
             return this.layouts[2].y;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return this.layouts[3].y;
             return this.layouts[3].y;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             return combined.y;
             return combined.y;
@@ -584,24 +584,24 @@ public class LayeredNode implements LayeredGraphNode {
                     max = n.getX(layout) + n.getWidth(layout);
                     max = n.getX(layout) + n.getWidth(layout);
                 min = Math.min( n.getX(layout), min);
                 min = Math.min( n.getX(layout), min);
             }
             }
-            if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            if (layout == LayoutType.LEFTMOST_UPPER)
                 return Math.max(max - min, layouts[0].w);
                 return Math.max(max - min, layouts[0].w);
-            if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            if (layout == LayoutType.RIGHTMOST_UPPER)
                 return Math.max(max - min, layouts[1].w);
                 return Math.max(max - min, layouts[1].w);
-            if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            if (layout == LayoutType.LEFTMOST_LOWER)
                 return Math.max(max - min, layouts[2].w);
                 return Math.max(max - min, layouts[2].w);
-            if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            if (layout == LayoutType.RIGHTMOST_LOWER)
                 return Math.max(max - min, layouts[3].w);
                 return Math.max(max - min, layouts[3].w);
             if (layout == LayoutType.COMBINED)
             if (layout == LayoutType.COMBINED)
                 return Math.max(max - min, combined.w);
                 return Math.max(max - min, combined.w);
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return layouts[0].w;
             return layouts[0].w;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return layouts[1].w;
             return layouts[1].w;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return layouts[2].w;
             return layouts[2].w;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return layouts[3].w;
             return layouts[3].w;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             return combined.w;
             return combined.w;
@@ -618,24 +618,24 @@ public class LayeredNode implements LayeredGraphNode {
         		if( max < n.getY(layout) + n.getHeight(layout) )
         		if( max < n.getY(layout) + n.getHeight(layout) )
         			max = n.getY(layout) + n.getHeight(layout);
         			max = n.getY(layout) + n.getHeight(layout);
         	}
         	}
-            if( layout == LayoutType.TOP_BOTTOM_LEFT )
+            if( layout == LayoutType.LEFTMOST_UPPER )
                 return Math.max( max, layouts[ 0 ].h );
                 return Math.max( max, layouts[ 0 ].h );
-            if( layout == LayoutType.TOP_BOTTOM_RIGHT )
+            if( layout == LayoutType.RIGHTMOST_UPPER )
                 return Math.max( max, layouts[ 1 ].h );
                 return Math.max( max, layouts[ 1 ].h );
-            if( layout == LayoutType.BOTTOM_TOP_LEFT )
+            if( layout == LayoutType.LEFTMOST_LOWER )
                 return Math.max( max, layouts[ 2 ].h );
                 return Math.max( max, layouts[ 2 ].h );
-            if( layout == LayoutType.BOTTOM_TOP_RIGHT )
+            if( layout == LayoutType.RIGHTMOST_LOWER )
                 return Math.max( max, layouts[ 3 ].h );
                 return Math.max( max, layouts[ 3 ].h );
             if( layout == LayoutType.COMBINED )
             if( layout == LayoutType.COMBINED )
                 return Math.max( max, combined.h );
                 return Math.max( max, combined.h );
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             return layouts[0].h;
             return layouts[0].h;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             return layouts[1].h;
             return layouts[1].h;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             return layouts[2].h;
             return layouts[2].h;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             return layouts[3].h;
             return layouts[3].h;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             return combined.h;
             return combined.h;
@@ -651,13 +651,13 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[3].w = w;
             this.layouts[3].w = w;
             combined.w = w;
             combined.w = w;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].w = w;
             this.layouts[0].w = w;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].w = w;
             this.layouts[1].w = w;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].w = w;
             this.layouts[2].w = w;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].w = w;
             this.layouts[3].w = w;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             combined.w = w;
             combined.w = w;
@@ -672,13 +672,13 @@ public class LayeredNode implements LayeredGraphNode {
             this.layouts[3].h = h;
             this.layouts[3].h = h;
             combined.h = h;
             combined.h = h;
         }
         }
-        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+        if (layout == LayoutType.LEFTMOST_UPPER)
             this.layouts[0].h = h;
             this.layouts[0].h = h;
-        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_UPPER)
             this.layouts[1].h = h;
             this.layouts[1].h = h;
-        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+        if (layout == LayoutType.LEFTMOST_LOWER)
             this.layouts[2].h = h;
             this.layouts[2].h = h;
-        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+        if (layout == LayoutType.RIGHTMOST_LOWER)
             this.layouts[3].h = h;
             this.layouts[3].h = h;
         if (layout == LayoutType.COMBINED)
         if (layout == LayoutType.COMBINED)
             combined.h = h;
             combined.h = h;

+ 5 - 5
src/lib/SimpleNodePlacement.java

@@ -32,20 +32,20 @@ public class SimpleNodePlacement {
         double maxWidth = 0, maxHeight = 0;
         double maxWidth = 0, maxHeight = 0;
         
         
         for (LayeredGraphNode node : graph.getContainedNodes()) { // Suche die maximale Knotengröße
         for (LayeredGraphNode node : graph.getContainedNodes()) { // Suche die maximale Knotengröße
-            maxWidth = Math.max(node.getWidth( LayoutType.TOP_BOTTOM_LEFT ), maxWidth);
-            maxHeight = Math.max(node.getHeight( LayoutType.TOP_BOTTOM_LEFT ), maxHeight);
+            maxWidth = Math.max(node.getWidth( LayoutType.LEFTMOST_UPPER ), maxWidth);
+            maxHeight = Math.max(node.getHeight( LayoutType.LEFTMOST_UPPER ), maxHeight);
         }
         }
         
         
         ArrayList< ArrayList< LayeredGraphNode > > layers = graph.getContainedLayers();
         ArrayList< ArrayList< LayeredGraphNode > > layers = graph.getContainedLayers();
         for (ArrayList<LayeredGraphNode> layer : layers) { // Gehe alle Layer durch
         for (ArrayList<LayeredGraphNode> layer : layers) { // Gehe alle Layer durch
             maxHeight = 0;
             maxHeight = 0;
             for (LayeredGraphNode node : layer) { // Gehe alle Knoten durch
             for (LayeredGraphNode node : layer) { // Gehe alle Knoten durch
-                maxHeight = Math.max(node.getHeight( LayoutType.TOP_BOTTOM_LEFT ), maxHeight);
+                maxHeight = Math.max(node.getHeight( LayoutType.LEFTMOST_UPPER ), maxHeight);
             }
             }
             int curX = 0;
             int curX = 0;
             for (LayeredGraphNode node : layer) { // Gehe alle Knoten durch
             for (LayeredGraphNode node : layer) { // Gehe alle Knoten durch
-                node.setX( curX + maxWidth / 2 - node.getWidth( LayoutType.TOP_BOTTOM_LEFT ) / 2, false, null );
-                node.setY( curY + maxHeight / 2 - node.getHeight( LayoutType.TOP_BOTTOM_LEFT ) / 2, null ); // Position setzen
+                node.setX( curX + maxWidth / 2 - node.getWidth( LayoutType.LEFTMOST_UPPER ) / 2, false, null );
+                node.setY( curY + maxHeight / 2 - node.getHeight( LayoutType.LEFTMOST_UPPER ) / 2, null ); // Position setzen
                 curX += maxWidth + 20;
                 curX += maxWidth + 20;
             }
             }
             curY += maxHeight + 20;
             curY += maxHeight + 20;

+ 1 - 1
src/lib/TextLayoutHelper.java

@@ -6,7 +6,7 @@ import java.util.regex.Pattern;
 
 
 public class TextLayoutHelper {
 public class TextLayoutHelper {
     /**
     /**
-     * Modifies the given string such that its lenght matches the given length.
+     * Modifies the given string such that its length matches the given length.
      * If the string is too small, whitespace is appended on both sides equally.
      * If the string is too small, whitespace is appended on both sides equally.
      * Then, if the string is too large, it is cut off on the right.
      * Then, if the string is too large, it is cut off on the right.
      * @param s the string
      * @param s the string

+ 10 - 2
src/animation/ControlFlow.java → src/processor/ControlFlow.java

@@ -1,6 +1,6 @@
-package animation;
+package processor;
 
 
-import animation.CodeLine.BackwardAction;
+import algorithm.CodeLine.BackwardAction;
 
 
 public class ControlFlow {
 public class ControlFlow {
     public static final int STEP_INTO = 0;
     public static final int STEP_INTO = 0;
@@ -12,6 +12,10 @@ public class ControlFlow {
     private PseudoCodeNode jumpBack;
     private PseudoCodeNode jumpBack;
     private BackwardAction reverse;
     private BackwardAction reverse;
     
     
+    /**
+     * creates a new {@link ControlFlow} from a given status
+     * @param status one of ControlFlow.STEP_INTO, ControlFlow.STEP_OVER or ControlFlow.CALL
+     */
     public ControlFlow( int status )
     public ControlFlow( int status )
     {
     {
         this.status = status;
         this.status = status;
@@ -20,6 +24,10 @@ public class ControlFlow {
         reverse = null;
         reverse = null;
     }
     }
     
     
+    /**
+     * creates a new {@link ControlFlow} that is a function call
+     * @param functionNode the {@link PseudoCodeNode} of the function to call
+     */
     public ControlFlow( PseudoCodeNode functionNode )
     public ControlFlow( PseudoCodeNode functionNode )
     {
     {
     	status = CALL;
     	status = CALL;

+ 79 - 19
src/animation/Memory.java → src/processor/Memory.java

@@ -1,31 +1,50 @@
-package animation;
+package processor;
 
 
 import java.util.Stack;
 import java.util.Stack;
 
 
-import animation.StackFrame.FrameType;
+import processor.StackFrame.FrameType;
 
 
+/**
+ * manages the memory for a {@link PseudoCodeProcessor}
+ * @author kolja
+ *
+ */
 public class Memory {
 public class Memory {
 
 
-    public enum MemoryType
+    /**
+     * The visibility of a variable
+     * GLOBAL means that the variable can be accessed by using its name
+     * LOCAL means that the variable can only be accessed if it is on the topmost {@link StackFrame}.
+     * COMPLETE_STACK is the same as LOCAL for write access but for read access the whole {@link Stack} is searched.
+     * @author kolja
+     *
+     */
+    public enum Visibility
     {
     {
         GLOBAL,
         GLOBAL,
         LOCAL,
         LOCAL,
         COMPLETE_STACK
         COMPLETE_STACK
     }
     }
-    
+
+    /**
+     * a memory without the possibility to update or insert values.
+     * physically this is the same storage as the corresponding {@link Memory} object so there the values can still be initialized.
+     * @author kolja
+     *
+     */
     public class ReadOnlyMemory
     public class ReadOnlyMemory
     {
     {
-        public <T> T read( String name, MemoryType type )
+        public <T> T read( String name, Visibility type )
         {
         {
             return Memory.this.read( name, type );
             return Memory.this.read( name, type );
         }
         }
         
         
-        public boolean isSomewhereDefined( String name, MemoryType type )
+        public boolean isSomewhereDefined( String name, Visibility type )
         {
         {
             return Memory.this.isSomewhereDefined( name, type );
             return Memory.this.isSomewhereDefined( name, type );
         }
         }
         
         
-        public boolean isDefined( String name, MemoryType type )
+        public boolean isDefined( String name, Visibility type )
         {
         {
             return Memory.this.isDefined( name, type );
             return Memory.this.isDefined( name, type );
         }
         }
@@ -61,9 +80,16 @@ public class Memory {
         return stack.pop();
         return stack.pop();
     }
     }
     
     
-    public synchronized <T> void declare( String name, T value, MemoryType type )
+    /**
+     * declare a new variable
+     * @param name the name of the variable
+     * @param value the value of the variable
+     * @param visibility visibility of the variable
+     * @param <T> the type of the variable
+     */
+    public synchronized <T> void declare( String name, T value, Visibility visibility )
     {
     {
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             this.global.declare( name, value );
             this.global.declare( name, value );
@@ -74,12 +100,23 @@ public class Memory {
         		return;
         		return;
             stack.peek().declare( name, value );
             stack.peek().declare( name, value );
             break;
             break;
+        default:
+            assert false;
+            break;
         }
         }
     }
     }
     
     
-    public synchronized <T> void write( String name, T value, MemoryType type )
+    /**
+     * Writes a value to a previously declared variable.
+     * If the variable hat not been declared yet, nothing happens.
+     * @param name the name of the variable
+     * @param value the value of the variable
+     * @param visibility visibility of the variable
+     * @param <T> the type of the variable
+     */
+    public synchronized <T> void write( String name, T value, Visibility visibility )
     {
     {
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             this.global.set( name, value );
             this.global.set( name, value );
@@ -97,13 +134,24 @@ public class Memory {
         	   if( stackF.getType() == FrameType.FUNCTION )
         	   if( stackF.getType() == FrameType.FUNCTION )
         		   break;
         		   break;
         	}
         	}
+        	break;
+        default:
+            assert false;
+            break;
         }
         }
     }
     }
     
     
-    public synchronized <T> T read( String name, MemoryType type )
+    /**
+     * 
+     * @param name the name of the variable
+     * @param visibility visibility of the variable
+     * @param <T> the type of the variable
+     * @return
+     */
+    public synchronized <T> T read( String name, Visibility visibility )
     {
     {
         int index = stack.size() - 1;
         int index = stack.size() - 1;
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             return this.global.get( name );
             return this.global.get( name );
@@ -122,14 +170,18 @@ public class Memory {
                 if( stackF.isDefined( name ) )
                 if( stackF.isDefined( name ) )
                     return stackF.get( name );
                     return stackF.get( name );
              }
              }
+            break;
+        default:
+            assert false;
+            break;
         }
         }
         return null;
         return null;
     }
     }
     
     
-    public synchronized boolean isSomewhereDefined( String name, MemoryType type )
+    public synchronized boolean isSomewhereDefined( String name, Visibility visibility )
     {
     {
         int index = stack.size() - 1;
         int index = stack.size() - 1;
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             return this.global.isDefined( name );
             return this.global.isDefined( name );
@@ -148,13 +200,16 @@ public class Memory {
                 if( stackF.isDefined( name ) )
                 if( stackF.isDefined( name ) )
                     return true;
                     return true;
              }
              }
+            break;
+        default:
+            break;
         }
         }
     	return false;
     	return false;
     }
     }
     
     
-    public synchronized boolean isDefined( String name, MemoryType type )
+    public synchronized boolean isDefined( String name, Visibility visibility )
     {
     {
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             return this.global.isDefined( name );
             return this.global.isDefined( name );
@@ -163,13 +218,15 @@ public class Memory {
             if( stack.size() == 0 )
             if( stack.size() == 0 )
                 return false;
                 return false;
             return stack.peek().isDefined( name );
             return stack.peek().isDefined( name );
+        default:
+            break;
         }
         }
     	return false;
     	return false;
     }
     }
     
     
-    public synchronized void undeclare( String name, MemoryType type )
+    public synchronized void undeclare( String name, Visibility visibility )
     {
     {
-        switch( type )
+        switch( visibility )
         {
         {
         case GLOBAL:
         case GLOBAL:
             this.global.undeclare( name );
             this.global.undeclare( name );
@@ -179,6 +236,9 @@ public class Memory {
         	if( stack.size() == 0 )
         	if( stack.size() == 0 )
         		return;
         		return;
             stack.peek().undeclare( name );
             stack.peek().undeclare( name );
+            break;
+        default:
+            break;
         }
         }
     }
     }
 }
 }

+ 5 - 4
src/animation/PseudoCodeNode.java → src/processor/PseudoCodeNode.java

@@ -1,4 +1,4 @@
-package animation;
+package processor;
 
 
 import java.awt.Rectangle;
 import java.awt.Rectangle;
 
 
@@ -8,6 +8,8 @@ import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreePath;
 
 
+import algorithm.AnimationController;
+import algorithm.CodeLine;
 import lib.TextLayoutHelper;
 import lib.TextLayoutHelper;
 
 
 /**
 /**
@@ -16,6 +18,7 @@ import lib.TextLayoutHelper;
  *
  *
  */
  */
 public class PseudoCodeNode extends DefaultMutableTreeNode {
 public class PseudoCodeNode extends DefaultMutableTreeNode {
+    private static final long serialVersionUID = 7366822030747482541L;
 
 
     public static enum CodeAction
     public static enum CodeAction
     {
     {
@@ -23,8 +26,6 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         STOP,
         STOP,
         CONTINUE
         CONTINUE
     }
     }
-    
-    private static final long serialVersionUID = 1L;
 
 
     private static int nextNodeId = 0;
     private static int nextNodeId = 0;
     private final int nodeId;
     private final int nodeId;
@@ -197,7 +198,7 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
 
 
     public ControlFlow emptyForwardStep( Memory m )
     public ControlFlow emptyForwardStep( Memory m )
     {
     {
-        code.actions.push( (Memory mem) -> {} ); // add empty reverse function
+        code.createEmptyBackwardsAction();
         ControlFlow cf = new ControlFlow( ControlFlow.STEP_OVER );
         ControlFlow cf = new ControlFlow( ControlFlow.STEP_OVER );
         cf.setJumpBack( this );
         cf.setJumpBack( this );
         return cf;
         return cf;

+ 17 - 17
src/animation/PseudoCodeProcessor.java → src/processor/PseudoCodeProcessor.java

@@ -1,9 +1,9 @@
-package animation;
+package processor;
 
 
 import java.util.Stack;
 import java.util.Stack;
 
 
-import animation.Memory.MemoryType;
-import animation.StackFrame.FrameType;
+import processor.Memory.Visibility;
+import processor.StackFrame.FrameType;
 
 
 public class PseudoCodeProcessor {
 public class PseudoCodeProcessor {
 
 
@@ -20,11 +20,11 @@ public class PseudoCodeProcessor {
     private Stack<ControlFlow> controlStack;
     private Stack<ControlFlow> controlStack;
     private boolean skip = false;
     private boolean skip = false;
     
     
-    public PseudoCodeProcessor( PseudoCodeNode tree )
+    public PseudoCodeProcessor( PseudoCodeNode start )
     {
     {
         mem = new Memory();
         mem = new Memory();
         mem.addFrame( new StackFrame( FrameType.FUNCTION ) );
         mem.addFrame( new StackFrame( FrameType.FUNCTION ) );
-        programPointer = tree;
+        programPointer = start;
         currentDebugOutput = "";
         currentDebugOutput = "";
         controlStack = new Stack<>();
         controlStack = new Stack<>();
     }
     }
@@ -53,13 +53,13 @@ public class PseudoCodeProcessor {
         StackFrame before = mem.removeFrame();
         StackFrame before = mem.removeFrame();
         mem.addFrame( before );
         mem.addFrame( before );
         ControlFlow cf = null;
         ControlFlow cf = null;
-        if( mem.isDefined( "_call" + programPointer.getId(), MemoryType.LOCAL ) )
+        if( mem.isDefined( "_call" + programPointer.getId(), Visibility.LOCAL ) )
         {
         {
             String name = "_call" + programPointer.getId();
             String name = "_call" + programPointer.getId();
-            mem.undeclare( name, MemoryType.LOCAL );
+            mem.undeclare( name, Visibility.LOCAL );
             cf = programPointer.emptyForwardStep( mem );
             cf = programPointer.emptyForwardStep( mem );
             cf.setBackwardAction( (Memory m) -> {
             cf.setBackwardAction( (Memory m) -> {
-                mem.declare( name, true, MemoryType.LOCAL );
+                mem.declare( name, true, Visibility.LOCAL );
             });
             });
         }
         }
         else
         else
@@ -69,14 +69,14 @@ public class PseudoCodeProcessor {
         switch( cf.getStatus() )
         switch( cf.getStatus() )
         {
         {
         case ControlFlow.STEP_INTO:
         case ControlFlow.STEP_INTO:
-            if( mem.isDefined( "_returnTo" + programPointer.getId(), MemoryType.GLOBAL ) )
+            if( mem.isDefined( "_returnTo" + programPointer.getId(), Visibility.GLOBAL ) )
             {
             {
                 String name = "_returnTo" + programPointer.getId();
                 String name = "_returnTo" + programPointer.getId();
-                mem.declare( name, mem.read( name, MemoryType.GLOBAL ), MemoryType.LOCAL );
-                mem.undeclare( name, MemoryType.GLOBAL );
+                mem.declare( name, mem.read( name, Visibility.GLOBAL ), Visibility.LOCAL );
+                mem.undeclare( name, Visibility.GLOBAL );
                 cf.setBackwardAction( (Memory m) -> {
                 cf.setBackwardAction( (Memory m) -> {
-                    mem.declare( name, mem.read( name, MemoryType.LOCAL ), MemoryType.GLOBAL );
-                    mem.undeclare( name, MemoryType.LOCAL );
+                    mem.declare( name, mem.read( name, Visibility.LOCAL ), Visibility.GLOBAL );
+                    mem.undeclare( name, Visibility.LOCAL );
                 });
                 });
             }
             }
             if( programPointer.getChildCount() == 0 )
             if( programPointer.getChildCount() == 0 )
@@ -104,11 +104,11 @@ public class PseudoCodeProcessor {
         case ControlFlow.CALL:
         case ControlFlow.CALL:
             PseudoCodeNode f = cf.getFunction();
             PseudoCodeNode f = cf.getFunction();
             String name = "_call" + programPointer.getId();
             String name = "_call" + programPointer.getId();
-            mem.declare( name, true, MemoryType.LOCAL );
-            mem.declare( "_returnTo" + f.getId(), cf.getJumpBack(), MemoryType.GLOBAL );
+            mem.declare( name, true, Visibility.LOCAL );
+            mem.declare( "_returnTo" + f.getId(), cf.getJumpBack(), Visibility.GLOBAL );
             cf.setBackwardAction( (Memory m) -> {
             cf.setBackwardAction( (Memory m) -> {
-                m.undeclare( "_returnTo" + f.getId(), MemoryType.GLOBAL );
-                m.undeclare( name, MemoryType.LOCAL );
+                m.undeclare( "_returnTo" + f.getId(), Visibility.GLOBAL );
+                m.undeclare( name, Visibility.LOCAL );
             });
             });
             return selectNextNode( f, programPointer );
             return selectNextNode( f, programPointer );
         }
         }

+ 1 - 1
src/animation/StackFrame.java → src/processor/StackFrame.java

@@ -1,4 +1,4 @@
-package animation;
+package processor;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 
 

+ 41 - 41
src/view/MainView.java

@@ -35,11 +35,10 @@ import javax.swing.tree.TreePath;
 
 
 import org.eclipse.elk.graph.ElkNode;
 import org.eclipse.elk.graph.ElkNode;
 
 
-import animation.Action;
-import animation.AnimationController;
-import animation.PseudoCodeNode;
+import algorithm.Action;
+import algorithm.AnimationController;
 import bk.BKNodePlacement;
 import bk.BKNodePlacement;
-import bk.BKNodePlacement.State;
+import bk.BKNodePlacement.Stage;
 import bk.LayoutType;
 import bk.LayoutType;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphEdge;
 import graph.LayeredGraphNode;
 import graph.LayeredGraphNode;
@@ -48,6 +47,7 @@ import graph.io.Reader;
 import graph.io.Writer;
 import graph.io.Writer;
 import lib.SimpleNodePlacement;
 import lib.SimpleNodePlacement;
 import lib.TextLayoutHelper;
 import lib.TextLayoutHelper;
+import processor.PseudoCodeNode;
 
 
 /**
 /**
  * The main window of the application.
  * The main window of the application.
@@ -98,33 +98,33 @@ public class MainView {
         for( LayeredGraphNode n : graph.getContainedNodes() )
         for( LayeredGraphNode n : graph.getContainedNodes() )
         {
         {
             info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
             info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.TOP_BOTTOM_LEFT ) + "", 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.TOP_BOTTOM_LEFT ).getName(), 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 5 ) + 
-                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_LEFT ) + "", 8 ) + "| " +
+                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.LEFTMOST_UPPER ) + "", 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.LEFTMOST_UPPER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.LEFTMOST_UPPER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.LEFTMOST_UPPER ).getName(), 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.LEFTMOST_UPPER ) + "", 5 ) + 
+                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.LEFTMOST_UPPER ) + "", 8 ) + "| " +
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.TOP_BOTTOM_RIGHT ) + "", 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 5 ) + 
-                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_RIGHT ) + "", 8 ) + "| " +
+                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.RIGHTMOST_UPPER ) + "", 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.RIGHTMOST_UPPER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.RIGHTMOST_UPPER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.RIGHTMOST_UPPER ).getName(), 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.RIGHTMOST_UPPER ) + "", 5 ) + 
+                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.RIGHTMOST_UPPER ) + "", 8 ) + "| " +
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.BOTTOM_TOP_LEFT ) + "", 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.BOTTOM_TOP_LEFT ).getName(), 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 5 ) + 
-                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_LEFT ) + "", 8 ) + "| " +
+                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.LEFTMOST_LOWER ) + "", 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.LEFTMOST_LOWER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.LEFTMOST_LOWER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.LEFTMOST_LOWER ).getName(), 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.LEFTMOST_LOWER ) + "", 5 ) + 
+                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.LEFTMOST_LOWER ) + "", 8 ) + "| " +
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
                     "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.BOTTOM_TOP_RIGHT ) + "", 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 7 ) + 
-                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "", 5 ) + 
-                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_RIGHT ) + "", 8 ) + "|\n";
+                    "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.RIGHTMOST_LOWER ) + "", 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.RIGHTMOST_LOWER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.RIGHTMOST_LOWER ).getName(), 6 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.RIGHTMOST_LOWER ).getName(), 7 ) + 
+                    "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.RIGHTMOST_LOWER ) + "", 5 ) + 
+                    "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.RIGHTMOST_LOWER ) + "", 8 ) + "|\n";
         }
         }
         info += "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
         info += "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
         return info;
         return info;
@@ -529,7 +529,7 @@ public class MainView {
         JScrollPane debugView = new JScrollPane( debugText );
         JScrollPane debugView = new JScrollPane( debugText );
         debugView.setBounds( treeView.getX(), treeView.getY() + 500, treeView.getWidth(), 250 );
         debugView.setBounds( treeView.getX(), treeView.getY() + 500, treeView.getWidth(), 250 );
         
         
-        frame.setSize( (int)graph.getWidth( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 450, (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 50 );
+        frame.setSize( (int)graph.getWidth( LayoutType.LEFTMOST_UPPER ) * 2 + 450, (int)graph.getHeight( LayoutType.LEFTMOST_UPPER ) * 2 + 50 );
         frame.setLocation( 100, 100 );
         frame.setLocation( 100, 100 );
         frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
         frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
         frame.setVisible( true );
         frame.setVisible( true );
@@ -541,10 +541,10 @@ public class MainView {
         pl.setLayout( grout );
         pl.setLayout( grout );
         pl.setLocation( 0, 0 );
         pl.setLocation( 0, 0 );
         pl.setSize( frame.getSize() );
         pl.setSize( frame.getSize() );
-        NodeView topLeft = createNodeView( graph, LayoutType.TOP_BOTTOM_LEFT );
-        NodeView topRight = createNodeView( graph, LayoutType.TOP_BOTTOM_RIGHT );
-        NodeView bottomLeft = createNodeView( graph, LayoutType.BOTTOM_TOP_LEFT );
-        NodeView bottomRight = createNodeView( graph, LayoutType.BOTTOM_TOP_RIGHT );
+        NodeView topLeft = createNodeView( graph, LayoutType.LEFTMOST_UPPER );
+        NodeView topRight = createNodeView( graph, LayoutType.RIGHTMOST_UPPER );
+        NodeView bottomLeft = createNodeView( graph, LayoutType.LEFTMOST_LOWER );
+        NodeView bottomRight = createNodeView( graph, LayoutType.RIGHTMOST_LOWER );
         pl.add( topLeft );
         pl.add( topLeft );
         pl.add( topRight );
         pl.add( topRight );
         pl.add( bottomLeft );
         pl.add( bottomLeft );
@@ -602,7 +602,7 @@ public class MainView {
         frame.revalidate();
         frame.revalidate();
         frame.repaint();
         frame.repaint();
 
 
-        State old = algorithm.getAlgorithmState();
+        Stage old = algorithm.getAlgorithmState();
         
         
         frame.addComponentListener(new ComponentAdapter()
         frame.addComponentListener(new ComponentAdapter()
         {
         {
@@ -637,19 +637,19 @@ public class MainView {
                     pl.remove( combined );
                     pl.remove( combined );
                     switch( algorithm.getAlgorithmState() )
                     switch( algorithm.getAlgorithmState() )
                     {
                     {
-                    case CONFLICTS:
+                    case CONFLICT_DETECTION:
                         pl.add( topLeft );
                         pl.add( topLeft );
                         break;
                         break;
-                    case LAYOUT1:
+                    case LEFTMOST_UPPER:
                         pl.add( topLeft );
                         pl.add( topLeft );
                         break;
                         break;
-                    case LAYOUT2:
+                    case RIGHTMOST_UPPER:
                         pl.add( topRight );
                         pl.add( topRight );
                         break;
                         break;
-                    case LAYOUT3:
+                    case LEFTMOST_LOWER:
                         pl.add( bottomLeft );
                         pl.add( bottomLeft );
                         break;
                         break;
-                    case LAYOUT4:
+                    case RIGHTMOST_LOWER:
                         pl.add( bottomRight );
                         pl.add( bottomRight );
                         break;
                         break;
                     case COMBINE:
                     case COMBINE:
@@ -664,9 +664,9 @@ public class MainView {
         });
         });
         frame.setSize( frame.getWidth() + 1, frame.getHeight() );
         frame.setSize( frame.getWidth() + 1, frame.getHeight() );
         frame.setSize( frame.getWidth() - 1, frame.getHeight() );
         frame.setSize( frame.getWidth() - 1, frame.getHeight() );
-        if( frame.getHeight() < (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 50 )
+        if( frame.getHeight() < (int)graph.getHeight( LayoutType.LEFTMOST_UPPER ) * 2 + 50 )
         {
         {
-            double factor = (graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2) / (frame.getHeight()-50);
+            double factor = (graph.getHeight( LayoutType.LEFTMOST_UPPER ) * 2) / (frame.getHeight()-50);
             frame.setSize( (int)((frame.getWidth() - 450) / factor) + 450, frame.getHeight() );
             frame.setSize( (int)((frame.getWidth() - 450) / factor) + 450, frame.getHeight() );
             spane.setDividerLocation( frame.getWidth() - 430 );
             spane.setDividerLocation( frame.getWidth() - 430 );
         }
         }

+ 2 - 2
src/view/NodeView.java

@@ -81,8 +81,8 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
         {
         {
             setToolTipText( "<html>Name: " + model.toString() +
             setToolTipText( "<html>Name: " + model.toString() +
                             "<br>result X: " + model.getX( LayoutType.COMBINED ) +
                             "<br>result X: " + model.getX( LayoutType.COMBINED ) +
-                            "<br>other layouts: [" + model.getX( LayoutType.TOP_BOTTOM_LEFT ) + "," + model.getX( LayoutType.TOP_BOTTOM_RIGHT ) + ","
-                                + model.getX( LayoutType.BOTTOM_TOP_LEFT ) + "," + model.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "]</html>" );
+                            "<br>other layouts: [" + model.getX( LayoutType.LEFTMOST_UPPER ) + "," + model.getX( LayoutType.RIGHTMOST_UPPER ) + ","
+                                + model.getX( LayoutType.LEFTMOST_LOWER ) + "," + model.getX( LayoutType.RIGHTMOST_LOWER ) + "]</html>" );
         }
         }
         for( Component c : getComponents() )
         for( Component c : getComponents() )
         {
         {

+ 1 - 1
src/view/PseudoCodeLines.java

@@ -18,7 +18,7 @@ import javax.swing.JViewport;
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreePath;
 
 
-import animation.PseudoCodeNode;
+import processor.PseudoCodeNode;
 
 
 /**
 /**
  * JComponent used to draw line numbers. This JComponent should be added as a row header view in a JScrollPane. Based upon the 
  * JComponent used to draw line numbers. This JComponent should be added as a row header view in a JScrollPane. Based upon the 

+ 5 - 5
src/view/PseudoCodeRenderer.java

@@ -7,10 +7,10 @@ import java.awt.Font;
 import javax.swing.JTree;
 import javax.swing.JTree;
 import javax.swing.tree.DefaultTreeCellRenderer;
 import javax.swing.tree.DefaultTreeCellRenderer;
 
 
-import animation.Memory;
-import animation.Memory.MemoryType;
-import animation.PseudoCodeNode;
 import lib.TextLayoutHelper;
 import lib.TextLayoutHelper;
+import processor.Memory;
+import processor.PseudoCodeNode;
+import processor.Memory.Visibility;
 
 
 /**
 /**
  * A tree-like display of pseudocode.
  * A tree-like display of pseudocode.
@@ -78,9 +78,9 @@ public class PseudoCodeRenderer extends DefaultTreeCellRenderer {
             if( mem != null )
             if( mem != null )
             {
             {
                 synchronized( mem ) {
                 synchronized( mem ) {
-                    if( mem.isSomewhereDefined( var, MemoryType.LOCAL ) )
+                    if( mem.isSomewhereDefined( var, Visibility.LOCAL ) )
                     {
                     {
-                        Object val = mem.read( var, MemoryType.LOCAL );
+                        Object val = mem.read( var, Visibility.LOCAL );
                         if( val != null )
                         if( val != null )
                             toolTip += var + "=" + val.toString() + "<br>";
                             toolTip += var + "=" + val.toString() + "<br>";
                     }
                     }