1 package org.woehlke.computer.kurzweil.tabs.simulatedevolution.views;
2
3
4 import lombok.EqualsAndHashCode;
5 import lombok.Getter;
6 import lombok.ToString;
7 import lombok.extern.java.Log;
8 import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
9 import org.woehlke.computer.kurzweil.commons.layouts.FlowLayoutCenter;
10 import org.woehlke.computer.kurzweil.commons.widgets.SubTab;
11 import org.woehlke.computer.kurzweil.commons.widgets.SubTabImpl;
12 import org.woehlke.computer.kurzweil.tabs.simulatedevolution.config.SimulatedEvolution;
13 import org.woehlke.computer.kurzweil.tabs.simulatedevolution.config.SimulatedEvolutionContext;
14 import org.woehlke.computer.kurzweil.tabs.simulatedevolution.model.population.CellPopulationRecord;
15
16 import javax.swing.*;
17 import javax.swing.border.CompoundBorder;
18 import java.awt.*;
19
20 @Log
21 @Getter
22 @ToString(callSuper = true,exclude = {"tabCtx"})
23 @EqualsAndHashCode(callSuper=true,exclude = {"tabCtx","border","layout","layoutSubPanel"})
24 public class GetPopulationStatisticsPanel extends SubTabImpl implements SimulatedEvolution, SubTab {
25
26 private static final long serialVersionUID = 7526471155622776147L;
27
28 private final SimulatedEvolutionContext tabCtx;
29
30 private final JTextField populationnField;
31 private final JTextField worldIterationField;
32 private final String borderLabel;
33
34 public GetPopulationStatisticsPanel(
35 SimulatedEvolutionContext tabCtx
36 ) {
37 super(
38 tabCtx.getCtx().getProperties().getSimulatedevolution().getPopulation().getPanelPopulationStatistics(),
39 tabCtx.getCtx().getProperties()
40 );
41 this.tabCtx = tabCtx;
42 FlowLayout layoutSubPanel = new FlowLayout();
43 this.setLayout(layoutSubPanel);
44 borderLabel = this.tabCtx.getCtx().getProperties().getSimulatedevolution().getPopulation().getPanelPopulationStatistics();
45 FlowLayoutCenter layout = new FlowLayoutCenter();
46 CompoundBorder border = tabCtx.getCtx().getBottomButtonsPanelBorder(borderLabel);
47 this.setLayout(layout);
48 this.setBorder(border);
49 ComputerKurzweilProperties.SimulatedEvolution.Population cfg = this.tabCtx.getCtx().getProperties().getSimulatedevolution().getPopulation();
50 JLabel populationLabel = new JLabel(cfg.getPopulationLabel());
51 JLabel worldIterationLabel = new JLabel("world iterations");
52 populationnField = new JTextField("0",3);
53 worldIterationField = new JTextField("0",6);
54 this.add(populationLabel);
55 this.add(populationnField);
56 this.add(worldIterationLabel);
57 this.add(worldIterationField);
58 update();
59 }
60
61 public void update() {
62 CellPopulationRecord population = tabCtx.getTab().getPopulation();
63
64 populationnField.setText(population.getPopulation()+"");
65 worldIterationField.setText(population.getWorldIteration()+"");
66 }
67 }