Search in sources :

Example 86 with EmptyBorder

use of javax.swing.border.EmptyBorder in project beast-mcmc by beast-dev.

the class HierarchicalPriorDialog method showDialog.

public int showDialog(final java.util.List<Parameter> parameterList) {
    this.parameterList = parameterList;
    this.parameter = parameterList.get(0);
    PriorType priorType = parameter.priorType;
    // Set-up combo box depending on parameters
    priorCombo.removeAllItems();
    if (parameter.isNonNegative) {
        priorCombo.addItem(PriorType.LOGNORMAL_HPM_PRIOR);
    }
    priorCombo.addItem(PriorType.NORMAL_HPM_PRIOR);
    priorCombo.setSelectedItem(priorType);
    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;
    if (parameter.isZeroOne) {
        lower = 0.0;
        upper = 1.0;
    } else if (parameter.isNonNegative) {
        lower = 0.0;
    }
    initialField.setRange(lower, upper);
    initialField.setValue(parameter.getInitial());
    panel = new JPanel(new GridBagLayout());
    setupComponents();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);
    scrollPane.getViewport().setOpaque(false);
    JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, "Phylogenetic Hierarchical Model Setup");
    priorCombo.addItemListener(new ItemListener() {

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

            public void optionsPanelChanged() {
                setupChart();
                dialog.validate();
                dialog.repaint();
            }
        });
    }
    dialog.pack();
    if (OSType.isMac()) {
        dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        if (d.height < 700 && panel.getHeight() > 450) {
            dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
        } else {
            // setSize because optionsPanel is shrunk in dialog
            dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
        }
    //            System.out.println("panel width = " + panel.getWidth());
    //            System.out.println("panel height = " + panel.getHeight());
    }
    dialog.setResizable(true);
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : ItemEvent(java.awt.event.ItemEvent) PriorType(dr.app.beauti.types.PriorType) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 87 with EmptyBorder

use of javax.swing.border.EmptyBorder in project beast-mcmc by beast-dev.

the class JointPriorDialog method showDialog.

public int showDialog() {
    panel = new JPanel(new GridBagLayout());
    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;
    if (parameter.isZeroOne) {
        lower = 0.0;
        upper = 1.0;
    } else if (parameter.isNonNegative) {
        lower = 0.0;
    }
    panel = new JPanel(new GridBagLayout());
    setupComponents();
    JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup");
    priorSettingsPanel.setDialog(dialog);
    priorSettingsPanel.setParameter(parameter);
    if (OSType.isMac()) {
        dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        if (d.height < 700 && panel.getHeight() > 450) {
            dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
        } else {
            // setSize because optionsPanel is shrunk in dialog
            dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
        }
    //            System.out.println("panel width = " + panel.getWidth());
    //            System.out.println("panel height = " + panel.getHeight());
    }
    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 88 with EmptyBorder

use of javax.swing.border.EmptyBorder in project beast-mcmc by beast-dev.

the class GuessTraitDialog method showDialog.

public int showDialog() {
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, "Guess Trait Value for Taxa");
    dialog.pack();
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 89 with EmptyBorder

use of javax.swing.border.EmptyBorder in project beast-mcmc by beast-dev.

the class GuessDatesDialog method showDialog.

public int showDialog(boolean parsingFromFile) {
    setupPanel(parsingFromFile);
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    final JDialog dialog = optionPane.createDialog(frame, description);
    dialog.pack();
    dialog.setVisible(true);
    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
        setPreferencesFromDialog();
    }
    return result;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 90 with EmptyBorder

use of javax.swing.border.EmptyBorder in project beast-mcmc by beast-dev.

the class DefaultPriorTableDialog method showDialog.

public boolean showDialog(BeautiOptions options) {
    priorsPanel.setParametersList(options);
    Object[] buttons;
    JOptionPane optionPane;
    String title;
    if (priorsPanel.hasUndefinedPrior) {
        title = "Undefined Priors";
    } else {
        title = "Unchanged Default Priors";
    }
    buttons = new String[] { "Continue", "Cancel" };
    optionPane = new JOptionPane(priorsPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, buttons, buttons[0]);
    JButton button = findButton("Continue", optionPane);
    if (button != null) {
        priorsPanel.setContinueButton(button);
    }
    //       if (priorsPanel.hasUndefinedPrior) {
    //            buttons = new String[] {"OK"};
    //            title = "Undefined Priors";
    //            optionPane = new JOptionPane(priorsPanel,
    //                    JOptionPane.ERROR_MESSAGE,
    //                    JOptionPane.OK_OPTION,
    //                    null,
    //                    buttons,
    //                    buttons[0]);
    //        } else {
    //            buttons = new String[] {"Continue", "Cancel"};
    //            title = "Unchanged Default Priors";
    //            optionPane = new JOptionPane(priorsPanel,
    //                    JOptionPane.PLAIN_MESSAGE,
    //                    JOptionPane.OK_CANCEL_OPTION,
    //                    null,
    //                    buttons,
    //                    buttons[0]);
    //        }
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    optionPane.setPreferredSize(new java.awt.Dimension(800, 600));
    final JDialog dialog = optionPane.createDialog(frame, title);
    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);
    return optionPane.getValue() != null && optionPane.getValue().equals("Continue");
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder) java.awt(java.awt)

Aggregations

EmptyBorder (javax.swing.border.EmptyBorder)224 JPanel (javax.swing.JPanel)96 BorderLayout (java.awt.BorderLayout)87 JLabel (javax.swing.JLabel)70 JButton (javax.swing.JButton)44 JScrollPane (javax.swing.JScrollPane)44 Insets (java.awt.Insets)37 Dimension (java.awt.Dimension)35 Border (javax.swing.border.Border)30 GridBagLayout (java.awt.GridBagLayout)29 ActionEvent (java.awt.event.ActionEvent)27 ActionListener (java.awt.event.ActionListener)27 TitledBorder (javax.swing.border.TitledBorder)25 GridBagConstraints (java.awt.GridBagConstraints)24 Box (javax.swing.Box)22 JTextField (javax.swing.JTextField)21 CompoundBorder (javax.swing.border.CompoundBorder)20 BoxLayout (javax.swing.BoxLayout)17 FlowLayout (java.awt.FlowLayout)16 JCheckBox (javax.swing.JCheckBox)16