浏览代码

debug output für conflict detection

Kolja Strohm 6 年之前
父节点
当前提交
83981836e9
共有 3 个文件被更改,包括 47 次插入20 次删除
  1. 5 0
      src/animation/AnimatedAlgorithm.java
  2. 10 2
      src/animation/PseudoCodeNode.java
  3. 32 18
      src/bk/ConflictDetection.java

+ 5 - 0
src/animation/AnimatedAlgorithm.java

@@ -34,6 +34,11 @@ public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage
         activeFunction = new Stack<PseudoCodeNode>();
     }
     
+    public Memory getMemory()
+    {
+        return mem;
+    }
+    
     public void addActiveFunction( PseudoCodeNode n )
     {
     	if( !activeFunction.empty() )

+ 10 - 2
src/animation/PseudoCodeNode.java

@@ -161,12 +161,20 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         if( selected )
         {
             if( controller == null || controller.getStepOption() != 1 || breakPoint )
-            	expandToRoot();
+            {
+                synchronized( tree ) { // TODO figure out if this solves Exception in thread "AWT-EventQueue-0"
+                    expandToRoot();
+                }
+            }
         }
         else
         {
             if( controller == null || controller.getStepOption() != 1 )
-                tree.collapsePath( new TreePath( this.getPath() ) );
+            {
+                synchronized( tree ) {
+                    tree.collapsePath( new TreePath( this.getPath() ) );
+                }
+            }
         }
         if( breakPoint && selected )
             return CodeAction.STOP; // Breakpoint

+ 32 - 18
src/bk/ConflictDetection.java

@@ -240,24 +240,38 @@ public class ConflictDetection implements AlgorithmStage {
     }
 
     @Override
-    public String getDebugString() {/*
-        String info = "| i  | l  | l1 | k0 | k1 | k  |\n";
-        info +=       "|----|----|----|----|----|----|\n";
-        info += "|" + TextLayoutHelper.strToLen( "" + i, 4 ) + 
-                "|" + TextLayoutHelper.strToLen( "" + l, 4 ) + 
-                "|" + TextLayoutHelper.strToLen( "" + l1, 4 ) + 
-                "|" + TextLayoutHelper.strToLen( "" + k0, 4 ) + 
-                "|" + TextLayoutHelper.strToLen( "" + k1, 4 ) + 
-                "|" + TextLayoutHelper.strToLen( "" + k, 4 ) + "|\n";
-        if( insideSubgraph && vIndex < graph.getContainedNodes().size() )
-        {
-            info += "Subgraph of " + graph.getContainedNodes().get( vIndex ).getName() + ":\n";
-            String tmp = subgraphAlgs.get( vIndex ).getDebugString();
-            info += tmp;
-            return info;
-        }
-        return info;*/
-    	return "";
+    public String getDebugString() {
+        String info = "| i  | l  | l1 | k0 | k1 |  v  |  n  |\n";
+        info +=       "|----|----|----|----|----|-----|-----|\n";
+        String i = "null";
+        String l = "null";
+        String l1 = "null";
+        String k0 = "null";
+        String k1 = "null";
+        String v = "null";
+        String n = "null";
+        if( alg.getMemory().isSomewhereDefined( "i", MemoryType.LOCAL ) )
+            i = "" + alg.getMemory().<Integer>read( "i", MemoryType.LOCAL );
+        if( alg.getMemory().isSomewhereDefined( "l", MemoryType.LOCAL ) )
+            l = "" + alg.getMemory().<Integer>read( "l", MemoryType.LOCAL );
+        if( alg.getMemory().isSomewhereDefined( "l1", MemoryType.LOCAL ) )
+            l1 = "" + alg.getMemory().<Integer>read( "l1", MemoryType.LOCAL );
+        if( alg.getMemory().isSomewhereDefined( "k0", MemoryType.LOCAL ) )
+            k0 = "" + alg.getMemory().<Integer>read( "k0", MemoryType.LOCAL );
+        if( alg.getMemory().isSomewhereDefined( "k1", MemoryType.LOCAL ) )
+            k1 = "" + alg.getMemory().<Integer>read( "k1", MemoryType.LOCAL );
+        if( alg.getMemory().isSomewhereDefined( "v", MemoryType.LOCAL ) && alg.getMemory().<LayeredGraphEdge>read( "v", MemoryType.LOCAL ).getSources().get( 0 ).getName() != null )
+            v = "" + alg.getMemory().<LayeredGraphEdge>read( "v", MemoryType.LOCAL ).getSources().get( 0 ).getName();
+        if( alg.getMemory().isSomewhereDefined( "n", MemoryType.LOCAL ) && alg.getMemory().<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getName() != null )
+            n = "" + alg.getMemory().<LayeredGraphNode>read( "n", MemoryType.LOCAL ).getName();
+        info += "|" + TextLayoutHelper.strToLen( i, 4 ) + 
+                "|" + TextLayoutHelper.strToLen( l, 4 ) + 
+                "|" + TextLayoutHelper.strToLen( l1, 4 ) + 
+                "|" + TextLayoutHelper.strToLen( k0, 4 ) + 
+                "|" + TextLayoutHelper.strToLen( k1, 4 ) + 
+                "|" + TextLayoutHelper.strToLen( v, 5 ) + 
+                "|" + TextLayoutHelper.strToLen( n, 5 ) + "|\n";
+        return info;
     }
 
 }