AnimatedAlgorithm.java 784 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package animation;
  2. import graph.LayeredGraphNode;
  3. public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage {
  4. protected AnimationController ac;
  5. protected LayeredGraphNode graph;
  6. public AnimatedAlgorithm( AnimationController controller, LayeredGraphNode graph )
  7. {
  8. this.ac = controller;
  9. this.graph = graph;
  10. }
  11. @Override
  12. public void run()
  13. {
  14. while( true ) // if this loop would end we could not undo steps any more
  15. {
  16. try {
  17. switch( ac.getNextAction() )
  18. {
  19. case FORWARD:
  20. System.out.println( "FORWARD" );
  21. forwardStep();
  22. break;
  23. case BACKWARD:
  24. System.out.println( "BACKWARD" );
  25. backwardStep();
  26. break;
  27. }
  28. } catch (InterruptedException e) {
  29. e.printStackTrace();
  30. return;
  31. }
  32. }
  33. }
  34. }