Quellcode durchsuchen

introduction of new structure in animation packet

Kolja Strohm vor 6 Jahren
Ursprung
Commit
edf4060833

+ 0 - 53
src/animation/AlgorithmStage.java

@@ -18,59 +18,6 @@ public interface AlgorithmStage {
      * @author kolja
      *
      */
-    public static enum StageStatus
-    {
-        UNFINISHED,
-        BREAKPOINT,
-        FINISHED
-    }
-
-    /**
-     * Perform one atomic step of the algorithm. Stops at the end of the program.
-     * @return whether the whole stage is finished (afterwards).
-     * For example if all steps are finished, then {@code FINISHED} is returned.
-     */
-    public StageStatus forwardStep();
-
-    /**
-     * Perform steps until the next line of code on the same level of indentation as this line
-     * is reached. Stops at the end of the program.
-     * @return whether the whole stage is finished (afterwards).
-     * For example if all steps are finished, then {@code FINISHED} is returned.
-     */
-    public StageStatus forwardStepOver();
-
-    /**
-     * Perform steps until the next line of code on the level of indentation above this lines 
-     * level is reached. Stops at the end of the program.
-     * @return whether the whole stage is finished (afterwards).
-     * For example if all steps are finished, then {@code FINISHED} is returned.
-     */
-    public StageStatus forwardStepOut();
-    
-    /**
-     * Undo one atomic step of the algorithm. Stops at the beginning of the program.
-     * @return whether the whole stage is finished in backwards direction (afterwards).
-     * For example if all steps have been reverted, then {@code FINISHED} is returned.
-     */
-    public StageStatus backwardStep();
-
-    /**
-     * Perform backward steps until the previous line of code on the same level of indentation 
-     * as this line is reached. Stops at the end of the program.
-     * @return whether the whole stage is finished in backwards direction (afterwards).
-     * For example if all steps have been reverted, then {@code FINISHED} is returned.
-     */
-    public StageStatus backwardStepOver();
-
-
-    /**
-     * Perform backward steps until the previous line of code on the level of indentation above 
-     * this lines level is reached. Stops at the end of the program.
-     * @return whether the whole stage is finished in backwards direction (afterwards).
-     * For example if all steps have been reverted, then {@code FINISHED} is returned.
-     */
-    public StageStatus backwardStepOut();
 
     /**
      * Creates a {@link PseudoCodeNode}, i.e., a line of pseudocode that resembles this Stage.

+ 12 - 6
src/animation/AnimatedAlgorithm.java

@@ -7,6 +7,7 @@ import javax.swing.JFrame;
 import javax.swing.JTree;
 import javax.swing.SwingUtilities;
 
+import animation.PseudoCodeNode.CodeStatus;
 import graph.LayeredGraphNode;
 
 public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage {
@@ -14,12 +15,17 @@ public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage
     protected AnimationController ac;
     protected LayeredGraphNode graph;
     private JFrame view;
+    protected PseudoCodeNode root;
+    protected Memory mem;
 
     public AnimatedAlgorithm( AnimationController controller, LayeredGraphNode graph, JFrame view )
     {
         this.ac = controller;
         this.graph = graph;
         this.view = view;
+        root = null;
+        mem = new Memory();
+        mem.declare( "graph", graph, true );
     }
 
     private void update()
@@ -44,29 +50,29 @@ public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage
                 switch( ac.getNextAction() )
                 {
                 case FORWARD:
-                    if( forwardStep() == StageStatus.FINISHED )
+                    if( root.forwardStep( mem ) == CodeStatus.FINISHED )
                         ac.setContinuous( false );
                     update();
                     break;
                 case FORWARD_OUT:
-                    forwardStepOut();
+                    root.forwardStepOut( mem );
                     update();
                     break;
                 case FORWARD_OVER:
-                    forwardStepOver();
+                    root.forwardStepOver( mem );
                     update();
                     break;
                 case BACKWARD:
-                    if( backwardStep() == StageStatus.FINISHED )
+                    if( root.backwardStep( mem ) == CodeStatus.FINISHED )
                         ac.setContinuous( false );
                     update();
                     break;
                 case BACKWARD_OUT:
-                    backwardStepOut();
+                    root.backwardStepOut( mem );
                     update();
                     break;
                 case BACKWARD_OVER:
-                    backwardStepOver();
+                    root.backwardStepOver( mem );
                     update();
                     break;
                 default:

+ 0 - 14
src/animation/BackwardAction.java

@@ -1,14 +0,0 @@
-package animation;
-
-/**
- * An action that reverts another Action.
- * For example this is used to go one step backwards in the node placement algorithm.
- * @author kolja
- *
- */
-public interface BackwardAction {
-    /**
-     * Undo another action.
-     */
-    public void reverse();
-}

+ 22 - 0
src/animation/CodeLine.java

@@ -0,0 +1,22 @@
+package animation;
+
+public interface CodeLine {
+
+    public ControlFlow runForward( Memory m );
+    public ControlFlow runBackward( Memory m );
+    
+    public static final CodeLine DEFAULT_STEP_INTO_STACK = new CodeLine() {
+
+        @Override
+        public ControlFlow runForward(Memory m) {
+            m.addFrame();
+            return new ControlFlow( ControlFlow.STEP_INTO_STACK );
+        }
+
+        @Override
+        public ControlFlow runBackward(Memory m) {
+            m.addFrame();
+            return new ControlFlow( ControlFlow.STEP_INTO );
+        }
+    };
+}

+ 23 - 0
src/animation/ControlFlow.java

@@ -0,0 +1,23 @@
+package animation;
+
+public class ControlFlow {
+    public static final int STEP_INTO = 0;
+    public static final int STEP_INTO_STACK = 6;
+    public static final int STEP_OVER = 1;
+    public static final int STEP_INTO_LOOP = 2;
+    public static final int BREAK_LOOP = 3;
+    public static final int CONTINUE_LOOP = 4;
+    public static final int CALL = 5;
+    
+    private int status;
+    
+    public ControlFlow( int status )
+    {
+        this.status = status;
+    }
+    
+    public int getStatus()
+    {
+        return status;
+    }
+}

+ 57 - 0
src/animation/Memory.java

@@ -0,0 +1,57 @@
+package animation;
+
+import java.util.Stack;
+
+public class Memory {
+
+    private StackFrame global;
+    private Stack< StackFrame > stack;
+    
+    public Memory()
+    {
+        stack = new Stack<StackFrame>();
+        global = new StackFrame();
+    }
+    
+    public void addFrame()
+    {
+        stack.push( new StackFrame() );
+    }
+    
+    public void removeFrame()
+    {
+        stack.pop();
+    }
+    
+    public <T> void declare( String name, T value, boolean global )
+    {
+        if( global )
+            this.global.declare( name, value );
+        else
+            stack.peek().declare( name, value );
+    }
+    
+    public <T> void write( String name, T value, boolean global )
+    {
+        if( global )
+            this.global.set( name, value );
+        else
+            stack.peek().set( name, value );
+    }
+    
+    public <T> T read( String name, boolean global )
+    {
+        if( global )
+            return this.global.get( name );
+        else
+            return stack.peek().get( name );
+    }
+    
+    public void undeclare( String name, boolean global )
+    {
+        if( global )
+            this.global.undeclare( name );
+        else
+            stack.peek().undeclare( name );
+    }
+}

+ 274 - 1
src/animation/PseudoCodeNode.java

@@ -18,6 +18,13 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         STOP,
         CONTINUE
     }
