Search in sources :

Example 1 with TraitGuesser

use of dr.app.beauti.options.TraitGuesser in project beast-mcmc by beast-dev.

the class TraitsPanel method guessTrait.

public void guessTrait() {
    if (options.taxonList == null) {
        // validation of check empty taxonList
        return;
    }
    if (currentTrait == null) {
        if (!addTrait()) {
            // if addTrait() cancel then false
            return;
        }
    }
    int result;
    do {
        TraitGuesser currentTraitGuesser = new TraitGuesser(currentTrait);
        if (guessTraitDialog == null) {
            guessTraitDialog = new GuessTraitDialog(frame);
        }
        guessTraitDialog.setDescription("Extract values for trait '" + currentTrait + "' from taxa labels");
        result = guessTraitDialog.showDialog();
        if (result == -1 || result == JOptionPane.CANCEL_OPTION) {
            return;
        }
        guessTraitDialog.setupGuesserFromDialog(currentTraitGuesser);
        try {
            int[] selRows = dataTable.getSelectedRows();
            if (selRows.length > 0) {
                Taxa selectedTaxa = new Taxa();
                for (int row : selRows) {
                    Taxon taxon = (Taxon) dataTable.getValueAt(row, 0);
                    selectedTaxa.addTaxon(taxon);
                }
                currentTraitGuesser.guessTrait(selectedTaxa);
            } else {
                currentTraitGuesser.guessTrait(options.taxonList);
            }
        } catch (IllegalArgumentException iae) {
            JOptionPane.showMessageDialog(this, iae.getMessage(), "Unable to guess trait value", JOptionPane.ERROR_MESSAGE);
            result = -1;
        }
        dataTableModel.fireTableDataChanged();
    } while (result < 0);
}
Also used : TraitGuesser(dr.app.beauti.options.TraitGuesser) Taxa(dr.evolution.util.Taxa) Taxon(dr.evolution.util.Taxon)

Aggregations

TraitGuesser (dr.app.beauti.options.TraitGuesser)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1