Menu

[01c4ec]: / ParamDialog.java  Maximize  Restore  History

Download this file

639 lines (613 with data), 24.3 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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/* Copyright (C) 2006-2010 Joan Queralt Molina
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package biogenesis;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
public class ParamDialog extends JDialog {
private static final long serialVersionUID = Utils.FILE_VERSION;
private JComboBox localeCombo = null;
private JTextField widthText = null;
private JTextField heightText = null;
private JTextField delayText = null;
protected JRadioButton hardwareNoneRadio = null;
protected JRadioButton hardwareOpenGLRadio = null;
private ButtonGroup hardwareGroup = null;
protected JCheckBox hardwareFBObjectCheck = null;
private JTextField rubbingText = null;
private JTextField elasticityText = null;
private JTextField initialnumberText = null;
private JTextField initialenergyText = null;
private JTextField initialO2Text = null;
private JTextField initialCO2Text = null;
private JTextField maxageText = null;
private JTextField mutationrateText = null;
private JTextField redcostText = null;
private JTextField greencostText = null;
private JTextField bluecostText = null;
private JTextField cyancostText = null;
private JTextField whitecostText = null;
private JTextField graycostText = null;
private JTextField yellowcostText = null;
private JTextField segmentcostText = null;
private JTextField drainText = null;
private JTextField greenenergyText = null;
private JTextField organicenergyText = null;
private JTextField organicsubsText = null;
private JTextField redprobText = null;
private JTextField greenprobText = null;
private JTextField blueprobText = null;
private JTextField cyanprobText = null;
private JTextField whiteprobText = null;
private JTextField grayprobText = null;
private JTextField yellowprobText = null;
private JTextField decayenergyText = null;
private JButton OKButton = null;
private JButton cancelButton = null;
private JButton defaultButton = null;
protected MainWindow mainWindow;
public ParamDialog(MainWindow parent) {
// Configurem les caracter�stiques generals
super(parent,Messages.getString("T_PARAMETERS_CONFIGURATION"),true); //$NON-NLS-1$
mainWindow = parent;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setComponents();
pack();
setResizable(false);
// Configurem les accions dels butons
OKButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
checkParams();
Utils.savePreferences();
dispose();
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
dispose();
}
});
defaultButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
defaultPreferences();
}
});
// Ja est� tot apunt
setVisible(true);
}
protected void defaultPreferences() {
widthText.setText(String.valueOf(Utils.DEF_WORLD_WIDTH));
heightText.setText(String.valueOf(Utils.DEF_WORLD_HEIGHT));
delayText.setText(String.valueOf(Utils.DEF_DELAY));
rubbingText.setText(String.valueOf(Utils.DEF_RUBBING));
elasticityText.setText(String.valueOf(Utils.DEF_ELASTICITY));
initialnumberText.setText(String.valueOf(Utils.DEF_INITIAL_ORGANISMS));
initialenergyText.setText(String.valueOf(Utils.DEF_INITIAL_ENERGY));
initialO2Text.setText(String.valueOf(Utils.DEF_INITIAL_O2));
initialCO2Text.setText(String.valueOf(Utils.DEF_INITIAL_CO2));
maxageText.setText(String.valueOf(Utils.DEF_MAX_AGE));
mutationrateText.setText(String.valueOf(Utils.DEF_MUTATION_RATE));
segmentcostText.setText(String.valueOf(Utils.DEF_SEGMENT_COST_DIVISOR));
drainText.setText(String.valueOf(Utils.DEF_DRAIN_SUBS_DIVISOR));
greenenergyText.setText(String.valueOf(Utils.DEF_GREEN_OBTAINED_ENERGY_DIVISOR));
organicenergyText.setText(String.valueOf(Utils.DEF_ORGANIC_OBTAINED_ENERGY));
organicsubsText.setText(String.valueOf(Utils.DEF_ORGANIC_SUBS_PRODUCED));
redcostText.setText(String.valueOf(Utils.DEF_RED_ENERGY_CONSUMPTION));
greencostText.setText(String.valueOf(Utils.DEF_GREEN_ENERGY_CONSUMPTION));
bluecostText.setText(String.valueOf(Utils.DEF_BLUE_ENERGY_CONSUMPTION));
cyancostText.setText(String.valueOf(Utils.DEF_CYAN_ENERGY_CONSUMPTION));
whitecostText.setText(String.valueOf(Utils.DEF_WHITE_ENERGY_CONSUMPTION));
graycostText.setText(String.valueOf(Utils.DEF_GRAY_ENERGY_CONSUMPTION));
yellowcostText.setText(String.valueOf(Utils.DEF_YELLOW_ENERGY_CONSUMPTION));
redprobText.setText(String.valueOf(Utils.DEF_RED_PROB));
greenprobText.setText(String.valueOf(Utils.DEF_GREEN_PROB));
blueprobText.setText(String.valueOf(Utils.DEF_BLUE_PROB));
cyanprobText.setText(String.valueOf(Utils.DEF_CYAN_PROB));
whiteprobText.setText(String.valueOf(Utils.DEF_WHITE_PROB));
grayprobText.setText(String.valueOf(Utils.DEF_GRAY_PROB));
yellowprobText.setText(String.valueOf(Utils.DEF_YELLOW_PROB));
decayenergyText.setText(String.valueOf(Utils.DEF_DECAY_ENERGY));
switch (Utils.DEF_HARDWARE_ACCELERATION) {
case 0:
case 2:
case 5:
hardwareNoneRadio.setSelected(true);
hardwareFBObjectCheck.setSelected(false);
hardwareFBObjectCheck.setEnabled(false);
break;
case 1:
case 3:
hardwareOpenGLRadio.setSelected(true);
hardwareFBObjectCheck.setSelected(false);
break;
case 6:
hardwareOpenGLRadio.setSelected(true);
hardwareFBObjectCheck.setSelected(true);
break;
}
}
protected void setComponents() {
getContentPane().setLayout(new BorderLayout());
// Set up buttons
JPanel buttonsPanel = new JPanel();
OKButton = new JButton(Messages.getString("T_OK")); //$NON-NLS-1$
cancelButton = new JButton(Messages.getString("T_CANCEL")); //$NON-NLS-1$
defaultButton = new JButton(Messages.getString("T_DEFAULT_VALUES")); //$NON-NLS-1$
buttonsPanel.add(OKButton);
buttonsPanel.add(cancelButton);
buttonsPanel.add(defaultButton);
getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
JTabbedPane tabbedPane = new JTabbedPane();
// Set up general tab
tabbedPane.addTab(Messages.getString("T_GENERAL"), setGeneralTab()); //$NON-NLS-1$
// Set up world tab
tabbedPane.addTab(Messages.getString("T_WORLD"), setWorldTab()); //$NON-NLS-1$
// Set up organisms tab
tabbedPane.addTab(Messages.getString("T_ORGANISMS"), setOrganismsTab()); //$NON-NLS-1$
// Set up metabolism tab
tabbedPane.addTab(Messages.getString("T_METABOLISM"), setMetabolismTab()); //$NON-NLS-1$
// Set up genes tab
tabbedPane.addTab(Messages.getString("T_GENES"), setGenesTab()); //$NON-NLS-1$
getContentPane().add(tabbedPane, BorderLayout.CENTER);
}
protected JPanel setGeneralTab() {
JPanel generalPanel = new JPanel();
generalPanel.setLayout(new BoxLayout(generalPanel,BoxLayout.Y_AXIS));
// Language
JPanel panel = new JPanel();
JLabel label = new JLabel(Messages.getString("T_LANGUAGE")); //$NON-NLS-1$
panel.add(label);
localeCombo = new JComboBox(Messages.getSupportedLocalesNames());
localeCombo.setSelectedIndex(Messages.getLocaleIndex());
panel.add(localeCombo);
generalPanel.add(panel);
//Frames per second
panel = new JPanel();
label = new JLabel(Messages.getString("T_TIME_PER_FRAME")); //$NON-NLS-1$
panel.add(label);
delayText = new JTextField(Integer.toString(Utils.DELAY),6);
panel.add(delayText);
label = new JLabel(Messages.getString("T_MILLISECONDS")); //$NON-NLS-1$
panel.add(label);
generalPanel.add(panel);
// OpenGL
panel = new JPanel();
panel.setLayout(new GridLayout(5,1));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
Messages.getString("T_HARDWARE_ACCELERATION"))); //$NON-NLS-1$
hardwareNoneRadio = new JRadioButton(Messages.getString("T_NONE")); //$NON-NLS-1$
hardwareOpenGLRadio = new JRadioButton(Messages.getString("T_OPENGL")); //$NON-NLS-1$
hardwareFBObjectCheck = new JCheckBox(Messages.getString("T_DISABLE_FBOBJECT")); //$NON-NLS-1$
switch (Utils.HARDWARE_ACCELERATION) {
case 0:
hardwareNoneRadio.setSelected(true);
hardwareFBObjectCheck.setEnabled(false);
break;
case 1:
case 2:
case 3:
hardwareOpenGLRadio.setSelected(true);
break;
case 4:
case 5:
case 6:
hardwareOpenGLRadio.setSelected(true);
hardwareFBObjectCheck.setSelected(true);
break;
}
hardwareGroup = new ButtonGroup();
hardwareGroup.add(hardwareNoneRadio);
hardwareGroup.add(hardwareOpenGLRadio);
hardwareNoneRadio.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (hardwareNoneRadio.isSelected())
hardwareFBObjectCheck.setEnabled(false);
else
hardwareFBObjectCheck.setEnabled(true);
}
});
panel.add(hardwareNoneRadio);
panel.add(hardwareOpenGLRadio);
panel.add(hardwareFBObjectCheck);
panel.add(new JLabel(Messages.getString("T_DIRECTX_IS_AUTOMATICALLY_DETECTED_AND_INITIALIZED"))); //$NON-NLS-1$
panel.add(new JLabel(Messages.getString("T_APPLICATION_MUST_BE_RESTARTED_TO_APPLY_CHANGES"))); //$NON-NLS-1$
generalPanel.add(panel);
return generalPanel;
}
protected JPanel setWorldTab() {
JPanel worldPanel = new JPanel();
worldPanel.setLayout(new BoxLayout(worldPanel,BoxLayout.Y_AXIS));
// World size
JPanel panel = new JPanel();
JLabel label = new JLabel(Messages.getString("T_WIDTH")); //$NON-NLS-1$
panel.add(label);
widthText = new JTextField(Integer.toString(Utils.WORLD_WIDTH),6);
panel.add(widthText);
label = new JLabel(Messages.getString("T_HEIGHT")); //$NON-NLS-1$
panel.add(label);
heightText = new JTextField(Integer.toString(Utils.WORLD_HEIGHT),6);
panel.add(heightText);
worldPanel.add(panel);
// Initial O2 - initial CO2
panel = new JPanel();
label = new JLabel(Messages.getString("T_INITIAL_OXYGEN")); //$NON-NLS-1$
panel.add(label);
initialO2Text = new JTextField(Double.toString(Utils.INITIAL_O2),6);
panel.add(initialO2Text);
label = new JLabel(Messages.getString("T_INITIAL_CARBON_DIOXIDE")); //$NON-NLS-1$
panel.add(label);
initialCO2Text = new JTextField(Double.toString(Utils.INITIAL_CO2),6);
panel.add(initialCO2Text);
worldPanel.add(panel);
// Rubbing - Elasticity
panel = new JPanel();
label = new JLabel(Messages.getString("T_RUBBING_COEFFICIENT")); //$NON-NLS-1$
panel.add(label);
rubbingText = new JTextField(Double.toString(Utils.RUBBING),6);
panel.add(rubbingText);
worldPanel.add(panel);
panel = new JPanel();
label = new JLabel(Messages.getString("T_ELASTICITY_COEFFICIENT")); //$NON-NLS-1$
panel.add(label);
elasticityText = new JTextField(Double.toString(Utils.ELASTICITY),6);
panel.add(elasticityText);
worldPanel.add(panel);
return worldPanel;
}
protected JPanel setOrganismsTab() {
JPanel organismsPanel = new JPanel();
organismsPanel.setLayout(new BoxLayout(organismsPanel,BoxLayout.Y_AXIS));
// Initial number - initial energy
JPanel panel = new JPanel();
JLabel label = new JLabel(Messages.getString("T_INITIAL_NUMBER")); //$NON-NLS-1$
panel.add(label);
initialnumberText = new JTextField(Integer.toString(Utils.INITIAL_ORGANISMS),6);
panel.add(initialnumberText);
label = new JLabel(Messages.getString("T_INITIAL_ENERGY")); //$NON-NLS-1$
panel.add(label);
initialenergyText = new JTextField(Integer.toString(Utils.INITIAL_ENERGY),6);
panel.add(initialenergyText);
organismsPanel.add(panel);
// Max age - Mutation rate
panel = new JPanel();
label = new JLabel(Messages.getString("T_LIFE_EXPECTANCY")); //$NON-NLS-1$
panel.add(label);
maxageText = new JTextField(Integer.toString(Utils.MAX_AGE),6);
panel.add(maxageText);
label = new JLabel(Messages.getString("T_MUTATION_PERCENTAGE")); //$NON-NLS-1$
panel.add(label);
mutationrateText = new JTextField(Double.toString(Utils.MUTATION_RATE),6);
panel.add(mutationrateText);
organismsPanel.add(panel);
// Upkeep cost
panel = new JPanel();
label = new JLabel(Messages.getString("T_UPKEEP_COST_DIVISOR")); //$NON-NLS-1$
panel.add(label);
segmentcostText = new JTextField(Integer.toString(Utils.SEGMENT_COST_DIVISOR),6);
panel.add(segmentcostText);
organismsPanel.add(panel);
// Drain substance
panel = new JPanel();
label = new JLabel(Messages.getString("T_SUBSTANCE_DRAINAGE_DIVISOR")); //$NON-NLS-1$
panel.add(label);
drainText = new JTextField(Integer.toString(Utils.DRAIN_SUBS_DIVISOR),6);
panel.add(drainText);
organismsPanel.add(panel);
// Decay energy
panel = new JPanel();
label = new JLabel(Messages.getString("T_DECAY_ENERGY")); //$NON-NLS-1$
panel.add(label);
decayenergyText = new JTextField(Double.toString(Utils.DECAY_ENERGY),6);
panel.add(decayenergyText);
organismsPanel.add(panel);
return organismsPanel;
}
protected JPanel setMetabolismTab() {
JPanel metabolismPanel = new JPanel();
metabolismPanel.setLayout(new BoxLayout(metabolismPanel,BoxLayout.Y_AXIS));
// Photosynthetic metabolism
JPanel panel = new JPanel();
JLabel label = new JLabel(Messages.getString("T_PHOTOSYNTHETIC_METABOLISM")); //$NON-NLS-1$
label.setAlignmentX(Component.CENTER_ALIGNMENT);
metabolismPanel.add(label);
metabolismPanel.add(Box.createVerticalStrut(10));
// Obtained energy
label = new JLabel(Messages.getString("T_OBTAINED_ENERGY_DIVISOR")); //$NON-NLS-1$
panel.add(label);
greenenergyText = new JTextField(Integer.toString(Utils.GREEN_OBTAINED_ENERGY_DIVISOR),6);
panel.add(greenenergyText);
metabolismPanel.add(panel);
// Chemoorganotrophic metabolism
label = new JLabel(Messages.getString("T_CHEMOORGANOTROPHIC_METABOLISM")); //$NON-NLS-1$
label.setAlignmentX(Component.CENTER_ALIGNMENT);
metabolismPanel.add(Box.createVerticalStrut(10));
metabolismPanel.add(label);
metabolismPanel.add(Box.createVerticalStrut(10));
// Obtained energy
panel = new JPanel();
label = new JLabel(Messages.getString("T_OBTAINED_ENERGY")); //$NON-NLS-1$
panel.add(label);
organicenergyText = new JTextField(Double.toString(Utils.ORGANIC_OBTAINED_ENERGY),6);
panel.add(organicenergyText);
metabolismPanel.add(panel);
// Released energy
panel = new JPanel();
label = new JLabel(Messages.getString("T_RELEASED_ENERGY_PROPORTION")); //$NON-NLS-1$
panel.add(label);
organicsubsText = new JTextField(Double.toString(Utils.ORGANIC_SUBS_PRODUCED),6);
panel.add(organicsubsText);
metabolismPanel.add(panel);
return metabolismPanel;
}
protected JPanel setGenesTab() {
JPanel genesPanel = new JPanel();
genesPanel.setLayout(new GridLayout(8,3));
JLabel label;
genesPanel.add(new JLabel(Messages.getString("T_COLOR2"),SwingConstants.CENTER)); //$NON-NLS-1$
genesPanel.add(new JLabel(Messages.getString("T_PROBABILITY"),SwingConstants.CENTER)); //$NON-NLS-1$
genesPanel.add(new JLabel(Messages.getString("T_COST"),SwingConstants.CENTER)); //$NON-NLS-1$
label = new JLabel(Messages.getString("T_RED"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
redprobText = new JTextField(Integer.toString(Utils.RED_PROB));
genesPanel.add(redprobText);
redcostText = new JTextField(Double.toString(Utils.RED_ENERGY_CONSUMPTION));
genesPanel.add(redcostText);
label = new JLabel(Messages.getString("T_GREEN"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
greenprobText = new JTextField(Integer.toString(Utils.GREEN_PROB));
genesPanel.add(greenprobText);
greencostText = new JTextField(Double.toString(Utils.GREEN_ENERGY_CONSUMPTION));
genesPanel.add(greencostText);
label = new JLabel(Messages.getString("T_BLUE"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
blueprobText = new JTextField(Integer.toString(Utils.BLUE_PROB));
genesPanel.add(blueprobText);
bluecostText = new JTextField(Double.toString(Utils.BLUE_ENERGY_CONSUMPTION));
genesPanel.add(bluecostText);
label = new JLabel(Messages.getString("T_CYAN"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
cyanprobText = new JTextField(Integer.toString(Utils.CYAN_PROB));
genesPanel.add(cyanprobText);
cyancostText = new JTextField(Double.toString(Utils.CYAN_ENERGY_CONSUMPTION));
genesPanel.add(cyancostText);
label = new JLabel(Messages.getString("T_WHITE"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
whiteprobText = new JTextField(Integer.toString(Utils.WHITE_PROB));
genesPanel.add(whiteprobText);
whitecostText = new JTextField(Double.toString(Utils.WHITE_ENERGY_CONSUMPTION));
genesPanel.add(whitecostText);
label = new JLabel(Messages.getString("T_GRAY"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
grayprobText = new JTextField(Integer.toString(Utils.GRAY_PROB));
genesPanel.add(grayprobText);
graycostText = new JTextField(Double.toString(Utils.GRAY_ENERGY_CONSUMPTION));
genesPanel.add(graycostText);
label = new JLabel(Messages.getString("T_YELLOW"),SwingConstants.CENTER); //$NON-NLS-1$
genesPanel.add(label);
yellowprobText = new JTextField(Integer.toString(Utils.YELLOW_PROB));
genesPanel.add(yellowprobText);
yellowcostText = new JTextField(Double.toString(Utils.YELLOW_ENERGY_CONSUMPTION));
genesPanel.add(yellowcostText);
return genesPanel;
}
void checkParams() {
int i;
double d;
if (Messages.getLocaleIndex() != localeCombo.getSelectedIndex()) {
Messages.setLocale(localeCombo.getSelectedIndex());
mainWindow.changeLocale();
}
try {
i = Integer.parseInt(widthText.getText());
if (i > 0) Utils.WORLD_WIDTH = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(heightText.getText());
if (i > 0) Utils.WORLD_HEIGHT = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(delayText.getText());
if (i > 0) {
Utils.DELAY = i;
}
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(initialO2Text.getText());
if (d >= 0) Utils.INITIAL_O2 = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(initialCO2Text.getText());
if (d >= 0) Utils.INITIAL_CO2 = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(rubbingText.getText());
if (d >= 0 && d <= 1) Utils.RUBBING = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(elasticityText.getText());
if (d >= 0 && d <= 1) Utils.ELASTICITY = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(initialnumberText.getText());
if (i >= 0) Utils.INITIAL_ORGANISMS = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(initialenergyText.getText());
if (i > 0) Utils.INITIAL_ENERGY = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(maxageText.getText());
if (i > 0) Utils.MAX_AGE = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(mutationrateText.getText());
if (d >= 0 && d <= 100) Utils.MUTATION_RATE = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(redcostText.getText());
if (d >= 0) Utils.RED_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(greencostText.getText());
if (d >= 0) Utils.GREEN_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(bluecostText.getText());
if (d >= 0) Utils.BLUE_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(cyancostText.getText());
if (d >= 0) Utils.CYAN_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(whitecostText.getText());
if (d >= 0) Utils.WHITE_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(graycostText.getText());
if (d >= 0) Utils.GRAY_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(yellowcostText.getText());
if (d >= 0) Utils.YELLOW_ENERGY_CONSUMPTION = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(redprobText.getText());
if (i >= 0) Utils.RED_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(greenprobText.getText());
if (i > 0) Utils.GREEN_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(blueprobText.getText());
if (i >= 0) Utils.BLUE_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(cyanprobText.getText());
if (i >= 0) Utils.CYAN_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(whiteprobText.getText());
if (i >= 0) Utils.WHITE_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(grayprobText.getText());
if (i >= 0) Utils.GRAY_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(yellowprobText.getText());
if (i >= 0) Utils.YELLOW_PROB = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(segmentcostText.getText());
if (i > 0) Utils.SEGMENT_COST_DIVISOR = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(drainText.getText());
if (i > 0) Utils.DRAIN_SUBS_DIVISOR = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
i = Integer.parseInt(greenenergyText.getText());
if (i > 0) Utils.GREEN_OBTAINED_ENERGY_DIVISOR = i;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(organicenergyText.getText());
if (d >= 0) Utils.ORGANIC_OBTAINED_ENERGY = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
try {
d = Double.parseDouble(organicsubsText.getText());
if (d >= 0 && d <= 1) Utils.ORGANIC_SUBS_PRODUCED = d;
} catch (NumberFormatException ex) {
// Keep old value if there is a problem
}
if (hardwareNoneRadio.isSelected()) {
Utils.setHardwareAcceleration(0);
}
if (hardwareOpenGLRadio.isSelected()) {
if (hardwareFBObjectCheck.isSelected()) {
if (Utils.HARDWARE_ACCELERATION < 4)
Utils.setHardwareAcceleration(4);
} else {
if (Utils.HARDWARE_ACCELERATION != 0 && Utils.HARDWARE_ACCELERATION > 3)
Utils.setHardwareAcceleration(1);
}
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.