001: /*
002: * @(#)MWGraphicsEnvironment.java 1.18 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: import java.util.Locale;
031: import java.awt.image.BufferedImage;
032:
033: /**
034: * This is an implementation of a GraphicsEnvironment object for the
035: * default local GraphicsEnvironment used by the JavaSoft JDK in MW
036: * environments.
037: *
038: * @see GraphicsDevice
039: * @see GraphicsConfiguration
040: * @version 10 Feb 1997
041: */
042:
043: class MWGraphicsEnvironment extends GraphicsEnvironment implements
044: Runnable {
045: MWGraphicsDevice defaultScreenDevice;
046:
047: private static native void init();
048:
049: private native void destroy();
050:
051: private Thread eventThread;
052:
053: MWGraphicsEnvironment() {
054: java.security.AccessController
055: .doPrivileged(new sun.security.action.LoadLibraryAction(
056: "microwindowsawt"));
057: init();
058: Runtime.getRuntime().addShutdownHook(new Thread() {
059: public void run() {
060: eventThread.interrupt();
061: MWGraphicsEnvironment.this .destroy();
062: }
063: });
064: defaultScreenDevice = new MWGraphicsDevice(this );
065: eventThread = new Thread(this , "MicroWindows");
066: eventThread.start();
067: }
068:
069: public native void run();
070:
071: public synchronized GraphicsDevice[] getScreenDevices() {
072: return new GraphicsDevice[] { defaultScreenDevice };
073: }
074:
075: /**
076: * Returns the default screen graphics device.
077: */
078:
079: public GraphicsDevice getDefaultScreenDevice() {
080: return defaultScreenDevice;
081: }
082:
083: public String[] getAvailableFontFamilyNames() {
084: return MWFontMetrics.getFontList();
085: }
086:
087: public String[] getAvailableFontFamilyNames(Locale l) {
088: return MWFontMetrics.getFontList();
089: }
090:
091: void setWindow(MWGraphicsDevice device, Window window) {
092: pSetWindow(device.psd, window);
093: }
094:
095: private native void pSetWindow(int psd, Window window);
096:
097: /**
098: * Returns a <code>Graphics2D</code> object for rendering into the
099: * specified {@link BufferedImage}.
100: * @param img the specified <code>BufferedImage</code>
101: * @return a <code>Graphics2D</code> to be used for rendering into
102: * the specified <code>BufferedImage</code>.
103: */
104: public Graphics2D createGraphics(BufferedImage img) {
105: return img.createGraphics();
106: }
107: /*
108: protected void finalize() throws Throwable
109: {
110: destroy();
111: super.finalize();
112: }
113: */
114: }
|