BlockCalc.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package bk;
  2. import javax.swing.JTree;
  3. import animation.AlgorithmStage;
  4. import animation.AnimatedAlgorithm;
  5. import animation.CodeLine;
  6. import animation.ControlFlow;
  7. import animation.Memory;
  8. import animation.PseudoCodeNode;
  9. import graph.LayeredGraphNode;
  10. import lib.TextLayoutHelper;
  11. /**
  12. * The stage of the BK node placement algorithm where the blocks are computed.
  13. * @author kolja
  14. *
  15. */
  16. public class BlockCalc implements AlgorithmStage {
  17. private AnimatedAlgorithm alg;
  18. public BlockCalc( AnimatedAlgorithm alg )
  19. {
  20. this.alg = alg;
  21. }
  22. @Override
  23. public PseudoCodeNode createPseudocodeTree( JTree tree ) {
  24. String[] vars = { "graph", "L", "v", "r", "neighbors" };
  25. PseudoCodeNode root = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "calculateBlockGraph( graph )", vars ), tree, new CodeLine() {
  26. private LayeredGraphNode param;
  27. @Override
  28. public ControlFlow runForward(Memory m) {
  29. return new ControlFlow( ControlFlow.STEP_INTO );
  30. }
  31. }, alg);
  32. return root;
  33. }
  34. @Override
  35. public String getDebugString()
  36. {
  37. return "";
  38. }
  39. }