1 | package genius.gui.progress.session;
|
---|
2 |
|
---|
3 | import javax.swing.JPanel;
|
---|
4 | import javax.swing.JScrollPane;
|
---|
5 | import javax.swing.JSplitPane;
|
---|
6 | import javax.swing.JTable;
|
---|
7 | import javax.swing.JTextArea;
|
---|
8 | import javax.swing.text.BadLocationException;
|
---|
9 |
|
---|
10 | import genius.core.analysis.MultilateralAnalysis;
|
---|
11 | import genius.gui.panels.VflowPanelWithBorder;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Shows the progress in a multiparty single session run
|
---|
15 | */
|
---|
16 | @SuppressWarnings("serial")
|
---|
17 | public class SessionProgressUI extends VflowPanelWithBorder {
|
---|
18 |
|
---|
19 | private JSplitPane verticalsplit; // split on y axis
|
---|
20 | private JSplitPane horizontalsplit; // split on x axis
|
---|
21 |
|
---|
22 | /**
|
---|
23 | *
|
---|
24 | * @param model
|
---|
25 | * an {@link OutcomesListModel} of this session.
|
---|
26 | * @param showChart
|
---|
27 | * true iff any chart (normal or bi) has to be shown
|
---|
28 | * @param useBiChart
|
---|
29 | * if true, a {@link SessionProgressUI} will be used that shows
|
---|
30 | * utils of first two participants in util-util graph. Ignored if
|
---|
31 | * showChart is false.
|
---|
32 | * @param textmodel
|
---|
33 | * a {@link ActionDocumentModel}
|
---|
34 | */
|
---|
35 | public SessionProgressUI(OutcomesListModel model, ActionDocumentModel textmodel, boolean showChart,
|
---|
36 | boolean useBiChart, boolean showAllBids) {
|
---|
37 | super("Session Progress");
|
---|
38 |
|
---|
39 | MultilateralAnalysis analysis = new MultilateralAnalysis(model.getParties(), null, null);
|
---|
40 | double opposition = analysis.getOpposition();
|
---|
41 | String message = String.format("Opposition: %.4f \n\n", opposition);
|
---|
42 |
|
---|
43 | try {
|
---|
44 | textmodel.insertString(0, message, null);
|
---|
45 | } catch(BadLocationException e) {
|
---|
46 | System.out.print(String.format("\n\n ---- \n %s \n ---- \n\n ", message));
|
---|
47 | }
|
---|
48 |
|
---|
49 | createSplitPanes();
|
---|
50 | VflowPanelWithBorder textarea = new VflowPanelWithBorder("Negotiation log");
|
---|
51 | textarea.add(new JScrollPane(new JTextArea(textmodel)));
|
---|
52 | horizontalsplit.setLeftComponent(textarea);
|
---|
53 | verticalsplit.setRightComponent(new JScrollPane(new JTable(new OutcomesModelToTableModelAdapter(model))));
|
---|
54 | JPanel chart;
|
---|
55 | if (showChart) {
|
---|
56 | chart = useBiChart ? new ProgressChartBi(model, showAllBids) : new ProgressChart(model);
|
---|
57 | } else {
|
---|
58 | chart = new JPanel();
|
---|
59 | }
|
---|
60 | verticalsplit.setLeftComponent(chart);
|
---|
61 | add(horizontalsplit);
|
---|
62 |
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Creates overall layout of this panel: a panel with a vertical split, with
|
---|
67 | * in the right side a panel with a horizontal split .
|
---|
68 | */
|
---|
69 | private void createSplitPanes() {
|
---|
70 | horizontalsplit = new JSplitPane();
|
---|
71 | horizontalsplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
|
---|
72 |
|
---|
73 | verticalsplit = new JSplitPane();
|
---|
74 | verticalsplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
---|
75 |
|
---|
76 | horizontalsplit.setRightComponent(verticalsplit);
|
---|
77 | }
|
---|
78 |
|
---|
79 | }
|
---|