| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.beauti.treespanel; |
| 27 |
|
| 28 |
import dr.app.beauti.options.AbstractPartitionData; |
| 29 |
import dr.app.beauti.options.BeautiOptions; |
| 30 |
import dr.app.beauti.options.PartitionData; |
| 31 |
import jam.panels.OptionsPanel; |
| 32 |
|
| 33 |
import javax.swing.*; |
| 34 |
import javax.swing.border.EmptyBorder; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public class GenerateTreeDialog { |
| 42 |
|
| 43 |
private JFrame frame; |
| 44 |
|
| 45 |
public static enum MethodTypes { |
| 46 |
NJ, |
| 47 |
UPGMA |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
JTextField nameField; |
| 52 |
JComboBox partitionCombo; |
| 53 |
JComboBox methodCombo; |
| 54 |
|
| 55 |
OptionsPanel optionPanel; |
| 56 |
|
| 57 |
public GenerateTreeDialog(JFrame frame) { |
| 58 |
this.frame = frame; |
| 59 |
|
| 60 |
nameField = new JTextField(); |
| 61 |
nameField.setColumns(20); |
| 62 |
|
| 63 |
methodCombo = new JComboBox(MethodTypes.values()); |
| 64 |
partitionCombo = new JComboBox(); |
| 65 |
|
| 66 |
optionPanel = new OptionsPanel(12, 12); |
| 67 |
optionPanel.addComponentWithLabel("Name:", nameField); |
| 68 |
optionPanel.addComponentWithLabel("Data Partition:", partitionCombo); |
| 69 |
optionPanel.addComponentWithLabel("Construction Method:", methodCombo); |
| 70 |
|
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
public int showDialog(BeautiOptions options) { |
| 75 |
|
| 76 |
JOptionPane optionPane = new JOptionPane(optionPanel, |
| 77 |
JOptionPane.QUESTION_MESSAGE, |
| 78 |
JOptionPane.OK_CANCEL_OPTION, |
| 79 |
null, |
| 80 |
null, |
| 81 |
null); |
| 82 |
optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); |
| 83 |
|
| 84 |
partitionCombo.removeAllItems(); |
| 85 |
for (AbstractPartitionData partition : options.dataPartitions) { |
| 86 |
partitionCombo.addItem(partition); |
| 87 |
} |
| 88 |
final JDialog dialog = optionPane.createDialog(frame, "Construct New Tree"); |
| 89 |
dialog.pack(); |
| 90 |
|
| 91 |
dialog.setVisible(true); |
| 92 |
|
| 93 |
int result = JOptionPane.CANCEL_OPTION; |
| 94 |
Integer value = (Integer) optionPane.getValue(); |
| 95 |
if (value != null && value != -1) { |
| 96 |
result = value; |
| 97 |
} |
| 98 |
|
| 99 |
return result; |
| 100 |
} |
| 101 |
|
| 102 |
public String getName() { |
| 103 |
return nameField.getText(); |
| 104 |
} |
| 105 |
|
| 106 |
public PartitionData getDataPartition() { |
| 107 |
return (PartitionData)partitionCombo.getSelectedItem(); |
| 108 |
} |
| 109 |
public MethodTypes getMethodType() { |
| 110 |
return (MethodTypes)methodCombo.getSelectedItem(); |
| 111 |
} |
| 112 |
} |