001: /*
002: * @(#)GraphicsDevice.java 1.13 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package java.awt;
029:
030: /**
031: * The <code>GraphicsDevice</code> class describes the graphics devices
032: * that might be available in a particular graphics environment. These
033: * include screen and printer devices. Note that there can be many screens
034: * and many printers in an instance of {@link GraphicsEnvironment}. Each
035: * graphics device has one or more {@link GraphicsConfiguration} objects
036: * associated with it. These objects specify the different configurations
037: * in which the <code>GraphicsDevice</code> can be used.
038: * <p>
039: * In a multi-screen environment, the <code>GraphicsConfiguration</code>
040: * objects can be used to render components on multiple screens. The
041: * following code sample demonstrates how to create a <code>JFrame</code>
042: * object for each <code>GraphicsConfiguration</code> on each screen
043: * device in the <code>GraphicsEnvironment</code>:
044: * <pre>
045: * GraphicsEnvironment ge = GraphicsEnvironment.
046: * getLocalGraphicsEnvironment();
047: * GraphicsDevice[] gs = ge.getScreenDevices();
048: * for (int j = 0; j < gs.length; j++) {
049: * GraphicsDevice gd = gs[j];
050: * GraphicsConfiguration[] gc =
051: * gd.getConfigurations();
052: * for (int i=0; i < gc.length; i++) {
053: * JFrame f = new
054: * JFrame(gs[j].getDefaultConfiguration());
055: * Canvas c = new Canvas(gc[i]);
056: * Rectangle gcBounds = gc[i].getBounds();
057: * int xoffs = gcBounds.x;
058: * int yoffs = gcBounds.y;
059: * f.getContentPane().add(c);
060: * f.setLocation((i*50)+xoffs, (i*60)+yoffs);
061: * f.show();
062: * }
063: * }
064: * </pre>
065: * @see GraphicsEnvironment
066: * @see GraphicsConfiguration
067: * @version 1.21, 02/09/01
068: */
069: public abstract class GraphicsDevice {
070: private Window fullScreenWindow = null;
071: private Rectangle windowedModeBounds = null;
072:
073: /**
074: * This is an abstract class that cannot be instantiated directly.
075: * Instances must be obtained from a suitable factory or query method.
076: * @see GraphicsEnvironment#getScreenDevices
077: * @see GraphicsEnvironment#getDefaultScreenDevice
078: * @see GraphicsConfiguration#getDevice
079: */
080: protected GraphicsDevice() {
081: }
082:
083: /**
084: * Device is a raster screen.
085: */
086: public final static int TYPE_RASTER_SCREEN = 0;
087: /**
088: * Device is a printer.
089: */
090: public final static int TYPE_PRINTER = 1;
091: /**
092: * Device is an image buffer. This buffer can reside in device
093: * or system memory but it is not physically viewable by the user.
094: */
095: public final static int TYPE_IMAGE_BUFFER = 2;
096:
097: /**
098: * Returns the type of this <code>GraphicsDevice</code>.
099: * @return the type of this <code>GraphicsDevice</code>, which can
100: * either be TYPE_RASTER_SCREEN, TYPE_PRINTER or TYPE_IMAGE_BUFFER.
101: * @see #TYPE_RASTER_SCREEN
102: * @see #TYPE_PRINTER
103: * @see #TYPE_IMAGE_BUFFER
104: */
105: public abstract int getType();
106:
107: /**
108: * Returns the identification string associated with this
109: * <code>GraphicsDevice</code>.
110: * <p>
111: * A particular program might use more than one
112: * <code>GraphicsDevice</code> in a <code>GraphicsEnvironment</code>.
113: * This method returns a <code>String</code> identifying a
114: * particular <code>GraphicsDevice</code> in the local
115: * <code>GraphicsEnvironment</code>. Although there is
116: * no public method to set this <code>String</code>, a programmer can
117: * use the <code>String</code> for debugging purposes. Vendors of
118: * the Java<sup><font size=-2>TM</font></sup> Runtime Environment can
119: * format the return value of the <code>String</code>. To determine
120: * how to interpret the value of the <code>String</code>, contact the
121: * vendor of your Java Runtime. To find out who the vendor is, from
122: * your program, call the
123: * {@link System#getProperty(String) getProperty} method of the
124: * System class with "java.vendor".
125: * @return a <code>String</code> that is the identification
126: * of this <code>GraphicsDevice</code>.
127: */
128: public abstract String getIDstring();
129:
130: /**
131: * Returns all of the <code>GraphicsConfiguration</code>
132: * objects associated with this <code>GraphicsDevice</code>.
133: * @return an array of <code>GraphicsConfiguration</code>
134: * objects that are associated with this
135: * <code>GraphicsDevice</code>.
136: */
137: public abstract GraphicsConfiguration[] getConfigurations();
138:
139: /**
140: * Returns the default <code>GraphicsConfiguration</code>
141: * associated with this <code>GraphicsDevice</code>.
142: * @return the default <code>GraphicsConfiguration</code>
143: * of this <code>GraphicsDevice</code>.
144: */
145: public abstract GraphicsConfiguration getDefaultConfiguration();
146:
147: /**
148: * Returns the "best" configuration possible that passes the
149: * criteria defined in the {@link GraphicsConfigTemplate}.
150: * @param gct the <code>GraphicsConfigTemplate</code> object
151: * used to obtain a valid <code>GraphicsConfiguration</code>
152: * @return a <code>GraphicsConfiguration</code> that passes
153: * the criteria defined in the specified
154: * <code>GraphicsConfigTemplate</code>.
155: * @see GraphicsConfigTemplate
156: */
157:
158: /*
159: public GraphicsConfiguration
160: getBestConfiguration(GraphicsConfigTemplate gct) {
161: GraphicsConfiguration[] configs = getConfigurations();
162: return gct.getBestConfiguration(configs);
163: }
164: */
165:
166: /**
167: * Returns <code>true</code> if this <code>GraphicsDevice</code>
168: * supports full-screen exclusive mode.
169: * @return whether full-screen exclusive mode is available for
170: * this graphics device
171: * @since 1.4
172: */
173: public abstract boolean isFullScreenSupported();
174:
175: public abstract int getAvailableAcceleratedMemory();
176:
177: /**
178: * Enter full-screen mode, or return to windowed mode.
179: * <p>
180: * If <code>isFullScreenSupported</code> returns <code>true</code>, full
181: * screen mode is considered to be <i>exclusive</i>, which implies:
182: * <ul>
183: * <li>Windows cannot overlap the full-screen window. All other application
184: * windows will always appear beneath the full-screen window in the Z-order.
185: * <li>Input method windows are disabled. It is advisable to call
186: * <code>Component.enableInputMethods(false)</code> to make a component
187: * a non-client of the input method framework.
188: * </ul>
189: * <p>
190: * If <code>isFullScreenSupported</code> returns
191: * <code>false</code>, full-screen exclusive mode is simulated by resizing
192: * the window to the size of the screen and positioning it at (0,0).
193: * <p>
194: * When returning to windowed mode from an exclusive full-screen window, any
195: * display changes made by calling <code>setDisplayMode</code> are
196: * automatically restored to their original state.
197: *
198: * @param w a window to use as the full-screen window; <code>null</code>
199: * if returning to windowed mode.
200: * @see #isFullScreenSupported
201: * @see #getFullScreenWindow
202: * @see #setDisplayMode
203: * @see Component#enableInputMethods
204: * @since 1.4
205: */
206: public abstract void setFullScreenWindow(Window w);
207:
208: /**
209: * Returns the <code>Window</code> object representing the
210: * full-screen window if the device is in full-screen mode.
211: * @return the full-screen window, <code>null</code> if the device is
212: * not in full-screen mode.
213: * @see #setFullScreenWindow(Window)
214: * @since 1.4
215: */
216: public abstract Window getFullScreenWindow();
217: }
|