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

Last change on this file since 209 was 30, checked in by dimitrios, 6 years ago

Additions to uncertainty framework to support tournament configuration and command line running

File size: 1.7 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 if (key == DataKey.AGENTS || key == DataKey.FILES || key == DataKey.UTILS
39 || key == DataKey.DISCOUNTED_UTILS || key == DataKey.PERCEIVED_UTILS) {
40 colspec.put(key, numAgents);
41 } else {
42 colspec.put(key, 1);
43 }
44 }
45
46 return colspec;
47 }
48
49 @Override
50 public void notifyChange(NegotiationEvent e) {
51 if (e instanceof SessionEndedNormallyEvent) {
52 SessionEndedNormallyEvent e1 = (SessionEndedNormallyEvent) e;
53 addRow(e1.getValues());
54 } else if (e instanceof SessionFailedEvent) {
55 SessionFailedEvent e1 = (SessionFailedEvent) e;
56 addRow(e1.getValues());
57
58 }
59 }
60}
Note: See TracBrowser for help on using the repository browser.