/** Called to operate on the CharacterData blocks. Returns true if taxa altered */
  public boolean operateOnDatas(ListableVector datas, MesquiteTable table) {
    boolean anyExcluded = false;
    for (int im = 0; im < datas.size(); im++) {
      CharacterData data = (CharacterData) datas.elementAt(im);
      if (data.numCharsCurrentlyIncluded() < data.getNumChars()) anyExcluded = true;
    }
    if (anyExcluded) queryOptions();
    if (getProject() != null) getProject().incrementProjectWindowSuppression();
    for (int im = 0; im < datas.size(); im++) {
      CharacterData data = (CharacterData) datas.elementAt(im);
      CharacterData starter = data.makeCharacterData(data.getMatrixManager(), data.getTaxa());

      starter.addToFile(
          getProject().getHomeFile(), getProject(), findElementManager(CharacterData.class));

      boolean success =
          starter.concatenate(data, false, duplicateExcludedCharacters, false, false, false, false);
      if (success) {
        starter.setName(datas.getUniqueName(data.getName() + " (duplicate)"));
      }
    }
    if (getProject() != null) getProject().decrementProjectWindowSuppression();
    resetAllMenuBars();
    return true;
  }
Пример #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;
  }