Search in sources :

Example 1 with OptionsPanel

use of jam.panels.OptionsPanel in project beast-mcmc by beast-dev.

the class JointPriorDialog method setupComponents.

private void setupComponents() {
    panel.removeAll();
    JScrollPane scrollPane1 = new JScrollPane(parametersTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane1.setOpaque(false);
    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(addParameterAction);
    actionPanel1.setRemoveAction(removeParameterAction);
    actionPanel1.setAddToolTipText("Use this button to add an existing parameter to the prior");
    actionPanel1.setRemoveToolTipText("Use this button to remove a parameter from the prior");
    removeParameterAction.setEnabled(false);
    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);
    JPanel panel1 = new JPanel(new BorderLayout(0, 0));
    panel1.setOpaque(false);
    panel1.add(new JLabel("Linked parameters:"), BorderLayout.NORTH);
    panel1.add(scrollPane1, BorderLayout.CENTER);
    // removing the control panel for now. Not sure whether we really want adding and
    // removing of parameteres in this dialog.
    //        panel1.add(controlPanel1, BorderLayout.SOUTH);
    panel1.setSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT));
    panel1.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT));
    panel1.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, MINIMUM_TABLE_HEIGHT));
    OptionsPanel optionsPanel = new OptionsPanel(0, 6);
    if (parameter.getName() != null) {
        nameField.setText(parameter.getName());
    } else {
        nameField.setText("Untitled");
    }
    optionsPanel.addComponentWithLabel("Unique Name: ", nameField);
    //        optionsPanel.addComponentWithLabel("Initial Value: ", initialField);
    panel.setOpaque(false);
    panel.setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 2;
    panel.add(optionsPanel, c);
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.VERTICAL;
    c.gridwidth = 1;
    panel.add(panel1, c);
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.PAGE_START;
    c.gridwidth = GridBagConstraints.REMAINDER;
    panel.add(priorSettingsPanel, c);
}
Also used : BorderUIResource(javax.swing.plaf.BorderUIResource) ActionPanel(jam.panels.ActionPanel) OptionsPanel(jam.panels.OptionsPanel)

Example 2 with OptionsPanel

use of jam.panels.OptionsPanel in project beast-mcmc by beast-dev.

the class GLMSettingsPanel method setupComponents.

private void setupComponents() {
    removeAll();
    OptionsPanel optionsPanel = new OptionsPanel(12, (OSType.isMac() ? 6 : 24));
    JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel1.add(optionsPanel);
    repaint();
}
Also used : OptionsPanel(jam.panels.OptionsPanel)

Example 3 with OptionsPanel

use of jam.panels.OptionsPanel in project beast-mcmc by beast-dev.

the class PriorSettingsPanel method setupComponents.

private void setupComponents() {
    removeAll();
    OptionsPanel optionsPanel = new OptionsPanel(12, (OSType.isMac() ? 6 : 24));
    JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel1.add(optionsPanel);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panel1, gbc);
    PriorType priorType = (PriorType) priorCombo.getSelectedItem();
    if (!parameter.isPriorFixed) {
        optionsPanel.addComponentWithLabel("Prior Distribution: ", priorCombo);
    } else {
        optionsPanel.addComponentWithLabel("Prior Distribution: ", new JLabel(priorType.toString()));
    }
    PriorOptionsPanel panel3 = optionsPanels.get(priorType);
    if (panel3 != null) {
        // important to make init field appear during switch
        panel3.setArguments(parameter, priorType);
        optionsPanel.addSpanningComponent(panel3);
    }
    if (priorType == PriorType.CTMC_RATE_REFERENCE_PRIOR) {
        optionsPanel.addSpanningComponent(citationText);
    }
    if (priorType == PriorType.ONE_OVER_X_PRIOR) {
        optionsPanel.addSpanningComponent(oneOverXCaution);
    }
    if (priorType == PriorType.NONE_IMPROPER) {
        optionsPanel.addSpanningComponent(improperCaution);
    }
    if (priorType.isPlottable()) {
        optionsPanel.addSeparator();
        setupChart();
        chart.setMinimumSize(new Dimension(120, 120));
        chart.setPreferredSize(new Dimension(300, 200));
        chart.setFontSize(8);
        gbc.gridy = 1;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        add(chart, gbc);
        gbc.gridy = 2;
        gbc.weighty = 0.0;
        gbc.anchor = GridBagConstraints.PAGE_END;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        add(quantilePanel, gbc);
    }
    repaint();
}
Also used : PriorType(dr.app.beauti.types.PriorType) OptionsPanel(jam.panels.OptionsPanel)

