12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package Algorithms.Animated.BK;
- import Algorithms.Animated.AlgorithmStage;
- import Model.LayeredGraphNode;
- /**
- * The stage where the for extremal layouts are computed.
- * @author kolja
- *
- */
- public class Layout implements AlgorithmStage {
- public enum LayoutType{
- TOP_BOTTOM_LEFT,
- TOP_BOTTOM_RIGHT,
- BOTTOM_TOP_LEFT,
- BOTTOM_TOP_RIGHT
- }
-
- private enum LayoutState
- {
- BLOCK_CALCULATION,
- COMPACTION
- }
-
- private LayoutType typ;
- private BlockCalc bc;
- private Compaction cp;
- private LayoutState status;
-
-
- public Layout( LayoutType typ, LayeredGraphNode graph )
- {
- status = LayoutState.BLOCK_CALCULATION;
- this.typ = typ;
- bc = new BlockCalc( graph );
- cp = new Compaction( graph );
- }
-
- @Override
- public StageStatus forwardStep() {
- if( status == LayoutState.BLOCK_CALCULATION )
- {
- if( bc.forwardStep() == StageStatus.FINISHED )
- {
- status = LayoutState.COMPACTION;
- }
- return StageStatus.UNFINISHED;
- }
- if( status == LayoutState.COMPACTION )
- return cp.forwardStep();
- return StageStatus.UNFINISHED;
- }
- @Override
- public StageStatus backwardStep() {
- if( status == LayoutState.BLOCK_CALCULATION )
- return bc.backwardStep();
- if( status == LayoutState.COMPACTION )
- {
- if( cp.backwardStep() == StageStatus.FINISHED )
- status = LayoutState.BLOCK_CALCULATION;
- }
- return StageStatus.UNFINISHED;
- }
- }
|