Search in sources :

Example 11 with PriorType

use of dr.app.beauti.types.PriorType in project beast-mcmc by beast-dev.

the class PriorSettingsPanel method setupChart.

void setupChart() {
    chart.removeAllPlots();
    if (hasInvalidInput(false)) {
        quantileText.setText("Invalid input");
        return;
    }
    PriorType priorType = (PriorType) priorCombo.getSelectedItem();
    if (priorType == null) {
        priorType = parameter.priorType;
        priorCombo.setSelectedItem(priorType);
    }
    PriorOptionsPanel priorOptionsPanel = optionsPanels.get(priorType);
    // TODO is this used or duplicated to OffsetPositiveDistribution?
    double offset = 0.0;
    // this does not refresh dist from parameter truncation lower/upper, it get them from GUI
    Distribution distribution = priorOptionsPanel.getDistribution(parameter);
    chart.addPlot(new PDFPlot(distribution, offset));
    if (distribution != null) {
        quantileText.setText(formatter.format(distribution.quantile(0.025)) + "\n" + formatter.format(distribution.quantile(0.05)) + "\n" + formatter.format(distribution.quantile(0.5)) + "\n" + formatter.format(distribution.quantile(0.95)) + "\n" + formatter.format(distribution.quantile(0.975)));
    }
}
Also used : Distribution(dr.math.distributions.Distribution) PriorType(dr.app.beauti.types.PriorType) PDFPlot(dr.app.gui.chart.PDFPlot)

Example 12 with PriorType

use of dr.app.beauti.types.PriorType in project beast-mcmc by beast-dev.

the class PriorSettingsPanel method setParameter.

/**
 * Set the parameter to be controlled
 *                                                                                                       q
 * @param parameter
 */
public void setParameter(final Parameter parameter) {
    this.parameter = parameter;
    priorCombo = new JComboBox();
    for (PriorType priorType : PriorType.getPriorTypes(parameter)) {
        priorCombo.addItem(priorType);
    }
    if (parameter.priorType != null) {
        priorCombo.setSelectedItem(parameter.priorType);
    }
    // setArguments here
    setupComponents();
    priorCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            setupComponents();
            dialog.pack();
            dialog.repaint();
        }
    });
    for (PriorOptionsPanel optionsPanel : optionsPanels.values()) {
        optionsPanel.removeAllListeners();
        optionsPanel.addListener(new PriorOptionsPanel.Listener() {

            public void optionsPanelChanged() {
                setupChart();
                dialog.pack();
                dialog.repaint();
            }
        });
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener) PriorType(dr.app.beauti.types.PriorType)

Aggregations

PriorType (dr.app.beauti.types.PriorType)12 OptionsPanel (jam.panels.OptionsPanel)4 ItemEvent (java.awt.event.ItemEvent)4 ItemListener (java.awt.event.ItemListener)4 PDFPlot (dr.app.gui.chart.PDFPlot)2 Distribution (dr.math.distributions.Distribution)2 EmptyBorder (javax.swing.border.EmptyBorder)2 Parameter (dr.app.beauti.options.Parameter)1