AnnimatedAlgorithm.java 777 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package Algorithms.Animated;
  2. import Model.LayeredGraphNode;
  3. public abstract class AnnimatedAlgorithm extends Thread implements AlgorithmStep {
  4. protected AnnimationController ac;
  5. protected LayeredGraphNode graph;
  6. public AnnimatedAlgorithm( AnnimationController controller, LayeredGraphNode graph )
  7. {
  8. this.ac = controller;
  9. this.graph = graph;
  10. if( controller != null )
  11. start();
  12. }
  13. @Override
  14. public void run()
  15. {
  16. while( true )
  17. {
  18. try {
  19. switch( ac.getNextAction() )
  20. {
  21. case FORWARD:
  22. System.out.println( "FORWARD" );
  23. forwardStep();
  24. break;
  25. case BACKWARD:
  26. System.out.println( "BACKWARD" );
  27. backwardStep();
  28. break;
  29. }
  30. } catch (InterruptedException e) {
  31. e.printStackTrace();
  32. return;
  33. }
  34. }
  35. }
  36. }