File tree Expand file tree Collapse file tree 4 files changed +23
-12
lines changed
src/main/java/org/woehlke/computer/kurzweil/dla Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 11package org .woehlke .computer .kurzweil .dla .control ;
22
33import org .woehlke .computer .kurzweil .dla .model .DiffusionLimitedAggregationModel ;
4+ import org .woehlke .computer .kurzweil .dla .view .DiffusionLimitedAggregationFrame ;
45import org .woehlke .computer .kurzweil .dla .view .canvas .WorldCanvas ;
56
67import java .io .Serializable ;
@@ -23,15 +24,21 @@ public class ControllerThread extends Thread
2324
2425 static final long serialVersionUID = 242L ;
2526
27+ private final DiffusionLimitedAggregationFrame tab ;
28+
2629 private volatile DiffusionLimitedAggregationModel model ;
2730 private volatile WorldCanvas canvas ;
2831
32+ private final int threadSleepTime ;
33+
2934 private Boolean goOn ;
3035
31- public ControllerThread (WorldCanvas canvas , DiffusionLimitedAggregationModel model ) {
36+ public ControllerThread (DiffusionLimitedAggregationFrame tab ) {
37+ this .tab = tab ;
3238 this .goOn = Boolean .TRUE ;
33- this .canvas = canvas ;
34- this .model = model ;
39+ this .canvas = this .tab .getCanvas ();
40+ this .model = this .tab .getModel ();
41+ this .threadSleepTime = model .getConfig ().getDla ().getControl ().getThreadSleepTime ();
3542 }
3643
3744 public void run () {
@@ -40,9 +47,10 @@ public void run() {
4047 synchronized (goOn ) {
4148 doIt = goOn .booleanValue ();
4249 }
43- model .move ();
44- canvas .repaint ();
45- try { sleep (model .getConfig ().getDla ().getControl ().getThreadSleepTime ()); }
50+ this .model .move ();
51+ this .canvas .repaint ();
52+ this .tab .repaint ();
53+ try { sleep (this .threadSleepTime ); }
4654 catch (InterruptedException e ) { e .printStackTrace (); }
4755 }
4856 while (doIt );
Original file line number Diff line number Diff line change @@ -29,17 +29,17 @@ public class DiffusionLimitedAggregationModel implements Serializable {
2929 static final long serialVersionUID = 242L ;
3030
3131 @ Getter
32- private ComputerKurzweilProperties config ;
32+ private final ComputerKurzweilProperties config ;
3333
3434 @ Getter
35- private Point worldDimensions ;
35+ private final Point worldDimensions ;
3636
3737 @ Getter
38- private List <Point > particles = new ArrayList <Point >();
38+ private volatile List <Point > particles = new ArrayList <Point >();
3939
40- private Random random ;
40+ private volatile Random random ;
4141
42- private Dendrite dendrite ;
42+ private volatile Dendrite dendrite ;
4343
4444 public DiffusionLimitedAggregationModel (ComputerKurzweilProperties config ) {
4545 this .config = config ;
Original file line number Diff line number Diff line change 11package org .woehlke .computer .kurzweil .dla .view ;
22
3+ import lombok .Getter ;
34import org .woehlke .computer .kurzweil .dla .config .ComputerKurzweilProperties ;
45import org .woehlke .computer .kurzweil .dla .control .ControllerThread ;
56import org .woehlke .computer .kurzweil .dla .model .DiffusionLimitedAggregationModel ;
2930 * Date: 04.02.2006
3031 * Time: 18:47:46
3132 */
33+ @ Getter
3234public class DiffusionLimitedAggregationFrame extends JFrame implements ImageObserver ,
3335 MenuContainer ,
3436 Serializable ,
@@ -51,7 +53,7 @@ public DiffusionLimitedAggregationFrame(ComputerKurzweilProperties config) {
5153 this .copyright = new JLabel (config .getDla ().getView ().getCopyright (),CENTER );
5254 this .model = new DiffusionLimitedAggregationModel (config );
5355 this .canvas = new WorldCanvas (model );
54- this .controller = new ControllerThread (canvas , model );
56+ this .controller = new ControllerThread (this );
5557 this .setLayout (new BorderLayout ());
5658 this .add (subtitle , BorderLayout .NORTH );
5759 this .add (canvas , BorderLayout .CENTER );
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ public WorldCanvas( DiffusionLimitedAggregationModel model) {
4040 this .worldDimensions = model .getWorldDimensions ();
4141 this .setBackground (MEDIUM );
4242 this .setSize (this .worldDimensions .getX (), this .worldDimensions .getY ());
43+ this .setVisible (true );
4344 }
4445
4546 public void paint (Graphics g ) {
You can’t perform that action at this time.
0 commit comments