Example 4 with OptionsPanel

use of jam.panels.OptionsPanel 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 5 with OptionsPanel

use of jam.panels.OptionsPanel in project beast-mcmc by beast-dev.

the class PartitionModelPanel method setupPanel.

/**
     * Lays out the appropriate components in the panel for this partition
     * model.
     */
private void setupPanel() {
    switch(model.getDataType().getType()) {
        case DataType.NUCLEOTIDES:
            addComponentWithLabel("Substitution Model:", nucSubstCombo);
            addComponentWithLabel("Base frequencies:", frequencyCombo);
            addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
            heteroCombo.setSelectedIndex(0);
            gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
            gammaCatCombo.setEnabled(false);
            addSeparator();
            addComponentWithLabel("Partition into codon positions:", codingCombo);
            JPanel panel2 = new JPanel();
            panel2.setOpaque(false);
            panel2.setLayout(new BoxLayout(panel2, BoxLayout.PAGE_AXIS));
            panel2.setBorder(BorderFactory.createTitledBorder("Link/Unlink parameters:"));
            panel2.add(substUnlinkCheck);
            panel2.add(heteroUnlinkCheck);
            panel2.add(freqsUnlinkCheck);
            addComponent(panel2);
            addComponent(setYang96Button);
            addComponent(setSRD06Button);
            break;
        case DataType.AMINO_ACIDS:
            addComponentWithLabel("Substitution Model:", aaSubstCombo);
            addComponentWithLabel("Citation:", citationText);
            addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
            heteroCombo.setSelectedIndex(0);
            gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
            gammaCatCombo.setEnabled(false);
            break;
        case DataType.TWO_STATES:
        case DataType.COVARION:
            addComponentWithLabel("Substitution Model:", binarySubstCombo);
            addComponentWithLabel("Base frequencies:", frequencyCombo);
            addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
            heteroCombo.setSelectedIndex(0);
            gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
            gammaCatCombo.setEnabled(false);
            addSeparator();
            addComponentWithLabel("", useAmbiguitiesTreeLikelihoodCheck);
            // Easy XML specification is currently only available for binary models
            if (ENABLE_STOCHASTIC_DOLLO) {
                addSeparator();
                addComponent(dolloCheck);
            }
            break;
        case DataType.GENERAL:
            addComponentWithLabel("Discrete Trait Substitution Model:", discreteTraitSiteModelCombo);
            addComponent(activateBSSVS);
            addComponent(setupGLMButton);
            break;
        case DataType.CONTINUOUS:
            addComponentWithLabel("Continuous Trait Model:", continuousTraitSiteModelCombo);
            addComponent(latLongCheck);
            addSeparator();
            addComponent(addJitterCheck);
            OptionsPanel panel = new OptionsPanel();
            panel.addComponents(jitterWindowLabel, jitterWindowText);
            addComponent(panel);
            jitterWindowLabel.setEnabled(false);
            jitterWindowText.setEnabled(false);
            addSeparator();
            addComponent(useLambdaCheck);
            break;
        case DataType.MICRO_SAT:
            addComponentWithLabel("Microsatellite Name:", microsatName);
            addComponentWithLabel("Max of Length:", microsatMax);
            addComponentWithLabel("Min of Length:", microsatMin);
            addComponent(shareMicroSatCheck);
            addSeparator();
            addComponentWithLabel("Rate Proportionality:", rateProportionCombo);
            addComponentWithLabel("Mutational Bias:", mutationBiasCombo);
            addComponentWithLabel("Phase:", phaseCombo);
            break;
        default:
            throw new IllegalArgumentException("Unknown data type");
    }
    setOptions();
}
Also used : OptionsPanel(jam.panels.OptionsPanel)

Aggregations

OptionsPanel (jam.panels.OptionsPanel)6 PriorType (dr.app.beauti.types.PriorType)2 Parameter (dr.app.beauti.options.Parameter)1 RealNumberField (dr.app.gui.components.RealNumberField)1 WholeNumberField (dr.app.gui.components.WholeNumberField)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1 ActionPanel (jam.panels.ActionPanel)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 EmptyBorder (javax.swing.border.EmptyBorder)1 BorderUIResource (javax.swing.plaf.BorderUIResource)1