source: src/main/java/genius/gui/negosession/MultiPartyDataModel.java@ 345

Last change on this file since 345 was 232, checked in by Adel Magra, 5 years ago

Created a User class that implements an elicit functionality.

Created a Top_3 Agent with the BOA framework to showcase this functionality.

File size: 1.6 KB
Line 
1package genius.gui.negosession;
2
3import java.util.LinkedHashMap;
4
5import genius.core.events.NegotiationEvent;
6import genius.core.events.SessionEndedNormallyEvent;
7import genius.core.events.SessionFailedEvent;
8import genius.core.listener.Listener;
9import genius.gui.progress.DataKey;
10import genius.gui.progress.DataKeyTableModel;
11
12/**
13 * Tracks the Multiparty tournament and keeps a {@link DataKeyTableModel} up to
14 * date. This determines the layout of log file and tables. This can be listened
15 * to and shown in a table.
16 *
17 * @author W.Pasman
18 *
19 */
20@SuppressWarnings("serial")
21public class MultiPartyDataModel extends DataKeyTableModel implements Listener<NegotiationEvent> {
22
23 public MultiPartyDataModel(int numAgents) {
24 super(makeDataModel(numAgents));
25 }
26
27 /**
28 * create the dataModel. This determines what is logged, the exact order of
29 * the columns, etc. Currently it makes a table with ALL known
30 * {@link DataKey}s.
31 *
32 * @return datamodel that layouts data.
33 */
34 private static LinkedHashMap<DataKey, Integer> makeDataModel(int numAgents) {
35
36 LinkedHashMap<DataKey, Integer> colspec = new LinkedHashMap<DataKey, Integer>();
37 for (DataKey key : DataKey.values())
38 {
39 if (key.getMultiple())
40 colspec.put(key, numAgents);
41 else
42 colspec.put(key, 1);
43 }
44 return colspec;
45 }
46
47 @Override
48 public void notifyChange(NegotiationEvent e) {
49 if (e instanceof SessionEndedNormallyEvent) {
50 SessionEndedNormallyEvent e1 = (SessionEndedNormallyEvent) e;
51 addRow(e1.getValues());
52 } else if (e instanceof SessionFailedEvent) {
53 SessionFailedEvent e1 = (SessionFailedEvent) e;
54 addRow(e1.getValues());
55
56 }
57 }
58}
Note: See TracBrowser for help on using the repository browser.