+
+    public static enum CodeStatus
+    {
+        UNFINISHED,
+        BREAKPOINT,
+        FINISHED
+    }
     
     private static final long serialVersionUID = 1L;
     
@@ -25,13 +32,23 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
     private JTree tree;
     private boolean breakPoint;
     private AnimationController controller;
+    private int currentCodeLine; // next forward code line
+    private int beforeCodeLine; // next backwards code line
+    private CodeLine code;
+    private boolean loop;
+    private boolean stackFrameAdded;
     
-    public PseudoCodeNode( String description, JTree tree )
+    public PseudoCodeNode( String description, JTree tree, CodeLine line )
     {
         super( description );
         selected = false;
         this.tree = tree;
         breakPoint = false;
+        currentCodeLine = -1;
+        beforeCodeLine = -2;
+        code = line;
+        loop = false;
+        stackFrameAdded = false;
     }
     
     public void setController( AnimationController c )
@@ -133,4 +150,260 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
     {
         return breakPoint;
     }
+    
+    private PseudoCodeNode getForwardNode()
+    {
+        if( currentCodeLine == -1 )
+            return this;
+        if( children != null && children.size() > currentCodeLine )
+            return ((PseudoCodeNode)children.get( currentCodeLine )).getForwardNode();
+        return this;
+    }
+    
+    private PseudoCodeNode getBackwardNode()
+    {
+        if( beforeCodeLine == -1 )
+            return this;
+        if( children != null && children.size() > beforeCodeLine )
+            return ((PseudoCodeNode)children.get( beforeCodeLine )).getBackwardNode();
+        return this;
+    }
+    
+    private CodeStatus stepInto( Memory m )
+    {
+        currentCodeLine = 1;
+        beforeCodeLine = 0;
+        stackFrameAdded = true;
+        if( children == null || children.size() == 0 )
+        {
+            setSelected( false );
+            if( stackFrameAdded )
+                m.removeFrame();
+            stackFrameAdded = false;
+            return CodeStatus.FINISHED;
+        }
+        else
+        {
+            setSelected( false );
+            CodeStatus status = selectChild( 0, m ); // TODO if loop do something when finished
+            if( status == CodeStatus.FINISHED )
+            {
+                if( loop )
+                {
+                    beforeCodeLine = currentCodeLine;
+                    currentCodeLine = -1; // TODO select this node
+                    status = CodeStatus.UNFINISHED;
+                }
+                else
+                {
+                    if( stackFrameAdded )
+                        m.removeFrame();
+                    stackFrameAdded = false;
+                }
+            }
+            return status;
+        }
+    }
+    
+    /**
+     * Perform one atomic step of the algorithm. Stops at the end of the program.
+     * @return whether the whole stage is finished (afterwards).
+     * For example if all steps are finished, then {@code FINISHED} is returned.
+     */
+    public CodeStatus forwardStep( Memory m )
+    {
+        if( currentCodeLine == -1 )
+        {
+            ControlFlow cf = code.runForward( m );
+            switch( cf.getStatus() )
+            {
+            case ControlFlow.STEP_INTO_LOOP:
+                loop = true;
+                return stepInto( m );
+            case ControlFlow.STEP_INTO_STACK:
+                stackFrameAdded = true;
+                return stepInto( m );
+            case ControlFlow.STEP_INTO:
+                return stepInto( m );
+            case ControlFlow.STEP_OVER:
+                if( stackFrameAdded )
+                    m.removeFrame();
+                stackFrameAdded = false;
+                return CodeStatus.FINISHED;
+            }
+        }
+        else
+        {
+            if( children == null || children.size() <= currentCodeLine )
+            {
+                if( stackFrameAdded )
+                    m.removeFrame();
+                return CodeStatus.FINISHED;
+            }
+            switch( ( (PseudoCodeNode)children.get( currentCodeLine ) ).forwardStep( m ) )
+            {
+            case BREAKPOINT:
+                return CodeStatus.BREAKPOINT;
+            case FINISHED:
+                ( (PseudoCodeNode)children.get( currentCodeLine ) ).setSelected( false );
+                beforeCodeLine = currentCodeLine;
+                currentCodeLine++;
+                if( children.size() <= currentCodeLine )
+                {
+                    if( loop )
+                    {
+                        currentCodeLine = -1; // TODO select this node
+                    }
+                    else
+                    {
+                        if( stackFrameAdded )
+                            m.removeFrame();
+                        return CodeStatus.FINISHED;
+                    }
+                }
+                else
+                {
+                    CodeStatus status = selectChild( currentCodeLine, m );
+                    if( status == CodeStatus.FINISHED )
+                    {
+                        if( loop )
+                        {
+                            beforeCodeLine = currentCodeLine;
+                            currentCodeLine = -1; // TODO select this node
+                            status = CodeStatus.UNFINISHED;
+                        }
+                        else
+                        {
+                            if( stackFrameAdded )
+                                m.removeFrame();
+                        }
+                    }
+                    return status;
+                }
+            case UNFINISHED:
+                return CodeStatus.UNFINISHED;
+            }
+        }
+        return CodeStatus.UNFINISHED;
+    }
+    
+    private CodeStatus selectChild( int index, Memory m  )
+    {
+        switch( ( (PseudoCodeNode)children.get( index ) ).setSelected( true ) )
+        {
+        case CONTINUE:
+            return CodeStatus.UNFINISHED;
+        case SKIP:
+            switch( ( (PseudoCodeNode)children.get( index ) ).forwardStepOverIntern( m ) )
+            {
+            case BREAKPOINT:
+                return CodeStatus.BREAKPOINT;
+            case FINISHED:
+                ( (PseudoCodeNode)children.get( index ) ).setSelected( false );
+                beforeCodeLine = currentCodeLine;
+                currentCodeLine++;
+                if( children == null || currentCodeLine >= children.size() )
+                {
+                    return CodeStatus.FINISHED;
+                }
+                else
+                {
+                    return selectChild( currentCodeLine, m );
+                }
+            case UNFINISHED:
+                break;
+            }
+        case STOP:
+            return CodeStatus.BREAKPOINT;
+        }
+        return CodeStatus.UNFINISHED;
+    }
+
+    /**
+     * Perform steps until the next line of code on the same level of indentation as this line
+     * is reached. Stops at the end of the program.
+     * @return whether the whole stage is finished (afterwards).
+     * For example if all steps are finished, then {@code FINISHED} is returned.
+     */
+    public CodeStatus forwardStepOver( Memory m )
+    {
+        return getForwardNode().forwardStepOverIntern( m );
+    }
+    
+    private CodeStatus forwardStepOverIntern( Memory m )
+    {
+        CodeStatus status = null;
+        do {
+            status = forwardStep( m );
+        } while( status == CodeStatus.UNFINISHED );
+        return status;
+    }
+
+    /**
+     * Perform steps until the next line of code on the level of indentation above this lines 
+     * level is reached. Stops at the end of the program.
+     * @return whether the whole stage is finished (afterwards).
+     * For example if all steps are finished, then {@code FINISHED} is returned.
+     */
+    public CodeStatus forwardStepOut( Memory m )
+    {
+        return getForwardNode().forwardStepOutIntern( m );
+    }
+    
+    private CodeStatus forwardStepOutIntern( Memory m )
+    {
+        if( parent != null )
+            return ((PseudoCodeNode)parent).forwardStepOverIntern( m );
+        return forwardStepOverIntern( m );
+    }
+    
+    /**
+     * Undo one atomic step of the algorithm. Stops at the beginning of the program.
+     * @return whether the whole stage is finished in backwards direction (afterwards).
+     * For example if all steps have been reverted, then {@code FINISHED} is returned.
+     */
+    public CodeStatus backwardStep( Memory m )
+    {
+        // TODO
+        return null;
+    }
+
+    /**
+     * Perform backward steps until the previous line of code on the same level of indentation 
+     * as this line is reached. Stops at the end of the program.
+     * @return whether the whole stage is finished in backwards direction (afterwards).
+     * For example if all steps have been reverted, then {@code FINISHED} is returned.
+     */
+    public CodeStatus backwardStepOver( Memory m )
+    {
+        return getBackwardNode().backwardStepOverIntern( m );
+    }
+    
+    private CodeStatus backwardStepOverIntern( Memory m )
+    {
+        CodeStatus status = null;
+        do {
+            status = backwardStep( m );
+        } while( status == CodeStatus.UNFINISHED );
+        return status;
+    }
+
+
+    /**
+     * Perform backward steps until the previous line of code on the level of indentation above 
+     * this lines level is reached. Stops at the end of the program.
+     * @return whether the whole stage is finished in backwards direction (afterwards).
+     * For example if all steps have been reverted, then {@code FINISHED} is returned.
+     */
+    public CodeStatus backwardStepOut( Memory m )
+    {
+        return getBackwardNode().backwardStepOutIntern( m );
+    }
+    
+    private CodeStatus backwardStepOutIntern( Memory m )
+    {
+        if( parent != null )
+            return ((PseudoCodeNode)parent).backwardStepOver( m );
+        return backwardStepOutIntern( m );
+    }
 }

