Search in sources :

Example 1 with DateUnitsType

use of dr.evoxml.util.DateUnitsType in project beast-mcmc by beast-dev.

the class TipDatesPanel method timeScaleChanged.

public final void timeScaleChanged() {
    Units.Type units = Units.Type.YEARS;
    switch((DateUnitsType) unitsCombo.getSelectedItem()) {
        case YEARS:
            units = Units.Type.YEARS;
            break;
        case MONTHS:
            units = Units.Type.MONTHS;
            break;
        case DAYS:
            units = Units.Type.DAYS;
            break;
    }
    boolean backwards = directionCombo.getSelectedItem() == DateUnitsType.BACKWARDS;
    for (int i = 0; i < options.taxonList.getTaxonCount(); i++) {
        Date date = options.taxonList.getTaxon(i).getDate();
        double d = date.getTimeValue();
        Date newDate = createDate(d, units, backwards, 0.0);
        newDate.setPrecision(date.getPrecision());
        options.taxonList.getTaxon(i).setDate(newDate);
    }
    if (specifyOriginDate.isSelected()) {
        String text = originDateText.getText();
        DateGuesser guesser = options.dateGuesser;
        guessDatesDialog.setupGuesser(guesser);
        try {
            options.originDate = guesser.parseDate(text);
        } catch (GuessDatesException e) {
            options.originDate = null;
        }
    } else {
        options.originDate = null;
    }
    if (options.originDate != null) {
        originDateLabel.setText(" date value: " + Double.toString(options.originDate.getTimeValue()));
    } else {
        originDateLabel.setText(" unable to parse date");
    }
    calculateHeights();
    if (options.clockModelOptions.isTipCalibrated()) {
        // todo correct?
        for (PartitionTreeModel treeModel : options.getPartitionTreeModels()) {
            treeModel.setTipCalibrations(true);
        }
    }
    dataTableModel.fireTableDataChanged();
    frame.setDirty();
}
Also used : DateUnitsType(dr.evoxml.util.DateUnitsType) Date(dr.evolution.util.Date)

Aggregations

Date (dr.evolution.util.Date)1 DateUnitsType (dr.evoxml.util.DateUnitsType)1