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