+ 39 - 0
src/animation/StackFrame.java

@@ -0,0 +1,39 @@
+package animation;
+
+import java.util.HashMap;
+
+public class StackFrame {
+
+    private HashMap< String, Object > data;
+    
+    public StackFrame()
+    {
+        data = new HashMap< String, Object >();
+    }
+    
+    public <T> void declare( String name, T value )
+    {
+        data.put( name, (Object)value );
+    }
+    
+    public <T> void set( String name, T value )
+    {
+        data.put( name, (Object)value );
+    }
+    
+    public void undeclare( String name )
+    {
+        data.remove( name );
+    }
+    
+    public boolean isDefined( String name )
+    {
+        return data.containsKey( name );
+    }
+    
+    @SuppressWarnings("unchecked")
+    public <T> T get( String name )
+    {
+        return (T)data.get( name );
+    }
+}

+ 2 - 369
src/bk/BKNodePlacement.java

@@ -1,14 +1,12 @@
 package bk;
 
-import java.lang.reflect.InvocationTargetException;
-
 import javax.swing.JFrame;
 import javax.swing.JTree;
 
 import animation.AnimatedAlgorithm;
 import animation.AnimationController;
+import animation.CodeLine;
 import animation.PseudoCodeNode;
-import animation.PseudoCodeNode.CodeAction;
 import graph.LayeredGraphNode;
 import lib.TextLayoutHelper;
 
