View Javadoc
1   package org.woehlke.computer.kurzweil.tabs.simulatedevolution;
2   
3   import lombok.EqualsAndHashCode;
4   import lombok.Getter;
5   import lombok.ToString;
6   import lombok.extern.log4j.Log4j2;
7   import org.woehlke.computer.kurzweil.tabs.simulatedevolution.model.WorldPoint;
8   
9   import javax.accessibility.Accessible;
10  import javax.swing.*;
11  import java.awt.*;
12  import java.awt.image.ImageObserver;
13  import java.io.Serializable;
14  
15  /**
16   * The Container for running the Simulation.
17   * It containes a World Data Model, a Controller Thread and a WorldCanvas View.
18   *
19   * (C) 2013 Thomas Woehlke.
20   * http://thomas-woehlke.de/p/simulated-evolution/
21   * @author Thomas Woehlke
22   * Date: 04.02.2006
23   * Time: 18:33:14
24   */
25  @SuppressWarnings({"deprecation"})
26  @Log4j2
27  @Getter
28  @ToString
29  @EqualsAndHashCode(callSuper = false)
30  public class SimulatedEvolutionApplet extends JApplet implements ImageObserver, MenuContainer, Serializable, Accessible, SimulatedEvolution {
31  
32      static final long serialVersionUID = 242L;
33  
34      private Label title = new Label("      Artificial Life Simulation of Bacteria Motion depending on DNA - (C) 2013 Thomas Woehlke");
35  
36      /**
37       * ControllerThread for Interachtions between Model and View (MVC-Pattern).
38       */
39      private SimulatedEvolutionController simulatedEvolutionController;
40  
41      /**
42       * The View for the World. Food and Cells are painted to the Canvas.
43       */
44      private SimulatedEvolutionCanvas canvas;
45  
46      /**
47       * Data Model for the Simulation. The World contains the Bacteria Cells and the Food.
48       */
49      private SimulatedEvolutionModel simulatedEvolutionModel;
50  
51      public void init() {
52          int scale = 2;
53          int width = 320 * scale;
54          int height = 234 * scale;
55          this.setLayout(new BorderLayout());
56          this.add(title, BorderLayout.NORTH);
57          simulatedEvolutionController = new SimulatedEvolutionController();
58          WorldPointsimulatedevolution/model/WorldPoint.html#WorldPoint">WorldPoint worldDimensions = new WorldPoint(width,height);
59          simulatedEvolutionModel = new SimulatedEvolutionModel(worldDimensions);
60          canvas = new SimulatedEvolutionCanvas(worldDimensions);
61          canvas.setTabModel(simulatedEvolutionModel);
62          this.add(canvas, BorderLayout.CENTER);
63          simulatedEvolutionController.setCanvas(canvas);
64          simulatedEvolutionController.setSimulatedEvolutionModel(simulatedEvolutionModel);
65          simulatedEvolutionController.start();
66      }
67  
68      public void destroy() {
69      }
70  
71      public void stop() {
72      }
73  
74      public WorldPoint getCanvasDimensions() {
75          return canvas.getWorldDimensions();
76      }
77  }