1 package org.opentrafficsim.swing.gui;
2
3 import java.awt.BorderLayout;
4 import java.awt.Insets;
5 import java.rmi.RemoteException;
6
7 import javax.swing.JPanel;
8 import javax.swing.JScrollPane;
9 import javax.swing.SwingConstants;
10 import javax.swing.UIManager;
11
12 import org.opentrafficsim.core.dsol.OtsModelInterface;
13 import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
14
15 import nl.tudelft.simulation.dsol.model.inputparameters.InputParameterException;
16 import nl.tudelft.simulation.dsol.swing.gui.ConsoleOutput;
17 import nl.tudelft.simulation.dsol.swing.gui.TabbedContentPane;
18
19
20
21
22
23
24
25
26
27
28 public class OtsSimulationPanel extends JPanel
29 {
30
31 private static final long serialVersionUID = 20150617L;
32
33
34 private final OtsSimulatorInterface simulator;
35
36
37 private final ConsoleOutput console = new ConsoleOutput();
38
39
40 private final OtsControlPanel otsControlPanel;
41
42
43 private final OtsModelInterface otsModel;
44
45 static
46 {
47
48 UIManager.put("TabbedPane.contentBorderInsets", new Insets(1, 1, 1, 1));
49 }
50
51
52 private final TabbedContentPane tabbedPane = new AppearanceControlTabbedContentPane(SwingConstants.BOTTOM);
53
54
55
56
57
58
59
60 public OtsSimulationPanel(final OtsSimulatorInterface simulator, final OtsModelInterface otsModel) throws RemoteException
61 {
62 this.simulator = simulator;
63 this.otsModel = otsModel;
64
65 this.setLayout(new BorderLayout());
66
67
68 this.otsControlPanel = new OtsControlPanel(simulator, otsModel, (OtsAnimationPanel) this);
69 this.add(this.otsControlPanel, BorderLayout.NORTH);
70
71
72 this.add(this.tabbedPane, BorderLayout.CENTER);
73
74
75
76
77 }
78
79
80
81
82 public final void addConsoleTab()
83 {
84
85 JScrollPane cons = new JScrollPane(this.console);
86 cons.setBorder(null);
87 this.tabbedPane.addTab("console", cons);
88 }
89
90
91
92
93
94 public final void addPropertiesTab() throws InputParameterException
95 {
96
97 }
98
99
100
101
102 public final TabbedContentPane getTabbedPane()
103 {
104 return this.tabbedPane;
105 }
106
107
108
109
110 public final OtsSimulatorInterface getSimulator()
111 {
112 return this.simulator;
113 }
114
115
116
117
118
119 public final OtsControlPanel getOtsControlPanel()
120 {
121 return this.otsControlPanel;
122 }
123
124
125
126
127 public final ConsoleOutput getConsole()
128 {
129 return this.console;
130 }
131
132
133
134
135 public final OtsModelInterface getOtsModel()
136 {
137 return this.otsModel;
138 }
139
140
141
142
143
144
145 public void enableSimulationControlButtons()
146 {
147 getOtsControlPanel().setSimulationControlButtons(true);
148 }
149
150
151
152
153 public void disableSimulationControlButtons()
154 {
155 getOtsControlPanel().setSimulationControlButtons(false);
156 }
157
158
159 @Override
160 public final String toString()
161 {
162 return "OtsSimulationPanel [simulatorTime=" + this.simulator.getSimulatorTime() + "]";
163 }
164
165
166
167
168
169
170
171
172
173
174
175
176 static class AppearanceControlTabbedContentPane extends TabbedContentPane implements AppearanceControl
177 {
178
179 private static final long serialVersionUID = 20180206L;
180
181
182
183
184 AppearanceControlTabbedContentPane(final int tabPlacement)
185 {
186 super(tabPlacement);
187 }
188
189
190 @Override
191 public String toString()
192 {
193 return "AppearanceControlTabbedContentPane []";
194 }
195
196 }
197
198 }