123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package bk;
- import javax.swing.JTree;
- import animation.AlgorithmStage;
- import animation.AnimatedAlgorithm;
- import animation.CodeLine;
- import animation.ControlFlow;
- import animation.Memory;
- import animation.PseudoCodeNode;
- import graph.LayeredGraphNode;
- import lib.TextLayoutHelper;
- /**
- * The stage of the BK node placement algorithm where the blocks are computed.
- * @author kolja
- *
- */
- public class BlockCalc implements AlgorithmStage {
- private LayeredGraphNode graph;
- private AnimatedAlgorithm alg;
- public BlockCalc( LayeredGraphNode graph, AnimatedAlgorithm alg )
- {
- this.graph = graph;
- this.alg = alg;
- }
- @Override
- public PseudoCodeNode createPseudocodeTree( JTree tree ) {
- String[] vars = { "graph", "L", "v", "r", "neighbors" };
- PseudoCodeNode root = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "calculateBlockGraph( graph )", vars ), tree, new CodeLine() {
- private LayeredGraphNode param;
-
- @Override
- public ControlFlow runForward(Memory m) {
- param = m.<LayeredGraphNode>read( "param1", true );
- m.declare( "graph", param, false );
- m.declare( "Layers", param.getContainedLayers(), false );
- return new ControlFlow( ControlFlow.STEP_INTO );
- }
-
- }, alg);
- return root;
- }
-
- @Override
- public String getDebugString()
- {
- return "";
- }
- }
|