Skip to content

Commit 56b6272

Browse files
committed
* fixed #10 remove JApplet and integrate SimulatedEvolutionApplet into SimulatedEvolutionTab extends JFrame
* fixed #12 add application properties as Java and yml File
1 parent fa7fef3 commit 56b6272

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

src/main/java/org/woehlke/computer/kurzweil/dla/control/ControllerThread.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.woehlke.computer.kurzweil.dla.control;
22

33
import org.woehlke.computer.kurzweil.dla.model.DiffusionLimitedAggregationModel;
4+
import org.woehlke.computer.kurzweil.dla.view.DiffusionLimitedAggregationFrame;
45
import org.woehlke.computer.kurzweil.dla.view.canvas.WorldCanvas;
56

67
import 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);

src/main/java/org/woehlke/computer/kurzweil/dla/model/DiffusionLimitedAggregationModel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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;

src/main/java/org/woehlke/computer/kurzweil/dla/view/DiffusionLimitedAggregationFrame.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.woehlke.computer.kurzweil.dla.view;
22

3+
import lombok.Getter;
34
import org.woehlke.computer.kurzweil.dla.config.ComputerKurzweilProperties;
45
import org.woehlke.computer.kurzweil.dla.control.ControllerThread;
56
import org.woehlke.computer.kurzweil.dla.model.DiffusionLimitedAggregationModel;
@@ -29,6 +30,7 @@
2930
* Date: 04.02.2006
3031
* Time: 18:47:46
3132
*/
33+
@Getter
3234
public 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);

src/main/java/org/woehlke/computer/kurzweil/dla/view/canvas/WorldCanvas.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)