source: src/main/java/genius/gui/boaparties/BoaPartyPanel.java

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

Initial import : Genius 9.0.0

File size: 2.8 KB
Line 
1package genius.gui.boaparties;
2
3import java.awt.BorderLayout;
4import java.awt.GridLayout;
5
6import javax.swing.JOptionPane;
7import javax.swing.JPanel;
8
9import genius.core.boaframework.AcceptanceStrategy;
10import genius.core.boaframework.BOA;
11import genius.core.boaframework.OMStrategy;
12import genius.core.boaframework.OfferingStrategy;
13import genius.core.boaframework.OpponentModel;
14import genius.core.exceptions.InstantiateException;
15import genius.core.repository.boa.BoaPartyRepItem;
16import genius.core.repository.boa.BoaRepItem;
17import genius.core.repository.boa.BoaWithSettingsRepItem;
18import genius.core.repository.boa.ParameterList;
19import genius.gui.panels.LabelAndComponent;
20import genius.gui.panels.TextPanel;
21
22/**
23 * panel that allows user to set properties that will later be used to generate
24 * {@link BoaPartyRepItem}s.
25 */
26@SuppressWarnings("serial")
27public class BoaPartyPanel extends JPanel {
28
29 /**
30 * show panel that edits the given BoaPartyModel
31 *
32 * @param model
33 * the {@link BoaPartyModel} to edit.
34 */
35 public BoaPartyPanel(BoaPartyModel model) {
36 setLayout(new BorderLayout());
37
38 add(new LabelAndComponent("Name", new TextPanel(model.getNameModel())), BorderLayout.NORTH);
39
40 JPanel strategies = new JPanel(new GridLayout(2, 2, 40, 50));
41 strategies.add(new BoaComponentPanel<>(model.getOfferingModel(), "Bidding Strategy"));
42 strategies.add(new BoaComponentPanel<>(model.getAcceptanceModel(), "Acceptance Strategy"));
43 strategies.add(new BoaComponentPanel<>(model.getOpponentModel(), "Opponent Model"));
44 strategies.add(new BoaComponentPanel<>(model.getOmStrategiesModel(), "Opponent Model Strategy"));
45 add(strategies, BorderLayout.CENTER);
46
47 }
48
49 /**
50 * Test function.
51 *
52 * @param args
53 * @throws InstantiateException
54 */
55 public static void main(String[] args) throws InstantiateException {
56
57 // make specific settings, to check the proper value is selected
58 BoaWithSettingsRepItem<OfferingStrategy> boa1 = makeSettings("resources.boa.Offering2");
59 BoaWithSettingsRepItem<AcceptanceStrategy> boa2 = makeSettings("resources.boa.Acceptance2");
60 BoaWithSettingsRepItem<OpponentModel> boa3 = makeSettings("resources.boa.OpponentModel1");
61 BoaWithSettingsRepItem<OMStrategy> boa4 = makeSettings("resources.boa.OMStrategy1");
62 BoaPartyRepItem partyitem = new BoaPartyRepItem("test party", boa1, boa2, boa3, boa4);
63 BoaPartyModel model = new BoaPartyModel(partyitem);
64
65 int result = JOptionPane.showConfirmDialog(null, new BoaPartyPanel(model), "test model",
66 JOptionPane.OK_CANCEL_OPTION);
67 System.out.println("result=" + result + ":" + model);
68 }
69
70 // for testing
71 private static <T extends BOA> BoaWithSettingsRepItem<T> makeSettings(String classname) {
72 BoaRepItem<T> item = new BoaRepItem<T>(classname);
73 ParameterList parameters = new ParameterList();
74 return new BoaWithSettingsRepItem<T>(item, parameters);
75 }
76
77}
Note: See TracBrowser for help on using the repository browser.