View Javadoc

1   package org.woehlke.simulation.evolution.activities;
2   
3   import org.woehlke.simulation.evolution.dom.ISimGenWorld;
4   import org.woehlke.simulation.evolution.gui.ISimGenWorldCanvas;
5   import org.woehlke.simulation.evolution.beans.SimGenPoint;
6   
7   /**
8    * (C) 2006 - 2008 Thomas Woehlke
9    * http://www.thomas-woehlke.de
10   * @author Thomas Woehlke
11   * Date: 05.02.2006
12   * Time: 00:36:20
13   */
14  public class SimGenController extends Thread
15          implements ISimGenController {
16      private ISimGenWorld world;
17      private Boolean goOn;
18      private ISimGenWorldCanvas canvas;
19      private SimGenPoint max;
20  
21      public SimGenController() {
22          goOn = new Boolean(true);
23      }
24  
25      public void run() {
26          boolean doIt;
27          int daytime = 0;
28          do {
29              synchronized (goOn) {
30                  doIt = goOn.booleanValue();
31              }
32              world.letLivePopulation();
33              canvas.repaint();
34              try {
35                  sleep(100);
36              }
37              catch (InterruptedException e) {
38                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
39              }
40          }
41          while (doIt);
42      }
43  
44      public void exit() {
45          synchronized (goOn) {
46              goOn = new Boolean(false);
47          }
48      }
49  
50      public ISimGenWorldCanvas getCanvas() {
51          return canvas;
52      }
53  
54      public void setCanvas(ISimGenWorldCanvas canvas) {
55          this.canvas = canvas;
56      }
57  
58      public SimGenPoint getMax() {
59          return max;
60      }
61  
62      public void setMax(SimGenPoint max) {
63          this.max = max;
64      }
65  
66      public Boolean getGoOn() {
67          return goOn;
68      }
69  
70      public void setGoOn(Boolean goOn) {
71          this.goOn = goOn;
72      }
73  
74      public ISimGenWorld getWorld() {
75          return world;
76      }
77  
78      public void setWorld(ISimGenWorld world) {
79          this.world = world;
80      }
81  }