source: src/main/java/genius/gui/uncertainty/PerceivedUtilityPanel.java@ 1

Last change on this file since 1 was 1, checked in by Wouter Pasman, 7 years ago

Initial import : Genius 9.0.0

File size: 3.0 KB
Line 
1package genius.gui.uncertainty;
2
3import java.awt.BorderLayout;
4import java.awt.Color;
5//import java.awt.Dimension;
6import java.awt.event.ActionEvent;
7import java.awt.event.ActionListener;
8
9import javax.swing.BorderFactory;
10import javax.swing.BoxLayout;
11import javax.swing.ButtonGroup;
12import javax.swing.JPanel;
13
14import genius.gui.panels.ButtonPanel;
15import genius.gui.panels.RadioButtonPanel;
16
17
18
19/**
20 * GUI container implementation for Perceived Utility
21 *
22 * @author Dimitrios Tsimpoukis, June 2018
23 *
24 */
25public class PerceivedUtilityPanel extends JPanel{
26
27 private static final long serialVersionUID = -6778243039290185922L;
28
29 private final PerceivedUtilityModel model;
30 private final JPanel strategySelectionPanel = new JPanel();
31 private JPanel actionPanel = new JPanel();;
32 private final ButtonGroup strategyButtonGroup = new ButtonGroup();
33 private final RadioButtonPanel perturbationButton;
34 private final RadioButtonPanel flatteningButton;
35
36 private final ButtonPanel okButton;
37
38 public PerceivedUtilityPanel (PerceivedUtilityModel model) {
39 this.model = model;
40
41 strategySelectionPanel.setLayout(new BoxLayout(strategySelectionPanel, BoxLayout.Y_AXIS));
42
43 perturbationButton = new RadioButtonPanel("Perturbation", model.getPerturbationActivationModel());
44 strategyButtonGroup.add(perturbationButton.getButton());
45 strategySelectionPanel.add(perturbationButton);
46
47 flatteningButton = new RadioButtonPanel("Flatten", model.getFlatteningActivationModel());
48 strategyButtonGroup.add(flatteningButton.getButton());
49 strategySelectionPanel.add(flatteningButton);
50
51 actionPanel.setBorder(BorderFactory.createLineBorder(Color.black));
52
53 this.add(strategySelectionPanel, BorderLayout.WEST);
54 this.add(actionPanel, BorderLayout.CENTER);
55// actionPanel.setPreferredSize(new Dimension(600, 600));
56 strategySelectionPanel.setAlignmentX(CENTER_ALIGNMENT);
57
58 okButton = new ButtonPanel("OK", model.getConfirmationModel());
59 this.add(okButton, BorderLayout.SOUTH);
60 connect();
61 }
62
63 public void connect() {
64 perturbationButton.getButton().addActionListener(new ActionListener() {
65
66 @Override
67 public void actionPerformed(ActionEvent e) {
68 if (perturbationButton.getButton().isSelected()) {
69 flatteningButton.getButton().setSelected(false);
70 actionPanel.removeAll();
71 PerturbationPanel perturbationPanel = new PerturbationPanel(model.getPerturbationModel());
72 actionPanel.add(perturbationPanel, BorderLayout.CENTER);
73 actionPanel.revalidate();
74 actionPanel.repaint();
75 }
76 }
77 });
78
79 flatteningButton.getButton().addActionListener(new ActionListener() {
80
81 @Override
82 public void actionPerformed(ActionEvent e) {
83 if (flatteningButton.getButton().isSelected()) {
84 perturbationButton.getButton().setSelected(false);
85 actionPanel.removeAll();
86 FlatteningPanel flatteningPanel = new FlatteningPanel(model.getFlatteningModel());
87 actionPanel.add(flatteningPanel, BorderLayout.CENTER);
88 actionPanel.revalidate();
89 actionPanel.repaint();
90 }
91 }
92 });
93 }
94}
Note: See TracBrowser for help on using the repository browser.