@@ -63,20 +61,10 @@ public class BKNodePlacement extends AnimatedAlgorithm {
         return state;
     }
 
-    @Override
-    public StageStatus forwardStep() {
-        return forward( "forwardStep" );
-    }
-
-    @Override
-    public StageStatus backwardStep() {
-        return backward( "backwardStep" );
-    }
-
     @Override
     public PseudoCodeNode createPseudocodeTree( JTree tree )
     {
-        PseudoCodeNode root = new PseudoCodeNode( TextLayoutHelper.setupPseudoCodeStage("BK Node Placement Algorithm"), tree );
+        root = new PseudoCodeNode( TextLayoutHelper.setupPseudoCodeStage("BK Node Placement Algorithm"), tree, CodeLine.DEFAULT_STEP_INTO_STACK );
         root.setSelected( true );
         conflictsNode = conftion.createPseudocodeTree( tree );
         layout1Node = layouts[ 0 ].createPseudocodeTree( tree );
@@ -93,60 +81,6 @@ public class BKNodePlacement extends AnimatedAlgorithm {
         return root;
     }
 
-    @Override
-    public StageStatus forwardStepOver() {
-        if( !inside )
-        {
-            State oldState = state;
-            StageStatus status = StageStatus.UNFINISHED;
-            while( state == oldState && status == StageStatus.UNFINISHED )
-                status = forwardStep();
-            return status;
-        }
-        else
-            return forward( "forwardStepOver" );
-    }
-
-    @Override
-    public StageStatus forwardStepOut() {
-        if( !inside )
-        {
-            StageStatus status = StageStatus.UNFINISHED;
-            while( status == StageStatus.UNFINISHED )
-                status = forwardStep();
-            return status;
-        }
-        else
-            return forward( "forwardStepOut" );
-    }
-
-    @Override
-    public StageStatus backwardStepOver() {
-        if( !inside )
-        {
-            State oldState = state;
-            StageStatus status = StageStatus.UNFINISHED;
-            while( state == oldState && status == StageStatus.UNFINISHED )
-                status = backwardStep();
-            return status;
-        }
-        else
-            return backward( "backwardStepOver" );
-    }
-
-    @Override
-    public StageStatus backwardStepOut() {
-        if( !inside )
-        {
-            StageStatus status = StageStatus.UNFINISHED;
-            while( status == StageStatus.UNFINISHED )
-                status = backwardStep();
-            return status;
-        }
-        else
-            return backward( "backwardStepOut" );
-    }
-
     @Override
     public String getDebugString()
     {
@@ -169,305 +103,4 @@ public class BKNodePlacement extends AnimatedAlgorithm {
         }
         return "";
     }
-    
-    private StageStatus forward( String fName )
-    {
-        boolean breakpoint = false;
-        CodeAction action = null;
-        try {
-            switch( state )
-            {
-            case CONFLICTS:
-                boolean selected = conflictsNode.isSelected();
-                action = conflictsNode.setSelected( true );
-                if( !selected )
-                    breakpoint |= action == CodeAction.STOP;
-                do {
-                    switch( (StageStatus)(ConflictDetection.class.getMethod( fName ).invoke( conftion ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        conflictsNode.setSelected( false );
-                        CodeAction ca = layout1Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT1;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return forward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT1:
-                action = layout1Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 0 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout1Node.setSelected( false );
-                        CodeAction ca = layout2Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT2;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return forward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT2:
-                action = layout2Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 1 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout2Node.setSelected( false );
-                        CodeAction ca = layout3Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT3;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return forward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT3:
-                action = layout3Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 2 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout3Node.setSelected( false );
-                        CodeAction ca = layout4Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT4;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return forward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT4:
-                action = layout4Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 3 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout4Node.setSelected( false );
-                        CodeAction ca = combineNode.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.COMBINE;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return forward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case COMBINE:
-                action = combineNode.setSelected( true );
-                do {
-                    switch( (StageStatus)(Combine.class.getMethod( fName ).invoke( combine ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        return StageStatus.FINISHED;
-                    case BREAKPOINT:
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-            }
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-        } catch (IllegalArgumentException e) {
-            e.printStackTrace();
-        } catch (InvocationTargetException e) {
-            e.printStackTrace();
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-        } catch (SecurityException e) {
-            e.printStackTrace();
-        }
-        if( breakpoint )
-            return StageStatus.BREAKPOINT;
-        return StageStatus.UNFINISHED;
-    }
-
-    private StageStatus backward( String fName ) {
-        boolean breakpoint = false;
-        CodeAction action = null;
-        try {
-            switch( state )
-            {
-            case CONFLICTS:
-                action = conflictsNode.setSelected( true );
-                do {
-                    switch( (StageStatus)(ConflictDetection.class.getMethod( fName ).invoke( conftion ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        conflictsNode.setSelected( false );
-                        return StageStatus.FINISHED;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-            case LAYOUT1:
-                action = layout1Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 0 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout1Node.setSelected( false );
-                        CodeAction ca = conflictsNode.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.CONFLICTS;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return backward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT2:
-                action = layout2Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 1 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout2Node.setSelected( false );
-                        CodeAction ca = layout1Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT1;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return backward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT3:
-                action = layout3Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 2 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout3Node.setSelected( false );
-                        CodeAction ca = layout2Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT2;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return backward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case LAYOUT4:
-                action = layout4Node.setSelected( true );
-                do {
-                    switch( (StageStatus)(ExtremalLayoutCalc.class.getMethod( fName ).invoke( layouts[ 3 ] ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        layout4Node.setSelected( false );
-                        CodeAction ca = layout3Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT3;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return backward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            case COMBINE:
-                action = combineNode.setSelected( true );
-                do {
-                    switch( (StageStatus)(Combine.class.getMethod( fName ).invoke( combine ) ) )
-                    {
-                    case FINISHED:
-                        inside = false;
-                        combineNode.setSelected( false );
-                        CodeAction ca = layout4Node.setSelected( true );
-                        breakpoint |= ca == CodeAction.STOP;
-                        state = State.LAYOUT4;
-                        if( ca == CodeAction.SKIP && !breakpoint )
-                            return backward( fName );
-                        break;
-                    case BREAKPOINT:
-                        inside = true;
-                        return StageStatus.BREAKPOINT;
-                    case UNFINISHED:
-                        inside = true;
-                    }
-                } while( !breakpoint && action == CodeAction.SKIP );
-                break;
-            }
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-        } catch (IllegalArgumentException e) {
-            e.printStackTrace();
-        } catch (InvocationTargetException e) {
-            e.printStackTrace();
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-        } catch (SecurityException e) {
-            e.printStackTrace();
-        }
-        if( breakpoint )
-            return StageStatus.BREAKPOINT;
-        return StageStatus.UNFINISHED;
-    }
-    
 }