Dialog presenting options for exporting one or more trees from FigTree @author Andrew Rambaut @version $Id$ $HeadURL$ $LastChangedBy$ $LastChangedDate$ $LastChangedRevision$
| 40 | * $LastChangedRevision$ |
| 41 | */ |
| 42 | public class ExportTreeDialog { |
| 43 | |
| 44 | public enum Format { |
| 45 | NEXUS("NEXUS"), |
| 46 | NEWICK("Newick"), |
| 47 | JSON("JSON"); |
| 48 | |
| 49 | Format(String name) { |
| 50 | this.name = name; |
| 51 | } |
| 52 | |
| 53 | public String toString() { |
| 54 | return name; |
| 55 | } |
| 56 | |
| 57 | private String name; |
| 58 | } |
| 59 | |
| 60 | private final JDialog dialog; |
| 61 | private final JOptionPane optionPane; |
| 62 | |
| 63 | private JComboBox formatCombo = null; |
| 64 | private JCheckBox asDisplayedCheck = new JCheckBox("Save as currently displayed"); |
| 65 | private JCheckBox allTreesCheck = new JCheckBox("Save all trees"); |
| 66 | private JCheckBox includeFigTreeCheck = new JCheckBox("Include FigTree block (NEXUS only)"); |
| 67 | private JCheckBox includeAnnotationsCheck = new JCheckBox("Include Annotations (NEXUS & JSON only)"); |
| 68 | |
| 69 | public ExportTreeDialog(JFrame frame) { |
| 70 | |
| 71 | OptionsPanel options = new OptionsPanel(12, 12); |
| 72 | |
| 73 | formatCombo = new JComboBox(Format.values()); |
| 74 | options.addComponentWithLabel("Tree file format: ", formatCombo); |
| 75 | |
| 76 | options.addComponent(asDisplayedCheck); |
| 77 | options.addComponent(allTreesCheck); |
| 78 | options.addComponent(includeFigTreeCheck); |
| 79 | options.addComponent(includeAnnotationsCheck); |
| 80 | |
| 81 | optionPane = new JOptionPane(options, |
| 82 | JOptionPane.QUESTION_MESSAGE, |
| 83 | JOptionPane.OK_CANCEL_OPTION, |
| 84 | null, |
| 85 | null, |
| 86 | null); |
| 87 | optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); |
| 88 | |
| 89 | dialog = optionPane.createDialog(frame, "Export Trees"); |
| 90 | dialog.pack(); |
| 91 | |
| 92 | formatCombo.addItemListener(new ItemListener() { |
| 93 | public void itemStateChanged(ItemEvent e) { |
| 94 | Object item = formatCombo.getSelectedItem(); |
| 95 | |
| 96 | includeFigTreeCheck.setEnabled(item.equals(Format.NEXUS)); |
| 97 | includeAnnotationsCheck.setEnabled(item.equals(Format.NEXUS) || item.equals(Format.JSON)); |
| 98 | } |
| 99 | }); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…