1 package org.opentrafficsim.gui;
2
3 import java.awt.BorderLayout;
4 import java.util.ArrayList;
5
6 import javax.swing.JLabel;
7 import javax.swing.JPanel;
8 import javax.swing.JScrollPane;
9 import javax.swing.SwingConstants;
10
11 import nl.tudelft.simulation.dsol.gui.swing.Console;
12 import nl.tudelft.simulation.dsol.gui.swing.StatusBar;
13 import nl.tudelft.simulation.dsol.gui.swing.TabbedContentPane;
14
15 import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
16 import org.opentrafficsim.simulationengine.WrappableSimulation;
17 import org.opentrafficsim.simulationengine.properties.AbstractProperty;
18 import org.opentrafficsim.simulationengine.properties.CompoundProperty;
19
20
21
22
23
24
25
26
27
28
29
30 public class OTSSimulationPanel extends JPanel
31 {
32
33 private static final long serialVersionUID = 20150617L;
34
35
36 private final OTSDEVSSimulatorInterface simulator;
37
38
39 private final Console console = new Console();
40
41
42 private final OTSControlPanel otsControlPanel;
43
44
45 private final TabbedContentPane tabbedPane = new TabbedContentPane(SwingConstants.BOTTOM);
46
47
48 private final StatusBar statusBar;
49
50
51
52
53
54
55 public OTSSimulationPanel(final OTSDEVSSimulatorInterface simulator, final WrappableSimulation wrappableSimulation)
56 {
57 this.simulator = simulator;
58
59 this.setLayout(new BorderLayout());
60
61
62 this.otsControlPanel = new OTSControlPanel(simulator, wrappableSimulation);
63 this.add(this.otsControlPanel, BorderLayout.NORTH);
64
65
66 this.tabbedPane.addTab("console", new JScrollPane(this.console));
67
68
69 ArrayList<AbstractProperty<?>> propertyList =
70 new CompoundProperty("", "", wrappableSimulation.getUserModifiedProperties(), true, 0).displayOrderedValue();
71 StringBuilder html = new StringBuilder();
72 html.append("<html><table border=\"1\"><tr><th colspan=\"" + propertyList.size() + "\">Settings</th></tr><tr>");
73
74 for (AbstractProperty<?> ap : propertyList)
75 {
76 html.append("<td valign=\"top\">" + ap.htmlStateDescription() + "</td>");
77 }
78 html.append("</table></html>");
79 JLabel propertySettings = new JLabel(html.toString());
80 this.tabbedPane.addTab("settings", new JScrollPane(propertySettings));
81
82
83 this.add(this.tabbedPane, BorderLayout.CENTER);
84
85
86 this.statusBar = new StatusBar(this.simulator);
87 this.add(this.statusBar, BorderLayout.SOUTH);
88 }
89
90
91
92
93 public final TabbedContentPane getTabbedPane()
94 {
95 return this.tabbedPane;
96 }
97
98
99
100
101 public final OTSDEVSSimulatorInterface getSimulator()
102 {
103 return this.simulator;
104 }
105
106
107
108
109 public final StatusBar getStatusBar()
110 {
111 return this.statusBar;
112 }
113
114 }