use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class SamplesPanel method clearDates.
public void clearDates() {
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
java.util.Date origin = new java.util.Date(0);
double d = 0.0;
Date date = Date.createTimeSinceOrigin(d, Units.Type.YEARS, origin);
taxonList.getTaxon(i).setAttribute("date", date);
}
// adjust the dates to the current timescale...
timeScaleChanged();
dataTableModel.fireTableDataChanged();
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class SamplesPanel method calculateHeights.
private void calculateHeights() {
maximumTipHeight = 0.0;
if (taxonList == null || taxonList.getTaxonCount() == 0)
return;
heights = null;
Date mostRecent = null;
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
Date date = taxonList.getTaxon(i).getDate();
if ((date != null) && (mostRecent == null || date.after(mostRecent))) {
mostRecent = date;
}
}
if (mostRecent != null) {
heights = new double[taxonList.getTaxonCount()];
TimeScale timeScale = new TimeScale(mostRecent.getUnits(), true, mostRecent.getAbsoluteTimeValue());
double time0 = timeScale.convertTime(mostRecent.getTimeValue(), mostRecent);
for (int i = 0; i < taxonList.getTaxonCount(); i++) {
Date date = taxonList.getTaxon(i).getDate();
if (date != null) {
heights[i] = timeScale.convertTime(date.getTimeValue(), date) - time0;
if (heights[i] > maximumTipHeight)
maximumTipHeight = heights[i];
}
}
}
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class TipDatesPanel method clearDates.
private void clearDates() {
for (int i = 0; i < options.taxonList.getTaxonCount(); i++) {
java.util.Date origin = new java.util.Date(0);
double d = 0.0;
Date date = Date.createTimeSinceOrigin(d, Units.Type.YEARS, origin);
options.taxonList.getTaxon(i).setAttribute("date", date);
}
// adjust the dates to the current timescale...
timeScaleChanged();
dataTableModel.fireTableDataChanged();
}
use of dr.evolution.util.Date 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.setUncertainty(date.getUncertainty());
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.useTipDates) {
for (PartitionTreeModel treeModel : options.getPartitionTreeModels()) {
treeModel.setTipCalibrations(true);
}
}
dataTableModel.fireTableDataChanged();
frame.setDirty();
}
use of dr.evolution.util.Date in project beast-mcmc by beast-dev.
the class TipDatesPanel method calculateHeights.
private void calculateHeights() {
options.maximumTipHeight = 0.0;
if (options.taxonList == null || options.taxonList.getTaxonCount() == 0)
return;
heights = null;
dr.evolution.util.Date mostRecent = options.originDate;
for (int i = 0; i < options.taxonList.getTaxonCount(); i++) {
Date date = options.taxonList.getTaxon(i).getDate();
if ((date != null) && (mostRecent == null || date.after(mostRecent))) {
mostRecent = date;
}
}
if (mostRecent != null) {
heights = new double[options.taxonList.getTaxonCount()];
TimeScale timeScale = new TimeScale(mostRecent.getUnits(), true, mostRecent.getAbsoluteTimeValue());
double time0 = timeScale.convertTime(mostRecent.getTimeValue(), mostRecent);
for (int i = 0; i < options.taxonList.getTaxonCount(); i++) {
Taxon taxon = options.taxonList.getTaxon(i);
Date date = taxon.getDate();
if (date != null) {
heights[i] = timeScale.convertTime(date.getTimeValue(), date) - time0;
taxon.setAttribute("height", heights[i]);
if (heights[i] > options.maximumTipHeight)
options.maximumTipHeight = heights[i];
}
}
}
frame.setStatusMessage();
}
Aggregations