|
@@ -35,6 +35,11 @@ public class Compaction implements AlgorithmStage{
|
|
|
private ArrayList< StackFrame > stack; // TODO: evtl richtigen "Stack" benutzen
|
|
|
private ArrayList< BackwardAction > actions; // TODO: evtl richtigen "Stack" benutzen
|
|
|
private LayoutType layout;
|
|
|
+ private PseudoCodeNode placeNode;
|
|
|
+ private PseudoCodeNode placeLoopNode;
|
|
|
+ private PseudoCodeNode applyNode;
|
|
|
+ private PseudoCodeNode applyLoopNode;
|
|
|
+
|
|
|
|
|
|
public Compaction( LayeredGraphNode graph, LayoutType layout )
|
|
|
{
|
|
@@ -76,6 +81,8 @@ public class Compaction implements AlgorithmStage{
|
|
|
int acSize = actions.size();
|
|
|
if( state == CompactionState.PLACE_BLOCKS ) // blöcke platzieren
|
|
|
{
|
|
|
+ placeNode.setSelected( true );
|
|
|
+ placeLoopNode.setSelected( true );
|
|
|
if( stack.size() == 0 ) // äußere schleife, placeblocks bisher nicht aufgerufen
|
|
|
{
|
|
|
ArrayList< LayeredGraphNode > nodes = graph.getContainedNodes();
|
|
@@ -96,9 +103,17 @@ public class Compaction implements AlgorithmStage{
|
|
|
if( !found )
|
|
|
{
|
|
|
// wechsele in die phase des Blöckeshiftens
|
|
|
+ placeNode.setSelected( false );
|
|
|
+ placeLoopNode.setSelected( false );
|
|
|
+ applyNode.setSelected( true );
|
|
|
+ applyLoopNode.setSelected( true );
|
|
|
state = CompactionState.APPLY_SHIFT;
|
|
|
vIndex = 0;
|
|
|
actions.add( 0, ()-> {
|
|
|
+ applyNode.setSelected( false );
|
|
|
+ applyLoopNode.setSelected( false );
|
|
|
+ placeNode.setSelected( true );
|
|
|
+ placeLoopNode.setSelected( true );
|
|
|
vIndex = oldVIndex;
|
|
|
state = CompactionState.PLACE_BLOCKS;
|
|
|
} );
|
|
@@ -262,13 +277,19 @@ public class Compaction implements AlgorithmStage{
|
|
|
if( v == v.getRoot( layout ) && v.getSink( layout ).getShift( layout ) < Double.POSITIVE_INFINITY )
|
|
|
v.setX( v.getX( layout ) + v.getSink( layout ).getShift( layout ), true, layout );
|
|
|
actions.add( 0, ()-> {
|
|
|
+ applyNode.setSelected( true );
|
|
|
+ applyLoopNode.setSelected( true );
|
|
|
v.setX( oldX, oldDef, layout );
|
|
|
v.setSelected( layout );
|
|
|
vIndex--;
|
|
|
} );
|
|
|
vIndex++;
|
|
|
if( vIndex >= graph.getContainedNodes().size() )
|
|
|
+ {
|
|
|
+ applyNode.setSelected( false );
|
|
|
+ applyLoopNode.setSelected( false );
|
|
|
return StageStatus.FINISHED;
|
|
|
+ }
|
|
|
}
|
|
|
if( actions.size() != acSize + 1 )
|
|
|
System.out.println( "ERROR" );
|
|
@@ -278,7 +299,11 @@ public class Compaction implements AlgorithmStage{
|
|
|
@Override
|
|
|
public StageStatus backwardStep() {
|
|
|
if( actions.size() == 0 )
|
|
|
+ {
|
|
|
+ placeNode.setSelected( false );
|
|
|
+ placeLoopNode.setSelected( false );
|
|
|
return StageStatus.FINISHED;
|
|
|
+ }
|
|
|
actions.get( 0 ).reverse();
|
|
|
actions.remove( 0 );
|
|
|
return StageStatus.UNFINISHED;
|
|
@@ -287,6 +312,14 @@ public class Compaction implements AlgorithmStage{
|
|
|
@Override
|
|
|
public PseudoCodeNode createPseudocodeTree() {
|
|
|
PseudoCodeNode root = new PseudoCodeNode( "Plaziere die Knoten" );
|
|
|
+ placeNode = new PseudoCodeNode( "Berechne die Klasen und Plaziere sie" );
|
|
|
+ placeLoopNode = new PseudoCodeNode( "Loop durch alle Wurzelknoten..." );
|
|
|
+ placeNode.add( placeLoopNode );
|
|
|
+ applyNode = new PseudoCodeNode( "Shift anwenden" );
|
|
|
+ applyLoopNode = new PseudoCodeNode( "Loop durch alle Knoten..." );
|
|
|
+ applyNode.add( applyLoopNode );
|
|
|
+ root.add( placeNode );
|
|
|
+ root.add( applyNode );
|
|
|
return root;
|
|
|
}
|
|
|
}
|