/*.................................................................................................................*/
 public boolean transformTree(AdjustableTree tree, MesquiteString resultString, boolean notify) {
   if (!(tree instanceof MesquiteTree)) return false;
   reinterpret((MesquiteTree) tree, tree.getRoot());
   if (notify && tree instanceof Listened)
     ((Listened) tree).notifyListeners(this, new Notification(MesquiteListener.NAMES_CHANGED));
   return true;
 }
Ejemplo n.º 2
0
  /*.................................................................................................................*/
  public boolean transformTree(AdjustableTree tree, MesquiteString resultString, boolean notify) {
    Taxa taxa = tree.getTaxa();
    // counting how many excluded
    int count = 0;
    for (int i = 0; i < taxa.getNumTaxa(); i++) {
      if (!tree.taxonInTree(i)) count++;
    }
    if (count == 0) {
      discreetAlert(
          "The tree contains all of the taxa available in the block of taxa.  There are none available to be added");
      return true;
    }
    // getting list of excluded
    ListableVector excluded = new ListableVector(count);
    count = 0;
    for (int i = 0; i < taxa.getNumTaxa(); i++) {
      if (!tree.taxonInTree(i)) {
        excluded.addElement(taxa.getTaxon(i), false);
      }
    }

    // presenting choice
    Listable[] toInclude =
        ListDialog.queryListMultiple(
            containerOfModule(),
            "Add taxa to tree",
            "Select taxa to be added to the tree",
            MesquiteString.helpString,
            "Add",
            false,
            excluded,
            null);
    if (toInclude == null || toInclude.length == 0) return true;

    for (int i = 0; i < toInclude.length; i++) {
      int taxon = taxa.whichTaxonNumber((Taxon) toInclude[i]);
      tree.graftTaxon(taxon, tree.getRoot(), false);
    }
    if (notify && tree instanceof Listened)
      ((Listened) tree)
          .notifyListeners(this, new Notification(MesquiteListener.BRANCHES_REARRANGED));
    return true;
  }