@Override public void onValueChanged(final IAlleleSpecies species) { if (species != null) { for (ControlText control : this.levels.values()) { control.setValue("- - -"); } this.genus.setValue(species.getBinomial()); for (IClassification classification = species.getBranch(); classification != null; classification = classification.getParent()) { IClassification.EnumClassLevel level = classification.getLevel(); String text = classification.getScientific(); this.levels.get(level).setValue(text); } } } }
@Override public IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific, IClassification... members) { IClassification classification = new Classification(level, uid, scientific); for (IClassification member : members) { classification.addMemberGroup(member); } return classification; }
public ControlBranchBoxOption(final ControlList<IClassification> controlList, final IClassification option, final int y) { super(controlList, option, option.getName().contains(".") ? option.getScientific() : option.getName(), y); } }
ButterflyDefinition(ButterflyBranchDefinition branchDefinition, String speciesName, String binomial, Color serumColor, boolean dominant, float rarity) { this.branch = branchDefinition; String uid = "lepi" + name(); IClassification parent = branch.getBranch().getParent(); String unlocalizedName = "for.butterflies.species." + parent.getUID().substring(parent.getLevel().name().toLowerCase(Locale.ENGLISH).length() + 1) + '.' + speciesName; String unlocalizedDescription = "for.description." + uid; String texture = StringUtil.camelCaseToUnderscores("butterflies/" + uid); IAlleleButterflySpeciesBuilder speciesBuilder = ButterflyManager.butterflyFactory.createSpecies("forestry." + uid, unlocalizedName, "Sengir", unlocalizedDescription, Constants.MOD_ID, texture, dominant, branchDefinition.getBranch(), binomial, serumColor); speciesBuilder.setRarity(rarity); setSpeciesProperties(speciesBuilder); this.species = speciesBuilder.build(); }
@Override public void onValueChanged(final IClassification branch) { this.branchName.setValue(TextFormatting.UNDERLINE + I18N.localise(DatabaseConstants.BRANCH_KEY + ".name", branch.getName())); this.branchScientific.setValue(TextFormatting.ITALIC + I18N.localise(DatabaseConstants.BRANCH_KEY + ".apidae", branch.getScientific())); this.branchAuthority.setValue(I18N.localise(DatabaseConstants.BRANCH_KEY + ".discoveredBy", TextFormatting.BOLD + branch.getMemberSpecies()[0].getAuthority())); for (final IWidget widget : this.branchDescription) { this.deleteChild(widget); } this.branchDescription.clear(); String desc = branch.getDescription(); if (desc == null || Objects.equals(desc, "") || desc.contains("for.")) { desc = I18N.localise(DatabaseConstants.BRANCH_KEY + ".noDesc"); } StringBuilder line = new StringBuilder(); final List<String> descLines = new ArrayList<>(); for (final String str : desc.split(" ")) { if (RenderUtil.getTextWidth(line + " " + str) > 134) { descLines.add(TextFormatting.ITALIC + line.toString() + TextFormatting.RESET); line = new StringBuilder(); } line.append(' ').append(str); } descLines.add(line.toString()); int i = 0; for (final String dLine : descLines) { this.branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine)); } } }
@Override public void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes) { addValidAlleleTypes(allele, chromosomeTypes); alleleMap.put(allele.getUID(), allele); if (allele instanceof IAlleleSpecies) { IClassification branch = ((IAlleleSpecies) allele).getBranch(); branch.addMemberSpecies((IAlleleSpecies) allele); } for (IAlleleHandler handler : this.alleleHandlers) { handler.onRegisterAllele(allele); } }
ButterflySpecies(String name, String scientific, int colour) { String branchName = scientific.split(" ")[0].toLowerCase(); String binomial = scientific.split(" ")[1]; final String branchUid = "trees." + branchName.toLowerCase(); IClassification branch = AlleleManager.alleleRegistry.getClassification("genus." + branchUid); if (branch == null) { branch = AlleleManager.alleleRegistry.createAndRegisterClassification(IClassification.EnumClassLevel.GENUS, branchUid, scientific); } this.branch = branch; String uid = "extrabutterflies.species." + this.toString().toLowerCase().replace("_", ""); String unlocalizedName = uid + ".name"; IClassification parent = branch.getParent(); String unlocalizedDescription = "for.description." + uid; String texture = "butterflies/" + toString().toLowerCase(); IAlleleButterflySpeciesBuilder speciesBuilder = ButterflyManager.butterflyFactory.createSpecies(uid, unlocalizedName, "Binnie", unlocalizedDescription, Constants.EXTRA_TREES_MOD_ID, texture, true, branch, binomial, new Color(colour)); speciesBuilder.setRarity(0.5F); setSpeciesProperties(speciesBuilder); species = speciesBuilder.build(); }
@Override public void onValueChanged(final IAlleleSpecies species) { this.controlInd1.setSpecies(species, EnumDiscoveryState.SHOW); this.controlInd2.setSpecies(species, EnumDiscoveryState.SHOW); final String branchBinomial = species.getBranch().getScientific(); this.controlName.setValue(TextFormatting.UNDERLINE + species.getAlleleName()); this.controlScientific.setValue(TextFormatting.ITALIC + branchBinomial + ' ' + species.getBinomial()); this.controlAuthority.setValue(I18N.localise(DatabaseConstants.KEY + ".discovered") + ": " + TextFormatting.BOLD + species.getAuthority()); this.controlComplexity.setValue(I18N.localise(DatabaseConstants.KEY + ".overview.complexity") + ": " + species.getComplexity()); final String desc = species.getDescription(); StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); String descSig = ""; if (desc == null || Objects.equals(desc, "") || desc.contains("for.description") || desc.contains(".desc")) { descBody.append(I18N.localise(DatabaseConstants.KEY + ".no.description")); } else { final String[] descStrings = desc.split("\\|"); descBody.append(descStrings[0]); for (int i = 1; i < descStrings.length - 1; ++i) { descBody.append(' ').append(descStrings[i]); } if (descStrings.length > 1) { descSig += descStrings[descStrings.length - 1]; } } this.controlDescription.setValue(descBody.toString() + TextFormatting.RESET); this.controlSignature.setValue(descSig); final int descHeight = CraftGUI.RENDER.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().xPos()); this.controlSignature.setPosition(new Point(controlSignature.getPosition().xPos(), this.controlDescription.getPosition().yPos() + descHeight + 10)); } }
@Override public final boolean isSecret(final IClassification branch) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (!this.isSecret(species)) { return false; } } return true; }
@Override public void registerClassification(IClassification branch) { if (classificationMap.containsKey(branch.getUID())) { throw new RuntimeException(String.format("Could not add new classification '%s', because the key is already taken by %s.", branch.getUID(), classificationMap.get(branch.getUID()))); } classificationMap.put(branch.getUID(), branch); for (IAlleleHandler handler : this.alleleHandlers) { handler.onRegisterClassification(branch); } }
MothDefinition(ButterflyBranchDefinition branchDefinition, String speciesName, String binomial, Color serumColor, boolean dominant, float rarity) { branch = branchDefinition; String uid = "moth" + name(); IClassification parent = branch.getBranch().getParent(); String unlocalizedName = "for.butterflies.species." + parent.getUID().substring(parent.getLevel().name().toLowerCase(Locale.ENGLISH).length() + 1) + '.' + speciesName; String unlocalizedDescription = "for.description." + uid; String texture = StringUtil.camelCaseToUnderscores("butterflies/" + uid); IAlleleButterflySpeciesBuilder speciesBuilder = ButterflyManager.butterflyFactory.createSpecies("forestry." + uid, unlocalizedName, "Sengir", unlocalizedDescription, Constants.MOD_ID, texture, dominant, branchDefinition.getBranch(), binomial, serumColor); speciesBuilder.setRarity(rarity); speciesBuilder.setNocturnal(); setSpeciesProperties(speciesBuilder); species = speciesBuilder.build(); }
FlowerDefinition(String name, String branch, String binomial, IFlowerType<EnumFlowerType> flowerType, boolean isDominant, EnumFlowerColor primaryColor, EnumFlowerColor secondaryColor) { String modId = Constants.BOTANY_MOD_ID; String uid = modId + ".flower" + this; String unlocalizedDescription = "botany.description.flower" + this; String unlocalizedName = "botany.flowers.species." + name; variantTemplates = new ArrayList<>(); this.name = name; this.binomial = binomial; branchName = branch; type = flowerType; this.primaryColor = primaryColor; this.secondaryColor = secondaryColor; IAlleleFlowerSpeciesBuilder speciesBuilder = BotanyAPI.flowerFactory.createSpecies(modId, uid, unlocalizedName, "Binnie's Mod Team", unlocalizedDescription, isDominant, getBranch(), binomial, flowerType); setSpeciesProperties(speciesBuilder); species = speciesBuilder.build(); if (this.branch != null) { this.branch.addMemberSpecies(species); } }
@Override public final Collection<IClassification> getDiscoveredBranches(final World world, final GameProfile player) { final List<IClassification> branches = new ArrayList<>(); for (final IClassification branch : this.getAllBranches()) { boolean discovered = false; for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, world, player)) { discovered = true; } } if (discovered) { branches.add(branch); } } return branches; }
while (classification != null) { if (!classification.getScientific().isEmpty()) { hierarchy.push(classification); classification = classification.getParent(); 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; if (group != null && group.getLevel() == EnumClassLevel.GENUS) { binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH);
int y = 4; IAlleleSpecies species = ind.getGenome().getPrimary(); String branchBinomial = species.getBranch().getScientific(); String branchName = species.getBranch().getName(); String desc = species.getDescription(); StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString());
public void preInit() { final String scientific = StringUtils.capitalize(branchName); final String uid = "trees." + branchName; branch = AlleleManager.alleleRegistry.getClassification("genus." + uid); if (branch == null) { branch = AlleleManager.alleleRegistry.createAndRegisterClassification(IClassification.EnumClassLevel.GENUS, uid, scientific); } IAlleleTreeSpeciesBuilder speciesBuilder = TreeManager.treeFactory.createSpecies(getUID(), String.format(unlocalizedName, getUID()), getAuthority(), String.format(unlocalizedDesc, getUID()), isDominant(), branch, getBinomial(), Constants.EXTRA_TREES_MOD_ID, leafSpriteProvider, saplingType.getGermlingModelProvider(leafColor, woodColor), woodProvider, this, new ETLeafProvider() ); setSpeciesProperties(speciesBuilder); species = speciesBuilder.build(); branch.addMemberSpecies(species); }
public void initialize() { createAndRegisterClassification(EnumClassLevel.DOMAIN, "archaea", "Archaea"); createAndRegisterClassification(EnumClassLevel.DOMAIN, "bacteria", "Bacteria"); IClassification eukarya = createAndRegisterClassification(EnumClassLevel.DOMAIN, "eukarya", "Eukarya"); eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "animalia", "Animalia")); eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "plantae", "Plantae")); eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "fungi", "Fungi")); eukarya.addMemberGroup(createAndRegisterClassification(EnumClassLevel.KINGDOM, "protista", "Protista")); getClassification("kingdom.animalia").addMemberGroup(createAndRegisterClassification(EnumClassLevel.PHYLUM, "arthropoda", "Arthropoda")); // Animalia getClassification("phylum.arthropoda").addMemberGroup(createAndRegisterClassification(EnumClassLevel.CLASS, "insecta", "Insecta")); }
@Override public final Collection<IClassification> getDiscoveredBranches(final IBreedingTracker tracker) { final List<IClassification> branches = new ArrayList<>(); for (final IClassification branch : this.getAllBranches()) { boolean discovered = false; for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, tracker)) { discovered = true; } } if (discovered) { branches.add(branch); } } return branches; }
private static void createAlleles() { IClassification hymnoptera = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "hymnoptera", "Hymnoptera"); AlleleManager.alleleRegistry.getClassification("class.insecta").addMemberGroup(hymnoptera); IClassification apidae = AlleleManager.alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "apidae", "Apidae"); hymnoptera.addMemberGroup(apidae); for (BeeBranchDefinition beeBranch : BeeBranchDefinition.values()) { apidae.addMemberGroup(beeBranch.getBranch()); } AlleleEffects.registerAlleles(); }
@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); } } }