001: /*
002: * @(#)X11GraphicsEnvironment.java 1.11 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:
032: /**
033: * This is an implementation of a GraphicsEnvironment object for the
034: * default local GraphicsEnvironment used by the JavaSoft JDK in X11
035: * environments.
036: *
037: * @see GraphicsDevice
038: * @see GraphicsConfiguration
039: * @version 1.6, 08/19/02
040: */
041:
042: class X11GraphicsEnvironment extends GraphicsEnvironment implements
043: Runnable {
044: // Map fontNameMap;
045: // Map xlfdMap;
046:
047: GraphicsDevice[] screens;
048: static {
049: java.security.AccessController
050: .doPrivileged(new sun.security.action.LoadLibraryAction(
051: "x11awt"));
052: initDisplay();
053: /* Disable swing focus manager as we are mixing Swing and AWT components. */
054: javax.swing.FocusManager.disableSwingFocusManager();
055: }
056:
057: private static native void initDisplay();
058:
059: public X11GraphicsEnvironment() {
060: new Thread(this , "X-Event-Thread").start();
061: }
062:
063: public native void run();
064:
065: protected native int getNumScreens();
066:
067: protected GraphicsDevice makeScreenDevice(int screennum) {
068: return new X11GraphicsDevice(screennum);
069: }
070:
071: protected native int getDefaultScreenNum();
072:
073: public synchronized GraphicsDevice[] getScreenDevices() {
074: GraphicsDevice[] ret = screens;
075: if (ret == null) {
076: int num = getNumScreens();
077: ret = new GraphicsDevice[num];
078: for (int i = 0; i < num; i++)
079: ret[i] = makeScreenDevice(i);
080: screens = ret;
081: }
082: return ret;
083: }
084:
085: /**
086: * Returns the default screen graphics device.
087: */
088:
089: public GraphicsDevice getDefaultScreenDevice() {
090: GraphicsDevice[] gd = getScreenDevices();
091: System.out.println("NumSD=" + gd.length + " defDS="
092: + getDefaultScreenNum());
093: return gd[getDefaultScreenNum()];
094: }
095:
096: public String[] getAvailableFontFamilyNames() {
097: return X11FontMetrics.getFontList();
098: }
099:
100: public String[] getAvailableFontFamilyNames(Locale l) {
101: return X11FontMetrics.getFontList();
102: }
103: }
|