1 package org.opentrafficsim.swing.gui;
2
3 import java.awt.Frame;
4
5 import javax.swing.WindowConstants;
6
7 import org.opentrafficsim.core.dsol.OtsModelInterface;
8
9 /**
10 * Window to animate an OTS simulation. The window will be maximized.
11 * <p>
12 * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14 * </p>
15 * @author Alexander Verbraeck
16 * @author Peter Knoppers
17 * @author Wouter Schakel
18 * @param <T> model type
19 */
20 public class OtsSimulationApplication<T extends OtsModelInterface> extends AppearanceApplication
21 {
22
23 /** Serialization version UID. */
24 private static final long serialVersionUID = 20141216L;
25
26 /**
27 * Wrap an {@link OtsModelInterface} in an {@link AppearanceApplication}.
28 * @param model the model that will be shown in the window
29 * @param panel simulation panel
30 */
31 public OtsSimulationApplication(final T model, final OtsSimulationPanel panel)
32 {
33 super(panel);
34 setTitle("OTS | The Open Traffic Simulator | " + model.getDescription());
35 pack();
36 setExtendedState(Frame.MAXIMIZED_BOTH);
37 setVisible(true);
38 setExitOnClose(true);
39 setAppearance(getAppearance()); // update appearance of added objects
40 }
41
42 /**
43 * Set exit on close.
44 * @param exitOnClose whether to exit the JVM when the window is closed
45 */
46 public void setExitOnClose(final boolean exitOnClose)
47 {
48 if (exitOnClose)
49 {
50 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
51 }
52 else
53 {
54 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
55 }
56 }
57
58 }