001: /*
002: * @(#)QtVolatileImage.java 1.7 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: package java.awt;
027:
028: import java.awt.*;
029: import java.awt.image.*;
030:
031: /**
032: Qt volatile image implementation.
033: @version 1.00 08/25/04
034: */
035:
036: class QtVolatileImage extends java.awt.image.VolatileImage {
037:
038: QtOffscreenImage qtimage;
039:
040: QtVolatileImage(int width, int height, GraphicsConfiguration gc) {
041: qtimage = new QtOffscreenImage((Component) null, width, height,
042: (QtGraphicsConfiguration) gc);
043:
044: }
045:
046: public int getHeight(ImageObserver observer) {
047: return qtimage.getHeight(observer);
048: }
049:
050: public java.lang.Object getProperty(java.lang.String name,
051: ImageObserver observer) {
052: return qtimage.getProperty(name, observer);
053: }
054:
055: // 6240967
056: // The scaled instance should be a snapshot of "this"
057: // (i.e BufferedImage) and the contents should be immediately
058: // available. By using the Image.getScaledInstance() we acheive the
059: // desired effect (See also QtVolatileImage.getSource())
060: // public Image getScaledInstance(int width, int height, int hints)
061: // {
062: // return qtimage.getScaledInstance(width, height, hints);
063: // }
064: // 6240967
065:
066: public int getWidth(ImageObserver observer) {
067: return qtimage.getWidth(observer);
068: }
069:
070: public boolean contentsLost() {
071: return false;
072: }
073:
074: public Graphics2D createGraphics() {
075: return (Graphics2D) qtimage.getGraphics();
076: }
077:
078: public void flush() {
079: qtimage.flush();
080: }
081:
082: public ImageCapabilities getCapabilities() {
083: return new ImageCapabilities(false);
084: }
085:
086: public Graphics getGraphics() {
087: return qtimage.getGraphics();
088:
089: }
090:
091: public int getHeight() {
092: return qtimage.getHeight();
093: }
094:
095: public BufferedImage getSnapshot() {
096: // Returns a static snapshot image of this object.
097:
098: QtOffscreenImage img = new QtOffscreenImage((Component) null,
099: qtimage.width, qtimage.height, qtimage.gc);
100: Graphics g = img.getGraphics();
101: g.drawImage(qtimage, 0, 0, null);
102: g.dispose(); // 6240967
103:
104: return QtGraphicsConfiguration.createBufferedImageObject(img,
105: img.psd);
106: }
107:
108: public ImageProducer getSource() {
109: return getSnapshot().getSource(); // 6240967
110: }
111:
112: public int getWidth() {
113: return qtimage.getWidth();
114: }
115:
116: public int validate(GraphicsConfiguration gc) {
117: return 0;
118: }
119:
120: }
|