001: /*
002: * @(#)X11GraphicsConfig.java 1.10 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.awt.image.ColorModel;
031: import java.awt.image.BufferedImage;
032:
033: /**
034: * This is an implementation of a GraphicsConfiguration object for a
035: * single X11 visual.
036: *
037: * @see GraphicsEnvironment
038: * @see GraphicsDevice
039: * @version 1.40, 02/02/00
040: */
041: class X11GraphicsConfig extends GraphicsConfiguration {
042: X11GraphicsDevice screen;
043: int visual;
044: ColorModel colorModel;
045: private Rectangle bounds;
046:
047: private native void init(int visualNum, int screen);
048:
049: // private native ColorModel makeColorModel ();
050:
051: X11GraphicsConfig(X11GraphicsDevice device, int visualnum) {
052: this .screen = device;
053: this .visual = visualnum;
054: init(visualnum, screen.getScreen());
055: bounds = new Rectangle(0, 0,
056: getXResolution(screen.getScreen()),
057: getYResolution(screen.getScreen()));
058: }
059:
060: /**
061: * Return the graphics device associated with this configuration.
062: */
063: public GraphicsDevice getDevice() {
064: return screen;
065: }
066:
067: /**
068: * Returns a BufferedImage with channel layout and color model
069: * compatible with this graphics configuration. This method
070: * has nothing to do with memory-mapping
071: * a device. This BufferedImage has
072: * a layout and color model
073: * that is closest to this native device configuration and thus
074: * can be optimally blitted to this device.
075: */
076: public BufferedImage createCompatibleImage(int width, int height) {
077: return new X11Image(width, height, null);
078: }
079:
080: private native ColorModel getNativeColorModel(int visual);
081:
082: public synchronized ColorModel getColorModel() {
083: if (colorModel == null)
084: colorModel = getNativeColorModel(visual);
085: return colorModel;
086: }
087:
088: private native int getXResolution(int screen);
089:
090: private native int getYResolution(int screen);
091:
092: public String toString() {
093: return ("X11GraphicsConfig[dev=" + screen + ",vis=0x"
094: + Integer.toHexString(visual) + "]");
095: }
096:
097: public Rectangle getBounds() {
098: return bounds;
099: }
100: }
|