12345678910111213141516171819202122232425262728293031323334353637383940 |
- package animation;
- import graph.LayeredGraphNode;
- public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage {
- protected AnimationController ac;
- protected LayeredGraphNode graph;
-
- public AnimatedAlgorithm( AnimationController controller, LayeredGraphNode graph )
- {
- this.ac = controller;
- this.graph = graph;
- }
-
- @Override
- public void run()
- {
- while( true ) // if this loop would end we could not undo steps any more
- {
- try {
- switch( ac.getNextAction() )
- {
- case FORWARD:
- System.out.println( "FORWARD" );
- forwardStep();
- break;
- case BACKWARD:
- System.out.println( "BACKWARD" );
- backwardStep();
- break;
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- return;
- }
-
- }
- }
- }
|