aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population/PopulationPane.java
blob: 3a83a86426d2629e460d6de38bbbb61dc78807ae (plain)
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
package jcgp.gui.population;

import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import jcgp.JCGP;
import jcgp.backend.population.Population;
import jcgp.backend.resources.Resources;

public class PopulationPane extends TabPane {
	
	public PopulationPane(JCGP jcgp) {
		super();
		
		setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
		
		remakeTabs(jcgp.getPopulation(), jcgp.getResources());
	}
	
	public void remakeTabs(Population population, Resources resources) {
		getTabs().clear();
		
		Tab tab;
		ChromosomePane cp;
		for (int i = 0; i < resources.getInt("popSize"); i++) {
			cp = new ChromosomePane(population.getChromosome(i), resources);
			tab = new Tab("Chr " + i);
			tab.setContent(cp);
			getTabs().add(tab);
		}
	}
		
	public void updateGenes() {
		for (int i = 0; i < getChildrenUnmodifiable().size(); i++) {
			((ChromosomePane) getTabs().get(i).getContent()).updateGenes();
		}
	}
	
	public void unlockOutputs() {
		for (int i = 0; i < getChildrenUnmodifiable().size(); i++) {
			((ChromosomePane) getTabs().get(i).getContent()).unlockOutputs();
		}
	}
	
	public void relockOutputs() {
		for (int i = 0; i < getChildrenUnmodifiable().size(); i++) {
			((ChromosomePane) getTabs().get(i).getContent()).relockOutputs();
		}
	}
}