コード例 #1
0
 /** Called to alter data in all cells */
 public boolean operateOnData(CharacterData data) {
   if (!(data instanceof ContinuousData)) return false;
   ContinuousData cData = (ContinuousData) data;
   int numItems = cData.getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)";
     else items[i] = cData.getItemName(i);
   }
   int d =
       ListDialog.queryList(
           containerOfModule(),
           "Rename item",
           "Rename item:",
           MesquiteString.helpString,
           items,
           0);
   if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false;
   else {
     String s =
         MesquiteString.queryString(
             containerOfModule(), "Rename Item", "New name for " + items[d], items[d]);
     if (StringUtil.blank(s)) return false;
     cData.setItemReference(d, NameReference.getNameReference(s));
     return true;
   }
 }
コード例 #2
0
 /*..........................................MContinuousStates................*/
 public int userQueryItem(String message, MesquiteModule module) {
   int numItems = getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(getItemName(i))) items[i] = "(unnamed)";
     else items[i] = getItemName(i);
   }
   return ListDialog.queryList(
       module.containerOfModule(), "Select item", message, MesquiteString.helpString, items, 0);
 }
コード例 #3
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;
  }