List of usage examples for javax.swing JRadioButton setActionCommand
public void setActionCommand(String actionCommand)
From source file:savant.view.variation.swing.VariationModule.java
public VariationModule(VariationController vc) { super(new GridBagLayout()); controller = vc;/* w w w .j ava 2s. c o m*/ // Toolbar shared by all panels. JToolBar tools = new JToolBar(); tools.setFloatable(false); rangeField = new JTextField(); rangeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String text = rangeField.getText(); try { Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange()); controller.setLocation(bm.getReference(), (Range) bm.getRange()); } catch (ParseException x) { DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text)); } } }); tools.add(rangeField); tools.addSeparator(); JButton zoomInButton = new JButton(); zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.setBorderPainted(false); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomIn(); } }); tools.add(zoomInButton); JButton zoomOutButton = new JButton(); zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOutButton.setBorderPainted(false); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomOut(); } }); tools.add(zoomOutButton); tools.addSeparator(); JButton controlsButton = new JButton("Controls"); controlsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (controller.getTracks().length > 0) { new CaseControlDialog(controller).setVisible(true); frequencyPlot.repaint(); } else { Toolkit.getDefaultToolkit().beep(); } } }); tools.add(controlsButton); tabs = new JTabbedPane(); table = new RecordTable(new VariantTableModel(null)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { controller.navigateToRecord(controller.getData().get(table.getSelectedRow())); } } }); tabs.addTab("Table", new JScrollPane(table)); map = new VariantMap(controller); map.addMouseWheelListener(wheelListener); LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { map.repaint(); } }); JPanel mapPanel = populatePanel(map); tabs.addTab("Map", mapPanel); frequencyPlot = new AlleleFrequencyPlot(controller); frequencyPlot.addMouseWheelListener(wheelListener); JPanel frequencyPanel = populatePanel(frequencyPlot); tabs.addTab("Allele Frequency", frequencyPanel); JPanel ldPanel = new JPanel(); ldPanel.setLayout(new GridBagLayout()); ActionListener redrawForcer = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ldPlot.repaint(); } }; JRadioButton dPrimeButton = new JRadioButton("D\u2032", true); dPrimeButton.setActionCommand("true"); dPrimeButton.addActionListener(redrawForcer); JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false); rSquaredButton.setActionCommand("false"); rSquaredButton.addActionListener(redrawForcer); methodGroup = new ButtonGroup(); JPanel methodPanel = new JPanel(); methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method")); methodPanel.add(dPrimeButton); methodGroup.add(dPrimeButton); methodPanel.add(rSquaredButton); methodGroup.add(rSquaredButton); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 0.0; ldPanel.add(methodPanel, gbc); ldPlot = new LDPlot(controller); JPanel lowerLDPanel = populatePanel(ldPlot); gbc.weighty = 1.0; ldPanel.add(lowerLDPanel, gbc); tabs.addTab("LD Plot", ldPanel); gbc.weighty = 0.0; add(tools, gbc); // Create the informative cards, but don't use them. messageLabel = new JLabel(); messageLabel.setFont(MESSAGE_FONT); messagePanel = populatePanel(messageLabel); progressPanel = new ProgressPanel(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { controller.cancelDataRequests(); } }); showCard(tabs, null); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.DataGenerationPanel.java
/** * Inits the components./*from w w w . ja v a 2s . co m*/ */ public synchronized void initComponents() { while (activeFrame == null) { if (applicationService != null && applicationService.getFrameView() != null) { activeFrame = applicationService.getFrameView().getActiveFrame(); } } JPanel runPanel = new JPanel(); runPanel.setLayout(new BoxLayout(runPanel, BoxLayout.LINE_AXIS)); runPanel.setBorder(BorderFactory.createEmptyBorder(paddingSize, paddingSize, paddingSize, paddingSize)); JXLabel label = new JXLabel(); label.setLineWrap(true); label.setText( "<html>This panel allows the creation of clinically plausible data based on a query specification. " + "Please note that you <b>must</b> always specify a data generation source. " + "The rest of the parameters can be left in their default state. When you've configured the parameters " + "click the 'Generate data' button.</html>"); runPanel.add(label); runPanel.add(new JSeparator(SwingConstants.VERTICAL)); runPanel.add(Box.createHorizontalStrut(paddingSize)); JideButton runButton = new JideButton(new GenerateDataAction(applicationService, queryService, dataGenerationEngine, propertyChangeTrackerService)); runButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE); runPanel.add(runButton); runButton.setIcon(new ImageIcon(DataGenerationPanel.class.getResource("resources/linuxconf.png"))); runPanel.add(Box.createHorizontalStrut(paddingSize)); // create radio buttons for choosing source JRadioButton queryButton = new JRadioButton("Active Query"); queryButton.setSelected(true); queryButton.addActionListener(this); queryButton.setActionCommand("activeQuery"); JRadioButton fileButton = new JRadioButton("File"); fileButton.addActionListener(this); fileButton.setActionCommand("file"); JRadioButton folderButton = new JRadioButton("Folder"); folderButton.addActionListener(this); folderButton.setActionCommand("folder"); ButtonGroup bg = new ButtonGroup(); bg.add(queryButton); bg.add(fileButton); bg.add(folderButton); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); // buttonsPanel.add(new JLabel("Select data generation source")); buttonsPanel.setBorder(BorderFactory.createTitledBorder("Select data generation source")); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(queryButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(fileButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(folderButton); locationField = new JTextField(100); JButton loadQueryButton = new JButton("Browse"); loadQueryButton.addActionListener(this); loadQueryButton.setActionCommand("load"); locationPanel = new JPanel(); locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS)); locationPanel.add(new JLabel("Load file from")); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(locationField); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(loadQueryButton); JPanel lhsPanel = new JPanel(new GridLayout(0, 2)); JPanel rhsPanel = new JPanel(new GridLayout(0, 2)); lhsPanel.add(new JLabel("Max number of patients to generate")); SpinnerNumberModel model = new SpinnerNumberModel(initialPatientsNumber, 1, 1000000, 1); ptNumberSpinner = new JSpinner(model); ptNumberSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { // get value currently selected in spinner and set in engine dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // Object value = ptNumberSpinner.getValue(); // if(value instanceof Double) // { // Double d = (Double) ptNumberSpinner.getValue(); // dataGenerationEngine.setMaxPatientNumber(d.longValue()); // } // else // { // dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // } logger.debug("ptNumberSpinner.getValue().getClass() = " + ptNumberSpinner.getValue().getClass()); logger.debug("Max pt number in engine set to : " + dataGenerationEngine.getMaxPatientNumber()); } }); lhsPanel.add(ptNumberSpinner); lhsPanel.add(new JLabel("Min age of patients to generate")); SpinnerNumberModel ageModel = new SpinnerNumberModel(initialMinimumAge, 1, 120, 1); minAgeSpinner = new JSpinner(ageModel); minAgeSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // set min pt age to current value dataGenerationEngine.setMinPatientAgeInYears(Integer.parseInt(minAgeSpinner.getValue().toString())); logger.debug("Value of engine.getMinPatientAgeInYears() : " + dataGenerationEngine.getMinPatientAgeInYears()); } }); lhsPanel.add(minAgeSpinner); lhsPanel.add(new JLabel("Data generation strategy")); generationStrategyBox = new JComboBox(DataGenerationEngine.DataGenerationStrategy.values()); generationStrategyBox.setSelectedItem(DataGenerationEngine.DataGenerationStrategy.ADD_IF_NOT_EXISTS); generationStrategyBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setDataGenerationStrategy( (DataGenerationEngine.DataGenerationStrategy) generationStrategyBox.getSelectedItem()); } }); lhsPanel.add(generationStrategyBox); includeExcludedTermsBox = new JCheckBox(new AbstractAction("Include Excluded terms in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setIncludeExcludedTerms(includeExcludedTermsBox.isSelected()); logger.debug("dataGenerationEngine.isIncludeExcludedTerms() = " + dataGenerationEngine.isIncludeExcludedTerms()); } }); rhsPanel.add(includeExcludedTermsBox); randomiseNumericalValuesBox = new JCheckBox(new AbstractAction("Randomise Numerical values in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setRandomiseNumericalValues(randomiseNumericalValuesBox.isSelected()); logger.debug("dataGenerationEngine.isRandomiseNumericalValues() = " + dataGenerationEngine.isRandomiseNumericalValues()); } }); rhsPanel.add(randomiseNumericalValuesBox); refineQualifiersCheckBox = new JCheckBox(new AbstractAction("Refine Qualifiers in expression") { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setRefineQualifiers(refineQualifiersCheckBox.isSelected()); logger.debug( "dataGenerationEngine.isRefineQualifiers() = " + dataGenerationEngine.isRefineQualifiers()); } }); rhsPanel.add(refineQualifiersCheckBox); includePreCoordinatedDataCheckBox = new JCheckBox( new AbstractAction("Include pre-coordinated expressions") { public void actionPerformed(ActionEvent e) { dataGenerationEngine .setIncludePrecoordinatedData(includePreCoordinatedDataCheckBox.isSelected()); logger.debug("dataGenerationEngine.isIncludePrecoordinatedData() = " + dataGenerationEngine.isIncludePrecoordinatedData()); } }); rhsPanel.add(includePreCoordinatedDataCheckBox); rhsPanel.add(new JLabel(" ")); /* * create panel for parametrising engine */ JPanel parametrisationPanel = new JPanel(); parametrisationPanel.setLayout(new GridLayout(0, 2)); parametrisationPanel.setBorder(BorderFactory.createTitledBorder("Engine Parameters")); // add panels to parametrisation panel parametrisationPanel.add(lhsPanel); parametrisationPanel.add(rhsPanel); JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.add(runPanel); topPanel.add(new JSeparator(SwingConstants.VERTICAL)); topPanel.add(buttonsPanel); // add all panels to this component setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); add(parametrisationPanel, BorderLayout.CENTER); // initialise values populateFields(dataGenerationEngine); }