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;
53
54
55
56
57
58
59
60 public OtsSimulationPanel(final OtsSimulatorInterface simulator, final OtsModelInterface otsModel) throws RemoteException
61 {
62 AppearanceApplication.setDefaultFont();
63
64 this.simulator = simulator;
65 this.otsModel = otsModel;
66
67 this.setLayout(new BorderLayout());
68
69
70 this.otsControlPanel = new OtsControlPanel(simulator, otsModel, (OtsAnimationPanel) this);
71 this.add(this.otsControlPanel, BorderLayout.NORTH);
72
73
74 this.tabbedPane = new AppearanceControlTabbedContentPane(SwingConstants.BOTTOM);
75 this.add(this.tabbedPane, BorderLayout.CENTER);
76
77
78
79
80 }
81
82
83
84
85 public final void addConsoleTab()
86 {
87
88 JScrollPane cons = new JScrollPane(this.console);
89 cons.setBorder(null);
90 this.tabbedPane.addTab("console", cons);
91 }
92
93
94
95
96
97 public final void addPropertiesTab() throws InputParameterException
98 {
99
100 }
101
102
103
104
105 public final TabbedContentPane getTabbedPane()
106 {
107 return this.tabbedPane;
108 }
109
110
111
112
113 public final OtsSimulatorInterface getSimulator()
114 {
115 return this.simulator;
116 }
117
118
119
120
121
122 public final OtsControlPanel getOtsControlPanel()
123 {
124 return this.otsControlPanel;
125 }
126
127
128
129
130 public final ConsoleOutput getConsole()
131 {
132 return this.console;
133 }
134
135
136
137
138 public final OtsModelInterface getOtsModel()
139 {
140 return this.otsModel;
141 }
142
143
144
145
146
147
148 public void enableSimulationControlButtons()
149 {
150 getOtsControlPanel().setSimulationControlButtons(true);
151 }
152
153
154
155
156 public void disableSimulationControlButtons()
157 {
158 getOtsControlPanel().setSimulationControlButtons(false);
159 }
160
161
162 @Override
163 public final String toString()
164 {
165 return "OtsSimulationPanel [simulatorTime=" + this.simulator.getSimulatorTime() + "]";
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179 static class AppearanceControlTabbedContentPane extends TabbedContentPane implements AppearanceControl
180 {
181
182 private static final long serialVersionUID = 20180206L;
183
184
185
186
187 AppearanceControlTabbedContentPane(final int tabPlacement)
188 {
189 super(tabPlacement);
190 }
191
192
193 @Override
194 public String toString()
195 {
196 return "AppearanceControlTabbedContentPane []";
197 }
198
199 }
200
201 }