Merge from the pain train
[official-gcc.git] / libjava / java / awt / GraphicsDevice.java
blobc01723356b3dfa998fe9205aec7f5d2b1ff23a01
1 /* GraphicsDevice.java -- information about a graphics device
2 Copyright (C) 2002, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.awt;
41 /**
42 * This describes a graphics device available to the given environment. This
43 * includes screen and printer devices, and the different configurations for
44 * each device. Also, this allows you to create virtual devices which operate
45 * over a multi-screen environment.
47 * @author Eric Blake (ebb9@email.byu.edu)
48 * @see GraphicsEnvironment
49 * @see GraphicsConfiguration
50 * @since 1.3
51 * @status updated to 1.4
53 public abstract class GraphicsDevice
55 /** Device is a raster screen. */
56 public static final int TYPE_RASTER_SCREEN = 0;
58 /** Device is a printer. */
59 public static final int TYPE_PRINTER = 1;
61 /** Device is an image buffer not visible to the user. */
62 public static final int TYPE_IMAGE_BUFFER = 2;
64 /** The current full-screen window, or null if there is none. */
65 private Window full_screen;
67 /** The current display mode, or null if unknown. */
68 private DisplayMode mode;
70 /**
71 * The default constructor.
73 * @see GraphicsEnvironment#getScreenDevices()
74 * @see GraphicsEnvironment#getDefaultScreenDevice()
75 * @see GraphicsConfiguration#getDevice()
77 protected GraphicsDevice()
81 /**
82 * Returns the type of the device.
84 * @return the device type
85 * @see #TYPE_RASTER_SCREEN
86 * @see #TYPE_PRINTER
87 * @see #TYPE_IMAGE_BUFFER
89 public abstract int getType();
91 /**
92 * Returns an identification string for the device. This can be
93 * vendor-specific, and may be useful for debugging.
95 * @return the identification
97 public abstract String getIDstring();
99 /**
100 * Return all configurations valid for this device.
102 * @return an array of configurations
104 public abstract GraphicsConfiguration[] getConfigurations();
107 * Return the default configuration for this device.
109 * @return the default configuration
111 public abstract GraphicsConfiguration getDefaultConfiguration();
114 * Return the best configuration, according to the criteria in the given
115 * template.
117 * @param template the template to adjust by
118 * @return the best configuration
119 * @throws NullPointerException if template is null
121 public GraphicsConfiguration getBestConfiguration
122 (GraphicsConfigTemplate template)
124 return template.getBestConfiguration(getConfigurations());
128 * Returns true if the device supports full-screen exclusive mode. The
129 * default implementation returns true; subclass it if this is not the case.
131 * @return true if full screen support is available
132 * @since 1.4
134 public boolean isFullScreenSupported()
136 return true;
140 * Toggle the given window between full screen and normal mode. The previous
141 * full-screen window, if different, is restored; if the given window is
142 * null, no window will be full screen. If
143 * <code>isFullScreenSupported()</code> returns true, full screen mode is
144 * considered to be exclusive, which implies:<ul>
145 * <li>Windows cannot overlap the full-screen window. All other application
146 * windows will always appear beneath the full-screen window in the
147 * Z-order.</li>
148 * <li>Input method windows are disabled. It is advisable to call
149 * <code>Component.enableInputMethods(false)</code> to make a component
150 * a non-client of the input method framework.</li>
151 * </ul><br>
152 * If <code>isFullScreenSupported()</code> returns false, full-screen
153 * exclusive mode is simulated by resizing the window to the size of the
154 * screen and positioning it at (0,0).
156 * XXX Not yet implemented in Classpath.
158 * @param w the window to toggle
159 * @see #isFullScreenSupported()
160 * @see getFullScreenWindow()
161 * @see setDisplayMode(DisplayMode)
162 * @see Component#enableInputMethods(boolean)
163 * @since 1.4
165 public synchronized void setFullScreenWindow(Window w)
167 if (full_screen != null)
168 ; // XXX Restore the previous window to normal mode.
169 full_screen = w;
170 // XXX If w != null, make it full-screen.
171 throw new Error("not implemented");
175 * Returns the current full-screen window of the device, or null if no
176 * window is full-screen.
178 * @return the full-screen window
179 * @see #setFullScreenWindow(Window)
180 * @since 1.4
182 public Window getFullScreenWindow()
184 return full_screen;
188 * Returns whether this device supports low-level display changes. This may
189 * depend on whether full-screen exclusive mode is available.
191 * XXX The default implementation returns false for now.
193 * @return true if display changes are supported
194 * @see #setDisplayMode(DisplayMode)
195 * @since 1.4
197 public boolean isDisplayChangeSupported()
199 return false;
203 * Sets the display mode. This may be dependent on the availability of
204 * full-screen exclusive mode.
206 * @param mode the new mode
207 * @throws IllegalArgumentException if the new mode is not in getDisplayModes
208 * @throws UnsupportedOperationException if ! isDisplayChangeSupported()
209 * @see #getDisplayMode()
210 * @see #getDisplayModes()
211 * @see #isDisplayChangeSupported()
212 * @since 1.4
214 public void setDisplayMode(DisplayMode mode)
216 DisplayMode[] array = getDisplayModes();
217 if (! isDisplayChangeSupported())
218 throw new UnsupportedOperationException();
219 int i = array == null ? 0 : array.length;
220 while (--i >= 0)
221 if (array[i].equals(mode))
222 break;
223 if (i < 0)
224 throw new IllegalArgumentException();
225 this.mode = mode;
229 * Returns the current display mode of this device, or null if unknown.
231 * @return the current display mode
232 * @see #setDisplayMode(DisplayMode)
233 * @see #getDisplayModes()
234 * @since 1.4
236 public DisplayMode getDisplayMode()
238 return mode;
242 * Return an array of all available display modes. This implementation
243 * returns a 0-length array, so subclasses must override this.
245 * @return the array of available modes
246 * @since 1.4
248 public DisplayMode[] getDisplayModes()
250 return new DisplayMode[0];
254 * Return the number of bytes available in accelerated memory on this
255 * device. The device may support creation or caching on a first-come,
256 * first-served basis, depending on the operating system and driver.
257 * Memory may be a finite resource, and because of multi-threading, you
258 * are not guaranteed that the result of this method ensures your image
259 * will successfully be put in accelerated memory. A negative result means
260 * the memory is unlimited. The default implementation assumes no special
261 * memory is available, and returns 0.
263 * @return the size of accelerated memory available
264 * @see VolatileImage#flush()
265 * @see ImageCapabilities#isAccelerated()
267 public int getAvailableAcceleratedMemory()
269 return 0;
271 } // class GraphicsDevice