@SuppressWarnings({"unchecked"}) public SimulationPanel(final MainFrame frame, final PartitionDataList dataList) { this.frame = frame; this.dataList = dataList; optionPanel = new OptionsPanel(12, 12, SwingConstants.CENTER); simulationsNumberField = new WholeNumberField(1, Integer.MAX_VALUE); simulationsNumberField.setColumns(10); simulationsNumberField.setValue(dataList.simulationsCount); optionPanel.addComponentWithLabel("Number of simulations:", simulationsNumberField); setSeed = new JCheckBox(); setSeed.addItemListener(new SetSeedCheckBoxListener()); setSeed.setSelected(dataList.setSeed); optionPanel.addComponentWithLabel("Set seed:", setSeed); startingSeedNumberField = new WholeNumberField(1, Long.MAX_VALUE); startingSeedNumberField.setColumns(10); startingSeedNumberField.setValue(dataList.startingSeed); startingSeedNumberField.setEnabled(dataList.setSeed); optionPanel.addComponentWithLabel("Starting seed:", startingSeedNumberField); outputFormat = new JComboBox(); optionPanel.addComponentWithLabel("Output format:", outputFormat); outputFormatModel = new DefaultComboBoxModel(SimpleAlignment.OutputType.values()); outputFormat.setModel(outputFormatModel); outputAncestralSequences = new JCheckBox(); outputAncestralSequences.addItemListener(new outputAncestralSequencesCheckBoxListener()); outputAncestralSequences.setSelected(dataList.useParallel); optionPanel.addComponentWithLabel("Output ancestral sequences:", outputAncestralSequences); useParallel = new JCheckBox(); useParallel.addItemListener(new UseParallelCheckBoxListener()); useParallel.setSelected(dataList.useParallel); optionPanel.addComponentWithLabel("Use parallel implementation:", useParallel); // Buttons holder JPanel buttonsHolder = new JPanel(); buttonsHolder.setOpaque(false); // simulate button simulate = new JButton("Simulate", Utils.createImageIcon(Utils.BIOHAZARD_ICON)); simulate.addActionListener(new ListenSimulate()); buttonsHolder.add(simulate); generateXML = new JButton("Generate XML", Utils.createImageIcon(Utils.HAMMER_ICON)); generateXML.addActionListener(new ListenGenerateXML()); buttonsHolder.add(generateXML); setOpaque(false); setLayout(new BorderLayout()); add(optionPanel, BorderLayout.NORTH); add(buttonsHolder, BorderLayout.SOUTH); } // END: SimulationPanel
public final void collectSettings() { dataList.simulationsCount = simulationsNumberField.getValue(); if (dataList.setSeed) { dataList.startingSeed = startingSeedNumberField.getValue(); } dataList.outputFormat = SimpleAlignment.OutputType.parseFromString(outputFormat.getSelectedItem().toString()); } // END: collectSettings