Search in sources :

Example 1 with RealNumberField

use of dr.app.gui.components.RealNumberField in project beast-mcmc by beast-dev.

the class PriorOptionsPanel method addField.

protected void addField(String name, double initialValue, double min, boolean includeMin, double max, boolean includeMax) {
    RealNumberField field = new RealNumberField(min, includeMin, max, includeMax, name);
    field.setValue(initialValue);
    addField(name, field);
}
Also used : RealNumberField(dr.app.gui.components.RealNumberField)

Example 2 with RealNumberField

use of dr.app.gui.components.RealNumberField in project beast-mcmc by beast-dev.

the class PriorOptionsPanel method addField.

protected void addField(String name, double initialValue, double min, double max) {
    RealNumberField field = new RealNumberField(min, max, name);
    field.setValue(initialValue);
    addField(name, field);
}
Also used : RealNumberField(dr.app.gui.components.RealNumberField)

Example 3 with RealNumberField

use of dr.app.gui.components.RealNumberField in project beast-mcmc by beast-dev.

the class StatisticsPanel method createStatistic.

public TreeSummaryStatistic createStatistic(TreeSummaryStatistic.Factory factory) {
    if (!factory.allowsTaxonList() && !factory.allowsDouble() && !factory.allowsInteger() && !factory.allowsString()) {
        return factory.createStatistic();
    }
    OptionsPanel optionPanel = new OptionsPanel();
    optionPanel.addSpanningComponent(new JLabel(factory.getSummaryStatisticDescription()));
    final JRadioButton wholeTreeRadio = new JRadioButton("For the whole tree", false);
    final JRadioButton taxonSetRadio = new JRadioButton("Using a given taxon set", false);
    final JComboBox taxonSetCombo = new JComboBox();
    final JTextField valueField;
    if (factory.allowsTaxonList()) {
        for (Object taxonSet : treeStatData.taxonSets) {
            taxonSetCombo.addItem(taxonSet);
        }
        ButtonGroup group = new ButtonGroup();
        ItemListener listener = new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                taxonSetCombo.setEnabled(taxonSetRadio.isSelected());
            }
        };
        if (factory.allowsWholeTree()) {
            group.add(wholeTreeRadio);
            wholeTreeRadio.addItemListener(listener);
            optionPanel.addSpanningComponent(wholeTreeRadio);
            optionPanel.addSeparator();
        }
        if (factory.allowsTaxonList()) {
            group.add(taxonSetRadio);
            taxonSetRadio.addItemListener(listener);
            optionPanel.addSpanningComponent(taxonSetRadio);
            optionPanel.addComponentWithLabel("Taxon Set: ", taxonSetCombo);
            optionPanel.addSeparator();
        }
        if (factory.allowsTaxonList()) {
            taxonSetRadio.setSelected(true);
        }
        if (factory.allowsWholeTree()) {
            wholeTreeRadio.setSelected(true);
        }
    }
    if (factory.allowsDouble() || factory.allowsInteger() || factory.allowsString()) {
        if (factory.allowsDouble()) {
            valueField = new RealNumberField();
            valueField.setColumns(12);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        } else if (factory.allowsInteger()) {
            valueField = new WholeNumberField();
            valueField.setColumns(12);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        } else {
            // allowsString
            valueField = new JTextField();
            valueField.setColumns(24);
            optionPanel.addComponentWithLabel(factory.getValueName(), valueField);
        }
    } else {
        valueField = null;
    }
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    JDialog dialog = optionPane.createDialog(frame, factory.getSummaryStatisticName());
    // dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.pack();
    dialog.setVisible(true);
    if (optionPane.getValue() == null) {
        return null;
    }
    int result = (Integer) optionPane.getValue();
    if (result == -1 || result == JOptionPane.CANCEL_OPTION) {
        return null;
    }
    TreeSummaryStatistic statistic = factory.createStatistic();
    if (wholeTreeRadio.isSelected()) {
        statistic = factory.createStatistic();
    } else if (taxonSetRadio.isSelected()) {
        TreeStatData.TaxonSet t = (TreeStatData.TaxonSet) taxonSetCombo.getSelectedItem();
        Taxa taxa = new Taxa();
        taxa.setId(t.name);
        // Iterator iter = t.taxa.iterator();
        for (Object aTaxa : t.taxa) {
            String id = (String) aTaxa;
            Taxon taxon = new Taxon(id);
            taxa.addTaxon(taxon);
        }
        statistic.setTaxonList(taxa);
    } else {
        return null;
    }
    if (factory.allowsDouble()) {
        assert valueField instanceof RealNumberField;
        Double value = ((RealNumberField) valueField).getValue();
        statistic.setDouble(value);
    } else if (factory.allowsInteger()) {
        assert valueField instanceof WholeNumberField;
        Integer value = ((WholeNumberField) valueField).getValue();
        statistic.setInteger(value);
    } else if (factory.allowsString()) {
        String value = valueField.getText();
        statistic.setString(value);
    }
    return statistic;
}
Also used : ItemEvent(java.awt.event.ItemEvent) WholeNumberField(dr.app.gui.components.WholeNumberField) Taxon(dr.evolution.util.Taxon) RealNumberField(dr.app.gui.components.RealNumberField) Taxa(dr.evolution.util.Taxa) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder) OptionsPanel(jam.panels.OptionsPanel)

Example 4 with RealNumberField

use of dr.app.gui.components.RealNumberField in project beast-mcmc by beast-dev.

the class PriorOptionsPanel method addField.

protected void addField(String name, double initialValue, double min, double max) {
    RealNumberField field = new RealNumberField(min, max, name);
    field.setValue(initialValue);
    addField(name, field);
}
Also used : RealNumberField(dr.app.gui.components.RealNumberField)

Example 5 with RealNumberField

use of dr.app.gui.components.RealNumberField in project beast-mcmc by beast-dev.

the class PriorOptionsPanel method addField.

protected void addField(String name, double initialValue, double min, boolean includeMin, double max, boolean includeMax) {
    RealNumberField field = new RealNumberField(min, includeMin, max, includeMax, name);
    field.setValue(initialValue);
    addField(name, field);
}
Also used : RealNumberField(dr.app.gui.components.RealNumberField)

Aggregations

RealNumberField (dr.app.gui.components.RealNumberField)5 WholeNumberField (dr.app.gui.components.WholeNumberField)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1 OptionsPanel (jam.panels.OptionsPanel)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 EmptyBorder (javax.swing.border.EmptyBorder)1