Search in sources :

Example 16 with ControlText

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);
}
Also used : IAllele(forestry.api.genetics.IAllele) Area(binnie.core.gui.geometry.Area) ControlText(binnie.core.gui.controls.ControlText) LinkedList(java.util.LinkedList)

Aggregations

ControlText (binnie.core.gui.controls.ControlText)16 Area (binnie.core.gui.geometry.Area)10 Point (binnie.core.gui.geometry.Point)10 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)5 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)5 IAllele (forestry.api.genetics.IAllele)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)4 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)4 ItemStack (net.minecraft.item.ItemStack)4 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)3 Control (binnie.core.gui.controls.core.Control)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 ControlSlot (binnie.core.gui.minecraft.control.ControlSlot)3 Panel (binnie.core.gui.window.Panel)3 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)3 IChromosomeType (forestry.api.genetics.IChromosomeType)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2