use of binnie.core.gui.controls.ControlText in project Binnie by ForestryMC.
the class ControlPunnett method setup.
public void setup(IChromosomeType chromosome, IIndividual ind1, IIndividual ind2, ISpeciesRoot root) {
deleteAllChildren();
if (chromosome == null || ind1 == null || ind2 == null || root == null) {
return;
}
IAllele primary1 = ind1.getGenome().getActiveAllele(chromosome);
IAllele primary2 = ind2.getGenome().getActiveAllele(chromosome);
IAllele secondary1 = ind1.getGenome().getInactiveAllele(chromosome);
IAllele secondary2 = ind2.getGenome().getInactiveAllele(chromosome);
int x = 1;
int y = 1;
for (IAllele allele1 : new IAllele[] { primary1, secondary1 }) {
y = 1;
for (IAllele allele2 : new IAllele[] { primary2, secondary2 }) {
List<IAllele> alleles = new LinkedList<>();
if (allele1.isDominant() && !allele2.isDominant()) {
alleles.add(allele1);
} else if (allele2.isDominant() && !allele1.isDominant()) {
alleles.add(allele2);
} else {
alleles.add(allele1);
if (allele1 != allele2) {
alleles.add(allele2);
}
}
StringBuilder text = new StringBuilder();
for (IAllele allele3 : alleles) {
text.append(allele3.getAlleleName()).append(": ").append(25.0f / alleles.size()).append("%\n");
}
new ControlText(this, new Area(x * ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT * y, ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT), text.toString(), TextJustification.TOP_CENTER).setColor(11184810);
++y;
}
++x;
}
new ControlText(this, new Area(ControlPunnett.BOX_WIDTH, 0, ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT), '\n' + primary1.getAlleleName(), TextJustification.TOP_CENTER).setColor(11184810);
new ControlText(this, new Area(ControlPunnett.BOX_WIDTH * 2, 0, ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT), '\n' + secondary1.getAlleleName(), TextJustification.TOP_CENTER).setColor(11184810);
new ControlText(this, new Area(0, ControlPunnett.BOX_HEIGHT, ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT), primary2.getAlleleName(), TextJustification.TOP_CENTER).setColor(11184810);
new ControlText(this, new Area(0, ControlPunnett.BOX_HEIGHT * 2, ControlPunnett.BOX_WIDTH, ControlPunnett.BOX_HEIGHT), primary2.getAlleleName(), TextJustification.TOP_CENTER).setColor(11184810);
}
Aggregations