Beispiel #1
0
  public void removeSelection() {
    int[] selRows = dataTable.getSelectedRows();
    Set<AbstractPartitionData> partitionsToRemove = new HashSet<AbstractPartitionData>();
    for (int row : selRows) {
      partitionsToRemove.add(options.dataPartitions.get(row));
    }

    boolean hasIdenticalTaxa =
        options.hasIdenticalTaxa(); // need to check this before removing partitions

    // TODO: would probably be a good idea to check if the user wants to remove the last partition
    options.dataPartitions.removeAll(partitionsToRemove);

    if (options.dataPartitions.size() == 0) {
      // all data partitions removed so reset the taxa
      options.reset();
      useStarBEASTCheck.setSelected(false);
      frame.setupStarBEAST(false);
      frame.statusLabel.setText("");
      frame.setAllOptions();
      frame.getExportAction().setEnabled(false);
    } else if (!hasIdenticalTaxa) {
      options.updateTaxonList();
    }

    dataTableModel.fireTableDataChanged();

    fireDataChanged();
  }
Beispiel #2
0
  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();
  }