public boolean alterBlockOfCharacters(CharacterData data, int icStart, int icEnd) {
    if (data == null) return false;
    if (data instanceof MolecularData) {
      MolecularData mData = (MolecularData) data;
      mData.reverse(icStart, icEnd, true);
    } else {
      for (int it = 0; it < data.getNumTaxa(); it++)
        for (int i = 0; i <= (icEnd - icStart) / 2 && icStart + i < icEnd - i; i++) {
          data.tradeStatesBetweenCharacters(icStart + i, icEnd - i, it, true);
        }
    }

    return true;
  }
  public boolean alterBlockInTaxon(CharacterData data, int icStart, int icEnd, int it) {
    if (data == null) return false;

    if (data instanceof MolecularData) {
      MolecularData mData = (MolecularData) data;
      mData.reverse(icStart, icEnd, it, false, true);
    } else
      for (int i = 0; i <= (icEnd - icStart) / 2 && icStart + i < icEnd - i; i++) {
        data.tradeStatesBetweenCharacters(icStart + i, icEnd - i, it, true);
      }

    return true;
  }
示例#3
0
  /*.................................................................................................................*/
  private void recordSourceProject() {
    MesquiteString s = new MesquiteString();
    s.setValue(getProject().getHomeFileName());
    if (!QueryDialogs.queryString(
        containerOfModule(),
        "Name to Stamp",
        "Indicate source file name to stamp on matrix rows",
        s)) return;

    int numMatrices = getProject().getNumberCharMatrices();
    NameReference sourceRef = NameReference.getNameReference("SourceFile");

    for (int im = 0; im < numMatrices; im++) {
      CharacterData data = getProject().getCharacterMatrix(im);
      Taxa taxa = data.getTaxa();
      Associable tInfo = data.getTaxaInfo(true);
      boolean anySelected = taxa.anySelected();
      for (int it = 0; it < taxa.getNumTaxa(); it++) {
        if (data.hasDataForTaxon(it) && (!anySelected || taxa.getSelected(it)))
          tInfo.setAssociatedObject(sourceRef, it, s.getValue());
      }
    }
  }
示例#4
0
 public Associable getTaxaInfo(CharacterData data, boolean makeIfNotPresent) {
   if (makeIfNotPresent && taxaInfo == null) {
     taxaInfo = new TaxaInfo(data.getNumTaxa(), data);
   }
   return taxaInfo;
 }
  /** 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;
  }