1
2
3
4
5
6
7 package nl.tudelft.simulation.language.swing;
8
9 import java.awt.DisplayMode;
10 import java.awt.GraphicsEnvironment;
11 import java.awt.Window;
12
13 import javax.swing.JFrame;
14
15 /***
16 * The ScreenManager class manages initializing and displaying full screen
17 * graphics mode.
18 * <p>
19 * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
20 * University of Technology </a>, the Netherlands.
21 * <p>
22 * See for project information <a
23 * href="http://www.simulation.tudelft.nl/dsol/language">www.simulation.tudelft.nl/language
24 * </a> <br>
25 * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
26 * General Public License (LGPL) </a>, no warranty
27 *
28 * @version $Revision: 1.7 $ $Date: 2005/07/04 12:21:26 $
29 * @author <a href="mailto:stijnh@tbm.tudelft.nl">
30 * Stijn-Pieter van Houten </a>
31 */
32 public class ScreenManager
33 {
34 /*** the environment */
35 private GraphicsEnvironment environment;
36
37 /***
38 * Constructs a new ScreenManager.
39 */
40 public ScreenManager()
41 {
42 super();
43 this.environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
44 }
45
46 /***
47 * Method setFullScreen. Enters full screen mode and changes the display
48 * mode.
49 *
50 * @param window The window to show full screen.
51 */
52 public void setFullScreen(final JFrame window)
53 {
54 window.setUndecorated(true);
55 window.setResizable(false);
56 this.environment.getDefaultScreenDevice().setFullScreenWindow(window);
57 if (this.environment.getDefaultScreenDevice()
58 .isDisplayChangeSupported())
59 {
60 DisplayMode mode = new DisplayMode((int) this.environment
61 .getMaximumWindowBounds().getWidth(),
62 (int) this.environment.getMaximumWindowBounds().getWidth(),
63 24, DisplayMode.REFRESH_RATE_UNKNOWN);
64 this.environment.getDefaultScreenDevice().setDisplayMode(mode);
65
66 }
67 }
68
69 /***
70 * Method getFullScreenWindow.
71 *
72 * @return Returns the window currently used in full screen mode.
73 */
74 public Window getFullScreenWindow()
75 {
76 return this.environment.getDefaultScreenDevice().getFullScreenWindow();
77 }
78
79 /***
80 * Method restoreScreen. Restores the screen's display mode.
81 */
82 public void restoreScreen()
83 {
84 Window window = this.environment.getDefaultScreenDevice()
85 .getFullScreenWindow();
86 if (window != null)
87 {
88 window.dispose();
89 }
90 this.environment.getDefaultScreenDevice().setFullScreenWindow(null);
91 }
92 }