Procházet zdrojové kódy

start thread after constructing the object

Eren Yilmaz před 6 roky
rodič
revize
fb950fe6d6

+ 0 - 2
src/Algorithms/Animated/AnimatedAlgorithm.java

@@ -11,8 +11,6 @@ public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage
 	{
 		this.ac = controller;
 		this.graph = graph;
-		if( controller != null )
-			start();
 	}
 	
 	@Override

+ 7 - 4
src/View/MainView.java

@@ -22,14 +22,17 @@ import Model.LayeredGraphNode;
 
 /**
  * The main window of the application.
+ * There should only be one instance of this class at the same time.
+ * The JFrame of that single instance can be accessed by the static field {code MainView.frame}.
  * @author kolja
  *
  */
-public class MainView {
+public class MainView {    
     /**
      * The 'frame' of the main window.
+     * The reason why there can only be one instance of this class.
      */
-	public static JFrame frame;
+    public static JFrame frame;
 	AnimationController controller;
 	
 	private String strToLen( String s, int l )
@@ -51,7 +54,7 @@ public class MainView {
 	{
 		controller = new AnimationController();
 		controller.setTimeBetween( 10 );
-		frame = new JFrame();
+		frame = new JFrame(); // this may write to a static field because there should be only one instance of this class.
         frame.setSize( Math.min( (int)graph.getWidth( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 200, 1700 ), Math.min( (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 200, 900 ) );
 		frame.setLocation( 100, 100 );
 		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
@@ -153,7 +156,7 @@ public class MainView {
 	    		combined.setLocation( layne.getWidth() / 2 - combined.getWidth() / 2, layne.getHeight() / 2 - combined.getHeight() / 2 );
 	        }
 		});
-		new BKNodePlacement( controller, graph );
+		new BKNodePlacement( controller, graph ).start();
 	}
 	
 	private NodeView createNodeView( LayeredGraphNode gNode, LayoutType lt )