Search in sources :

Example 81 with EmptyBorder

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

the class ChartSetupDialog method showDialog.

public int showDialog(JChart chart) {
    JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    Axis xAxis = chart.getXAxis();
    Axis yAxis = chart.getYAxis();
    if (canLogXAxis) {
        logXAxis.setSelected(xAxis instanceof LogAxis);
    }
    if (canLogYAxis) {
        logYAxis.setSelected(yAxis instanceof LogAxis);
    }
    if (!manualXAxis.isSelected()) {
        minXValue.setValue(xAxis.getMinAxis());
        maxXValue.setValue(xAxis.getMaxAxis());
    }
    if (!manualYAxis.isSelected()) {
        minYValue.setValue(yAxis.getMinAxis());
        maxYValue.setValue(yAxis.getMaxAxis());
    }
    final JDialog dialog = optionPane.createDialog(frame, "Setup Chart");
    dialog.pack();
    dialog.setVisible(true);
    final Integer value = (Integer) optionPane.getValue();
    final int result = (value != null && value != -1) ? value : JOptionPane.CANCEL_OPTION;
    if (result == JOptionPane.OK_OPTION) {
        applySettings(chart);
    }
    return result;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 82 with EmptyBorder

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

the class SelectClockDialog method showDialog.

public int showDialog(Object[] models) {
    treeCombo.removeAllItems();
    for (Object model : models) {
        treeCombo.addItem(model);
    }
    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, "Create New Partition Clock Model");
    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 83 with EmptyBorder

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

the class SelectModelDialog method showDialog.

public int showDialog(Object[] models) {
    modelCombo.removeAllItems();
    for (Object model : models) {
        modelCombo.addItem(model);
    }
    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, "Create New Model");
    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 84 with EmptyBorder

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

the class InputFileSettingsDialog method showDialog.

public int showDialog(InputFile inputFile) {
    this.inputFile = inputFile;
    setupPanel(inputFile);
    final 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, "Edit Input File Settings");
    dialog.pack();
    int result = JOptionPane.CANCEL_OPTION;
    dialog.setVisible(true);
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
        result = value;
    }
    return result;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 85 with EmptyBorder

use of javax.swing.border.EmptyBorder 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)

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