01: /*
02: * @(#)QtGraphicsConfiguration.java 1.6 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program 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 version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package java.awt;
28:
29: import java.awt.image.BufferedImage;
30: import java.awt.image.ColorModel;
31:
32: /**
33: @version 1.11, 05/03/02 */
34:
35: abstract class QtGraphicsConfiguration extends GraphicsConfiguration {
36:
37: QtGraphicsConfiguration(QtGraphicsDevice device) {
38: this .device = device;
39: }
40:
41: public GraphicsDevice getDevice() {
42: return device;
43: }
44:
45: public Rectangle getBounds() {
46: return device.getBounds();
47: }
48:
49: public BufferedImage createCompatibleImage(int width, int height) {
50: if (width <= 0 || height <= 0)
51: return null;
52:
53: QtOffscreenImage qo = new QtOffscreenImage(null, width, height,
54: this );
55:
56: return createBufferedImageObject(qo, qo.psd);
57: }
58:
59: public java.awt.image.VolatileImage createCompatibleVolatileImage(
60: int width, int height) {
61: if (width <= 0 || height <= 0)
62: return null;
63:
64: QtVolatileImage qv = new QtVolatileImage(width, height, this );
65:
66: return qv;
67:
68: }
69:
70: int getCompatibleImageType() {
71: return imageType;
72: }
73:
74: protected native int createCompatibleImageType(int width,
75: int height, boolean fresh);
76:
77: protected native int pClonePSD(int psd);
78:
79: protected native int pDisposePSD(int psd);
80:
81: int createCompatibleImagePSD(int width, int height) {
82: int psd;
83:
84: try {
85: psd = createCompatibleImageType(width, height, false);
86: } catch (OutOfMemoryError e) {
87: System.gc();
88: psd = createCompatibleImageType(width, height, true);
89: }
90:
91: return psd;
92: }
93:
94: static native BufferedImage createBufferedImageObject(
95: QtImage image, int psd);
96:
97: private QtGraphicsDevice device;
98: protected int imageType;
99: }
|