コード例 #1
0
ファイル: DataPanel.java プロジェクト: JifengJiang/beast-mcmc
  public void linkTrees() { // keep previous PartitionTreePrior for reuse
    int[] selRows = dataTable.getSelectedRows();

    List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>();
    for (int row : selRows) {
      AbstractPartitionData partition = options.dataPartitions.get(row);

      if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition);
    }

    if (selectedPartitionData.size() > 1) {
      if (!options.hasIdenticalTaxa(selectedPartitionData)) {
        String errMsg = "To share a tree, partitions need to have identical taxa.";
        if (selectedPartitionData.get(0).getDataType().getType() == DataType.MICRO_SAT)
          errMsg += "\nThe data must be all diploid or all haploid when you want to link the tree.";
        JOptionPane.showMessageDialog(
            this, errMsg, "Illegal Configuration", JOptionPane.ERROR_MESSAGE);
        return;
      }
    }

    Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray();

    if (selectTreeDialog == null) {
      selectTreeDialog = new SelectTreeDialog(frame);
    }

    int result = selectTreeDialog.showDialog(treeArray);
    if (result != JOptionPane.CANCEL_OPTION) {
      PartitionTreeModel model = selectTreeDialog.getTree();
      if (selectTreeDialog.getMakeCopy()) {
        model.setName(selectTreeDialog.getName());
      }
      PartitionTreePrior prior = model.getPartitionTreePrior();
      options.linkTreePriors(prior);

      for (AbstractPartitionData partition : selectedPartitionData) {
        partition.setPartitionTreeModel(model);
      }

      for (Taxa taxa :
          options.taxonSets) { // Issue 454: all the taxon sets are deleted when link/unlink tree
        PartitionTreeModel prevModel = options.taxonSetsTreeModel.get(taxa);
        if (prevModel != model) options.taxonSetsTreeModel.put(taxa, model);
      }
    }

    modelsChanged();

    fireDataChanged();
    repaint();
  }
コード例 #2
0
ファイル: DataPanel.java プロジェクト: benb/beast-mcmc
  public void linkTrees() { // keep previous PartitionTreePrior for reuse
    int[] selRows = dataTable.getSelectedRows();

    List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>();
    for (int row : selRows) {
      PartitionData partition = options.dataPartitions.get(row);

      if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition);
    }

    if (options.allowDifferentTaxa) { // BEAST cannot handle multi <taxa> ref for 1 tree
      if (selectedPartitionData.size() > 1) {
        if (!options.validateDiffTaxa(selectedPartitionData)) {
          JOptionPane.showMessageDialog(
              this,
              "To accommodate different taxa for each partition trees cannot be linked.",
              "Illegal Configuration",
              JOptionPane.ERROR_MESSAGE);
          return;
        }
      }
    }

    Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray();

    if (selectTreeDialog == null) {
      selectTreeDialog = new SelectTreeDialog(frame);
    }

    int result = selectTreeDialog.showDialog(treeArray);
    if (result != JOptionPane.CANCEL_OPTION) {
      PartitionTreeModel model = selectTreeDialog.getTree();
      if (selectTreeDialog.getMakeCopy()) {
        model.setName(selectTreeDialog.getName());
      }
      PartitionTreePrior prior = model.getPartitionTreePrior();
      options.linkTreePriors(prior);

      for (PartitionData partition : selectedPartitionData) {
        partition.setPartitionTreeModel(model);
      }
    }

    modelsChanged();

    fireDataChanged();
    options.taxonSets.clear();
    options.taxonSetsMono.clear();
    repaint();
  }