Search in sources :

Example 6 with IClassification

use of forestry.api.genetics.IClassification in project ForestryMC by ForestryMC.

the class GuiAlyzer method drawAnalyticsPageClassification.

public final void drawAnalyticsPageClassification(IIndividual individual) {
    textLayout.startPage();
    textLayout.drawLine(Translator.translateToLocal("for.gui.alyzer.classification") + ":", 12);
    textLayout.newLine();
    Stack<IClassification> hierarchy = new Stack<>();
    IClassification classification = individual.getGenome().getPrimary().getBranch();
    while (classification != null) {
        if (!classification.getScientific().isEmpty()) {
            hierarchy.push(classification);
        }
        classification = classification.getParent();
    }
    boolean overcrowded = hierarchy.size() > 5;
    int x = 12;
    IClassification group = null;
    while (!hierarchy.isEmpty()) {
        group = hierarchy.pop();
        if (overcrowded && group.getLevel().isDroppable()) {
            continue;
        }
        textLayout.drawLine(group.getScientific(), x, group.getLevel().getColour());
        textLayout.drawLine(group.getLevel().name(), 170, group.getLevel().getColour());
        textLayout.newLineCompressed();
        x += 12;
    }
    // Add the species name
    String binomial = individual.getGenome().getPrimary().getBinomial();
    if (group != null && group.getLevel() == EnumClassLevel.GENUS) {
        binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH);
    }
    textLayout.drawLine(binomial, x, 0xebae85);
    textLayout.drawLine("SPECIES", 170, 0xebae85);
    textLayout.newLine();
    textLayout.drawLine(Translator.translateToLocal("for.gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12);
    if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) {
        String extinct = ">> " + Translator.translateToLocal("for.gui.alyzer.extinct").toUpperCase() + " <<";
        fontRenderer.drawStringWithShadow(extinct, guiLeft + 200 - fontRenderer.getStringWidth(extinct), guiTop + textLayout.getLineY(), ColourProperties.INSTANCE.get("gui.beealyzer.dominant"));
    }
    textLayout.newLine();
    String description = individual.getGenome().getPrimary().getDescription();
    if (StringUtils.isBlank(description) || description.startsWith("for.description.")) {
        textLayout.drawSplitLine(Translator.translateToLocal("for.gui.alyzer.nodescription"), 12, 200, 0x666666);
    } else {
        String[] tokens = description.split("\\|");
        textLayout.drawSplitLine(tokens[0], 12, 200, 0x666666);
        if (tokens.length > 1) {
            String signature = "- " + tokens[1];
            fontRenderer.drawStringWithShadow(signature, guiLeft + 210 - fontRenderer.getStringWidth(signature), guiTop + 145 - 14, 0x99cc32);
        }
    }
    textLayout.endPage();
}
Also used : IClassification(forestry.api.genetics.IClassification) Stack(java.util.Stack) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IClassification

use of forestry.api.genetics.IClassification in project Binnie by ForestryMC.

the class BreedingSystem method syncTracker.

@Override
public final void syncTracker(final IBreedingTracker tracker) {
    if (allActiveSpecies.isEmpty()) {
        calculateArrays();
    }
    this.discoveredSpeciesPercentage = 0.0f;
    this.totalSpeciesCount = 0;
    this.discoveredSpeciesCount = 0;
    this.totalSecretCount = 0;
    this.discoveredSecretCount = 0;
    final Collection<IAlleleSpecies> discoveredSpecies = this.getDiscoveredSpecies(tracker);
    final Collection<IAlleleSpecies> allSpecies = this.getAllSpecies();
    for (final IAlleleSpecies species : allSpecies) {
        if (!this.isSecret(species)) {
            ++this.totalSpeciesCount;
            if (!this.isSpeciesDiscovered(species, tracker)) {
                continue;
            }
            ++this.discoveredSpeciesCount;
        } else {
            ++this.totalSecretCount;
            if (!this.isSpeciesDiscovered(species, tracker)) {
                continue;
            }
            ++this.discoveredSecretCount;
        }
    }
    this.discoveredBranchPercentage = 0.0f;
    this.totalBranchCount = 0;
    this.discoveredBranchCount = 0;
    final Collection<IClassification> discoveredBranches = this.getDiscoveredBranches(tracker);
    final Collection<IClassification> allBranches = this.getAllBranches();
    for (final IClassification branch : allBranches) {
        if (!this.isSecret(branch)) {
            ++this.totalBranchCount;
            if (!discoveredBranches.contains(branch)) {
                continue;
            }
            ++this.discoveredBranchCount;
        } else {
            ++this.totalSecretBranchCount;
            if (!discoveredBranches.contains(branch)) {
                continue;
            }
            ++this.discoveredSecretBranchCount;
        }
    }
    this.discoveredSpeciesPercentage = this.discoveredSpeciesCount / this.totalSpeciesCount;
    this.discoveredBranchPercentage = this.discoveredBranchCount / this.totalBranchCount;
    final String epithet = this.getEpitome();
    this.onSyncBreedingTracker(tracker);
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IClassification(forestry.api.genetics.IClassification)

Example 8 with IClassification

use of forestry.api.genetics.IClassification in project Binnie by ForestryMC.

the class BreedingSystem method calculateBranches.

@Override
public void calculateBranches(ISpeciesRoot speciesRoot) {
    Collection<IClassification> allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values();
    this.allBranches = new ArrayList<>();
    for (IClassification branch : allRegBranches) {
        IAlleleSpecies[] species = branch.getMemberSpecies();
        if (species.length <= 0) {
            continue;
        }
        IAlleleSpecies firstSpecies = species[0];
        IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID());
        if (template != null) {
            boolean possible = false;
            for (IAlleleSpecies species2 : branch.getMemberSpecies()) {
                if (allActiveSpecies.contains(species2)) {
                    possible = true;
                }
            }
            if (!possible) {
                continue;
            }
            this.allBranches.add(branch);
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IClassification(forestry.api.genetics.IClassification)

Aggregations

IClassification (forestry.api.genetics.IClassification)8 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 Alignment (binnie.core.api.gui.Alignment)1 IWidget (binnie.core.api.gui.IWidget)1 EventHandlerOrigin (binnie.core.api.gui.events.EventHandlerOrigin)1 ControlText (binnie.core.gui.controls.ControlText)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlListBox (binnie.core.gui.controls.listbox.ControlListBox)1 ControlTextOption (binnie.core.gui.controls.listbox.ControlTextOption)1 ControlPage (binnie.core.gui.controls.page.ControlPage)1 ControlPages (binnie.core.gui.controls.page.ControlPages)1 ControlTab (binnie.core.gui.controls.tab.ControlTab)1 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)1 EventTextEdit (binnie.core.gui.events.EventTextEdit)1 EventValueChanged (binnie.core.gui.events.EventValueChanged)1 CraftGUIUtil (binnie.core.gui.geometry.CraftGUIUtil)1 Point (binnie.core.gui.geometry.Point)1 MinecraftGUI (binnie.core.gui.minecraft.MinecraftGUI)1 Window (binnie.core.gui.minecraft.Window)1