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;
}
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;
}
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;
}
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;
}
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");
}
Aggregations