// Path: src/starbeast2/SpeciesTree.java
// public class SpeciesTree extends Tree implements SpeciesTreeInterface {
//     Map<String, Integer> tipNumberMap;
//     Multimap<Integer, String> numberTipMap;
// 
//     public void initAndValidate() {
//         super.initAndValidate();
// 
//         tipNumberMap = new LinkedHashMap<>();
//         numberTipMap = HashMultimap.create();
// 
//         makeMaps();
//     }
// 
//     public Map<String, Integer> getTipNumberMap() {
//         return tipNumberMap;
//     }
// 
//     public Multimap<Integer, String> getNumberTipMap() {
//         return numberTipMap;
//     }
// 
// 	public void adjustTreeNodeHeights() {
// 		adjustTreeNodeHeights(root);
// 	}
// }
// 
// Path: src/starbeast2/StarBeastTaxonSet.java
// @Description("A TaxonSet is an ordered set of taxa. The order on the taxa is provided at the time of construction" +
//         " either from a list of taxon objects or an alignment.")
// public class StarBeastTaxonSet extends TaxonSet {
//     private boolean insideBeauti = false;
// 
//     @Override
//     public void initAndValidate() {
//         updateTaxaNames();
//     }
// 
//     private void updateTaxaNames() {
//         if (taxaNames == null) {
//             taxaNames = new ArrayList<>();
//         } else {
//             taxaNames.clear();
//         }
// 
//         if (taxonsetInput.get() == null && alignmentInput.get() == null) {
//             throw new IllegalArgumentException("Need a taxonset and/or an alignment as input");
//         }
// 
//         if (taxonsetInput.get() != null) {
//             for (Taxon t : taxonsetInput.get()) {
//                 final String taxonName = t.getID();
//                 taxaNames.add(taxonName);
//             }
//         }
// 
//         // Add taxon names in morphology but not in molecular data
//         if (alignmentInput.get() != null) {
//             for (String taxonName : alignmentInput.get().getTaxaNames()) {
//                 if (!taxaNames.contains(taxonName)) taxaNames.add(taxonName);
//             }
//         }
// 
//         insideBeauti |= taxaNames.contains("Beauti2DummyTaxonSet");
//     }
// 
//     // Hack to get tip dates to update correctly
//     @Override
//     public List<String> asStringList() {
//         if (taxaNames == null) return null;
//         if (insideBeauti) updateTaxaNames();
// 
//         return Collections.unmodifiableList(taxaNames);
//     }
// }


import beast.core.BEASTInterface;
import beast.core.Description;
import beast.evolution.alignment.Alignment;
import java.util.*;
import starbeast2.SpeciesTree;
import starbeast2.StarBeastTaxonSet;
package beast.app.beauti;



@Description("Class for creating new partitions for morphological data to be edited by AlignmentListInputEditor")
public class StarBeastMorphModelAlignmentProvider extends BeautiMorphModelAlignmentProvider {
    @Override
    public void processAlignment(Alignment alignment, List<BEASTInterface> filteredAlignments, boolean ascertained, BeautiDoc doc) throws Exception {
        StarBeastTaxonSet ts = (StarBeastTaxonSet) doc.pluginmap.get("taxonsuperset");
        ts.alignmentInput.set(alignment);
        ts.initAndValidate();

// Path: src/starbeast2/SpeciesTree.java
// public class SpeciesTree extends Tree implements SpeciesTreeInterface {
//     Map<String, Integer> tipNumberMap;
//     Multimap<Integer, String> numberTipMap;
// 
//     public void initAndValidate() {
//         super.initAndValidate();
// 
//         tipNumberMap = new LinkedHashMap<>();
//         numberTipMap = HashMultimap.create();
// 
//         makeMaps();
//     }
// 
//     public Map<String, Integer> getTipNumberMap() {
//         return tipNumberMap;
//     }
// 
//     public Multimap<Integer, String> getNumberTipMap() {
//         return numberTipMap;
//     }
// 
// 	public void adjustTreeNodeHeights() {
// 		adjustTreeNodeHeights(root);
// 	}
// }
// 
// Path: src/starbeast2/StarBeastTaxonSet.java
// @Description("A TaxonSet is an ordered set of taxa. The order on the taxa is provided at the time of construction" +
//         " either from a list of taxon objects or an alignment.")
// public class StarBeastTaxonSet extends TaxonSet {
//     private boolean insideBeauti = false;
// 
//     @Override
//     public void initAndValidate() {
//         updateTaxaNames();
//     }
// 
//     private void updateTaxaNames() {
//         if (taxaNames == null) {
//             taxaNames = new ArrayList<>();
//         } else {
//             taxaNames.clear();
//         }
// 
//         if (taxonsetInput.get() == null && alignmentInput.get() == null) {
//             throw new IllegalArgumentException("Need a taxonset and/or an alignment as input");
//         }
// 
//         if (taxonsetInput.get() != null) {
//             for (Taxon t : taxonsetInput.get()) {
//                 final String taxonName = t.getID();
//                 taxaNames.add(taxonName);
//             }
//         }
// 
//         // Add taxon names in morphology but not in molecular data
//         if (alignmentInput.get() != null) {
//             for (String taxonName : alignmentInput.get().getTaxaNames()) {
//                 if (!taxaNames.contains(taxonName)) taxaNames.add(taxonName);
//             }
//         }
// 
//         insideBeauti |= taxaNames.contains("Beauti2DummyTaxonSet");
//     }
// 
//     // Hack to get tip dates to update correctly
//     @Override
//     public List<String> asStringList() {
//         if (taxaNames == null) return null;
//         if (insideBeauti) updateTaxaNames();
// 
//         return Collections.unmodifiableList(taxaNames);
//     }
// }


// Path: src/beast/app/beauti/StarBeastMorphModelAlignmentProvider.java
import beast.core.BEASTInterface;
import beast.core.Description;
import beast.evolution.alignment.Alignment;
import java.util.*;
import starbeast2.SpeciesTree;
import starbeast2.StarBeastTaxonSet;

package beast.app.beauti;



@Description("Class for creating new partitions for morphological data to be edited by AlignmentListInputEditor")
public class StarBeastMorphModelAlignmentProvider extends BeautiMorphModelAlignmentProvider {
    @Override
    public void processAlignment(Alignment alignment, List<BEASTInterface> filteredAlignments, boolean ascertained, BeautiDoc doc) throws Exception {
        StarBeastTaxonSet ts = (StarBeastTaxonSet) doc.pluginmap.get("taxonsuperset");
        ts.alignmentInput.set(alignment);
        ts.initAndValidate();

        SpeciesTree st = (SpeciesTree) doc.pluginmap.get("Tree.t:Species");