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();
}
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);
}
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);
}
}
}
Aggregations