1 package org.woehlke.computer.kurzweil.tabs.simulatedevolution;
2
3 import lombok.Getter;
4 import lombok.extern.log4j.Log4j2;
5 import org.woehlke.computer.kurzweil.application.ComputerKurzweilContext;
6 import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
7 import org.woehlke.computer.kurzweil.tabs.Tab;
8 import org.woehlke.computer.kurzweil.tabs.simulatedevolution.model.SimulatedEvolutionParameter;
9
10 import javax.swing.*;
11 import java.awt.*;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.WindowEvent;
14 import java.awt.event.WindowListener;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 @Log4j2
31 @Getter
32 public class SimulatedEvolutionTab extends JFrame implements
33 MenuContainer,
34 WindowListener,
35 SimulatedEvolution,
36 Tab {
37
38 static final long serialVersionUID = 242L;
39
40 private final static String TITLE = "Simulated Evolution";
41
42 private final static int EXIT_STATUS = 0;
43
44 private final static String APPLET_POSITION = "Center";
45
46 private final static int HEIGHT_OF_TITLE = 30;
47
48 private final static int START_POSITION_ON_SCREEN_X = 100;
49
50 private final static int START_POSITION_ON_SCREEN_Y = 100;
51
52 private SimulatedEvolutionApplet simulatedEvolutionApplet;
53
54 private final SimulatedEvolutionParameter simulatedEvolutionParameter;
55
56 private final ComputerKurzweilContext ctx;
57
58 private final SimulatedEvolutionContext tabCtx;
59
60 private final ComputerKurzweilProperties properties;
61
62 private void setMyBounds(){
63 int x = START_POSITION_ON_SCREEN_X;
64 int y = START_POSITION_ON_SCREEN_Y;
65 int width = simulatedEvolutionApplet.getCanvasDimensions().getX();
66 int height = simulatedEvolutionApplet.getCanvasDimensions().getY() + HEIGHT_OF_TITLE;
67 setBounds(x, y, width, height);
68 }
69
70 public SimulatedEvolutionTab(ComputerKurzweilProperties properties) {
71 super(TITLE);
72 this.properties = properties;
73 simulatedEvolutionParameter = new SimulatedEvolutionParameter();
74 simulatedEvolutionApplet = new SimulatedEvolutionApplet();
75 simulatedEvolutionApplet.init();
76 add(APPLET_POSITION, simulatedEvolutionApplet);
77 this.ctx = new ComputerKurzweilContext(properties);
78 this.tabCtx = new SimulatedEvolutionContext(this,ctx);
79 pack();
80 setVisible(true);
81 toFront();
82 addWindowListener(this);
83 }
84
85 public void windowOpened(WindowEvent e) {
86 setMyBounds();
87 setVisible(true);
88 toFront();
89 }
90
91 public void windowClosing(WindowEvent e) {
92 System.exit(EXIT_STATUS);
93 }
94
95 public void windowClosed(WindowEvent e) {
96 System.exit(EXIT_STATUS);
97 }
98
99 public void windowIconified(WindowEvent e) {
100
101 }
102
103 public void windowDeiconified(WindowEvent e) {
104 setMyBounds();
105 setVisible(true);
106 toFront();
107 }
108
109 public void windowActivated(WindowEvent e) {
110 toFront();
111 }
112
113 public void windowDeactivated(WindowEvent e) {
114 }
115
116 public void update(){}
117
118 @Override
119 public void actionPerformed(ActionEvent actionEvent) {
120
121 }
122 }