Repository navigation
Expand file tree
/
Copy pathGameWindow.java
More file actions
298 lines (270 loc) · 11.9 KB
/
Copy pathGameWindow.java
File metadata and controls
298 lines (270 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
package gui;
import javax.swing.border.*;
import game.RobotModel;
import game.TargetModel;
import sound.algorithms.FilterMode;
import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import java.awt.*;
import java.io.Serializable;
import java.util.ResourceBundle;
public class GameWindow extends JInternalFrame implements Serializable, Reopenable, Multilangual
{
private GameWindow window = this;
private final GameVisualizer m_visualizer;
public GameWindow(ResourceBundle bundle, RobotModel robotModel, TargetModel targetModel, FilterMode filterMode)
{
super(bundle.getString("gameFieldKey"), true, true, true, true);
m_visualizer = new GameVisualizer(robotModel, targetModel, filterMode);
m_visualizer.grabFocus();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
initComponents();
createNewClosingHandler(bundle);
pack();
}
@Override
public void dispose(){
stopMusic();
super.dispose();
}
public void setMetadata(ResourceBundle bundle) {
m_visualizer.setMetadata();
createNewClosingHandler(bundle);
}
private void stopMusic(){
m_visualizer.stopMusic();
}
public void changeLanguage(ResourceBundle bundle){
stopMusic();
this.setTitle(bundle.getString("gameFieldKey"));
}
private void createNewClosingHandler(ResourceBundle bundle) {
addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosing(InternalFrameEvent e) {
m_visualizer.closingHandler.handleClosing(window, e, bundle, ClosingHandler.ClosingType.GAME);
}
});
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - unknown
JPanel panel = new JPanel(new BorderLayout());
panel.add(m_visualizer, BorderLayout.CENTER);
getContentPane().add(panel);
panel1 = new JPanel();
panel4 = new JPanel();
panel5 = new JPanel();
panel2 = new JPanel();
panel8 = new JPanel();
panel9 = new JPanel();
panel3 = new JPanel();
panel6 = new JPanel();
panel7 = new JPanel();
m_visualizer.setLayout(new GridLayout(3, 3));
//======== this ========
setVisible(true);
//======== panel1 ========
{
panel1.setBackground(new Color(153, 255, 255));
panel1.setBorder(new MatteBorder(2, 2, 1, 1, Color.black));
panel1.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel1.getComponentCount(); i++) {
Rectangle bounds = panel1.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel1.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel1.setMinimumSize(preferredSize);
panel1.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel1);
//======== panel4 ========
{
panel4.setBackground(new Color(153, 204, 255));
panel4.setBorder(new MatteBorder(2, 1, 1, 1, Color.darkGray));
panel4.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel4.getComponentCount(); i++) {
Rectangle bounds = panel4.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel4.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel4.setMinimumSize(preferredSize);
panel4.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel4);
//======== panel5 ========
{
panel5.setBackground(new Color(153, 153, 255));
panel5.setBorder(new MatteBorder(2, 1, 1, 2, Color.darkGray));
panel5.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel5.getComponentCount(); i++) {
Rectangle bounds = panel5.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel5.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel5.setMinimumSize(preferredSize);
panel5.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel5);
//======== panel2 ========
{
panel2.setBackground(new Color(255, 153, 255));
panel2.setBorder(new MatteBorder(1, 2, 1, 1, Color.darkGray));
panel2.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel2.getComponentCount(); i++) {
Rectangle bounds = panel2.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel2.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel2.setMinimumSize(preferredSize);
panel2.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel2);
//======== panel8 ========
{
panel8.setBackground(Color.white);
panel8.setBorder(new LineBorder(Color.darkGray, 1, true));
panel8.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel8.getComponentCount(); i++) {
Rectangle bounds = panel8.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel8.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel8.setMinimumSize(preferredSize);
panel8.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel8);
//======== panel9 ========
{
panel9.setBackground(new Color(255, 153, 153));
panel9.setBorder(new MatteBorder(1, 1, 1, 2, Color.darkGray));
panel9.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel9.getComponentCount(); i++) {
Rectangle bounds = panel9.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel9.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel9.setMinimumSize(preferredSize);
panel9.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel9);
//======== panel3 ========
{
panel3.setBackground(new Color(204, 255, 153));
panel3.setBorder(new MatteBorder(1, 2, 2, 1, Color.darkGray));
panel3.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel3.getComponentCount(); i++) {
Rectangle bounds = panel3.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel3.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel3.setMinimumSize(preferredSize);
panel3.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel3);
//======== panel6 ========
{
panel6.setBackground(new Color(153, 255, 153));
panel6.setBorder(new MatteBorder(1, 1, 2, 1, Color.darkGray));
panel6.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel6.getComponentCount(); i++) {
Rectangle bounds = panel6.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel6.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel6.setMinimumSize(preferredSize);
panel6.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel6);
//======== panel7 ========
{
panel7.setBackground(new Color(102, 255, 153));
panel7.setBorder(new MatteBorder(1, 1, 2, 2, Color.darkGray));
panel7.setLayout(null);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel7.getComponentCount(); i++) {
Rectangle bounds = panel7.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel7.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel7.setMinimumSize(preferredSize);
panel7.setPreferredSize(preferredSize);
}
}
m_visualizer.add(panel7);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license - unknown
private JPanel panel1;
private JPanel panel4;
private JPanel panel5;
private JPanel panel2;
private JPanel panel8;
private JPanel panel9;
private JPanel panel3;
private JPanel panel6;
private JPanel panel7;
// JFormDesigner - End of variables declaration //GEN-END:variables
}