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