View Javadoc
1   package org.woehlke.simulation.cyclic.cellular.automaton.view;
2   
3   import org.woehlke.simulation.cyclic.cellular.automaton.control.ControllerThread;
4   import org.woehlke.simulation.cyclic.cellular.automaton.model.CyclicCellularAutomaton;
5   import org.woehlke.simulation.cyclic.cellular.automaton.model.Point;
6   
7   import javax.accessibility.Accessible;
8   import javax.swing.*;
9   import java.awt.*;
10  import java.awt.image.ImageObserver;
11  import java.io.Serializable;
12  
13  /**
14   * (C) 2006 - 2013 Thomas Woehlke.
15   * http://thomas-woehlke.de/p/cyclic-cellular-automaton/
16   * @author Thomas Woehlke
17   * Date: 04.02.2006
18   * Time: 18:33:14
19   */
20  public class CyclicCellularAutomatonApplet extends JApplet implements ImageObserver, MenuContainer, Serializable, Accessible {
21  
22      private Label title = new Label("cyclic cellular automaton");
23      private ControllerThread controllerThread;
24      private WorldCanvas canvas;
25      private CyclicCellularAutomaton cyclicCellularAutomaton;
26  
27      public void init() {
28          int scale = 2;
29          int width = 320 * scale;
30          int height = 234 * scale;
31          this.setLayout(new BorderLayout());
32          this.add(title, BorderLayout.NORTH);
33          Point worldDimensions = new Point(width,height);
34          cyclicCellularAutomaton = new CyclicCellularAutomaton(worldDimensions);
35          canvas = new WorldCanvas(worldDimensions,cyclicCellularAutomaton);
36          this.add(canvas, BorderLayout.CENTER);
37          controllerThread = new ControllerThread(canvas,cyclicCellularAutomaton);
38          controllerThread.start();
39      }
40  
41      public void destroy() {
42      }
43  
44      public void stop() {
45      }
46  
47      public Point getCanvasDimensions() {
48          return canvas.getWorldDimensions();
49      }
50  }