Source Code Cross Referenced for QtImage.java in  » 6.0-JDK-Modules » j2me » sun » awt » qt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sun.awt.qt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)QtImage.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 sun.awt.qt;
029:
030:        import java.awt.Component;
031:        import java.awt.Graphics;
032:        import java.awt.GraphicsEnvironment;
033:        import java.awt.GraphicsConfiguration;
034:        import java.awt.Color;
035:        import java.awt.image.ImageProducer;
036:        import java.awt.image.ImageObserver;
037:        import java.awt.image.ColorModel;
038:        import java.awt.image.DirectColorModel;
039:        import java.awt.image.BufferedImage;
040:        import java.awt.image.RasterFormatException;
041:        import sun.awt.image.ImageRepresentation;
042:        import sun.awt.image.BufferedImagePeer;
043:
044:        class QtImage extends sun.awt.image.Image implements  BufferedImagePeer,
045:                QtDrawableImage {
046:            QtGraphicsConfiguration gc;
047:            Component c;
048:
049:            /* Tunnel the Offscreen image constructor to the super class. */
050:            protected QtImage(Component c, int w, int h) {
051:                super (c, w, h);
052:                if (gc == null)
053:                    gc = (QtGraphicsConfiguration) GraphicsEnvironment
054:                            .getLocalGraphicsEnvironment()
055:                            .getDefaultScreenDevice().getDefaultConfiguration();
056:                this .c = c;
057:
058:            }
059:
060:            public QtImage(Component c, int w, int h, QtGraphicsConfiguration gc) {
061:                super (c, w, h);
062:                this .gc = gc;
063:                this .c = c;
064:            }
065:
066:            /**
067:             * Construct an image from an ImageProducer object.
068:             */
069:            public QtImage(ImageProducer producer) {
070:                super (producer);
071:                gc = (QtGraphicsConfiguration) GraphicsEnvironment
072:                        .getLocalGraphicsEnvironment().getDefaultScreenDevice()
073:                        .getDefaultConfiguration();
074:            }
075:
076:            public Graphics getGraphics() {
077:                // 6258458
078:                // Per J2SE 1.5 spec, we should throw UOE if the method is called
079:                // on a non-offscreen image
080:                if (this .c == null) {
081:                    throw new UnsupportedOperationException(
082:                            "Not a offscreen image");
083:                }
084:                // 6258458
085:
086:                Graphics g = new QtGraphics(this );
087:                if (c != null)
088:                    initGraphics(g);
089:                return g;
090:            }
091:
092:            public boolean isComplete() {
093:                return ((getImageRep().check(null) & ImageObserver.ALLBITS) != 0);
094:            }
095:
096:            protected ImageRepresentation makeImageRep() {
097:                return new QtImageRepresentation(this );
098:            }
099:
100:            protected ImageRepresentation getImageRep() {
101:                return super .getImageRep();
102:            }
103:
104:            // BufferedImagePeer implementation
105:
106:            public int getType() {
107:                ImageRepresentation imgRep = this .getImageRep();
108:                if (imgRep instanceof  sun.awt.qt.QtImageRepresentation) {
109:                    return ((QtImageRepresentation) imgRep).getType();
110:                } else {
111:                    return BufferedImage.TYPE_CUSTOM;
112:                }
113:            }
114:
115:            public ColorModel getColorModel() {
116:                return gc.getColorModel();
117:            }
118:
119:            public Object getProperty(String name) {
120:                return super .getProperty(name, null);
121:            }
122:
123:            public BufferedImage getSubimage(int x, int y, int w, int h) {
124:
125:                if ((x + w < x) || (x + w > getWidth())) {
126:                    throw new RasterFormatException(
127:                            "(x + width) is outside raster");
128:                }
129:
130:                if ((y + h < y) || (y + h > getHeight())) {
131:                    throw new RasterFormatException(
132:                            "(y + height) is outside raster");
133:                }
134:
135:                return QtToolkit.createBufferedImage(new QtSubImage(this , x, y,
136:                        w, h));
137:            }
138:
139:            public String[] getPropertyNames() {
140:                return null;
141:            }
142:
143:            public int getRGB(int x, int y) {
144:                return ((QtImageRepresentation) getImageRep()).getRGB(
145:                        getColorModel(), x, y);
146:            }
147:
148:            public int[] getRGB(int startX, int startY, int w, int h,
149:                    int[] rgbArray, int offset, int scansize) {
150:                if (null == rgbArray)
151:                    rgbArray = new int[offset + h * scansize];
152:
153:                else if (rgbArray.length < offset + h * scansize)
154:                    throw new IllegalArgumentException(
155:                            "rgbArray is not large enough to store all the values");
156:
157:                ((QtImageRepresentation) getImageRep()).getRGBs(
158:                        getColorModel(), startX, startY, w, h, rgbArray,
159:                        offset, scansize);
160:                return rgbArray;
161:            }
162:
163:            private static final ColorModel COLOR_MODEL_FOR_SET_RGB = new DirectColorModel(
164:                    32, 0xff0000, 0xff00, 0xff, 0);
165:
166:            public void setRGB(int x, int y, int rgb) {
167:                getImageRep().setPixels(x, y, 1, 1, COLOR_MODEL_FOR_SET_RGB,
168:                        new int[] { rgb }, 0, 0);
169:            }
170:
171:            public void setRGB(int startX, int startY, int w, int h,
172:                    int[] rgbArray, int offset, int scansize) {
173:                getImageRep().setPixels(startX, startY, w, h,
174:                        COLOR_MODEL_FOR_SET_RGB, rgbArray, offset, scansize);
175:            }
176:
177:            // QtDrawableImage implementation
178:
179:            public boolean draw(QtGraphics g, int x, int y,
180:                    ImageObserver observer) {
181:                if (hasError()) {
182:                    if (observer != null) {
183:                        observer.imageUpdate(this , ImageObserver.ERROR
184:                                | ImageObserver.ABORT, -1, -1, -1, -1);
185:                    }
186:                    return false;
187:                }
188:
189:                QtImageRepresentation imgRep = (QtImageRepresentation) getImageRep();
190:
191:                if (imgRep.finishCalled
192:                        && imgRep.drawSucceeded
193:                        && g != null
194:                        && g.data != 0
195:                        && imgRep.imageDrawDirect(g.data, x + g.originX, y
196:                                + g.originY, null)) {
197:                    return true;
198:                } else {
199:                    return getImageRep().drawImage(g, x, y, null, observer);
200:                }
201:            }
202:
203:            public boolean draw(QtGraphics g, int x, int y, int width,
204:                    int height, ImageObserver observer) {
205:                if (width == 0 || height == 0) {
206:                    return true;
207:                }
208:                if (hasError()) {
209:                    if (observer != null) {
210:                        observer.imageUpdate(this , ImageObserver.ERROR
211:                                | ImageObserver.ABORT, -1, -1, -1, -1);
212:                    }
213:                    return false;
214:                }
215:                return getImageRep().drawScaledImage(g, x, y, width, height,
216:                        null, observer);
217:            }
218:
219:            public boolean draw(QtGraphics g, int x, int y, Color bg,
220:                    ImageObserver observer) {
221:                if (hasError()) {
222:                    if (observer != null) {
223:                        observer.imageUpdate(this , ImageObserver.ERROR
224:                                | ImageObserver.ABORT, -1, -1, -1, -1);
225:                    }
226:                    return false;
227:                }
228:
229:                QtImageRepresentation imgRep = (QtImageRepresentation) getImageRep();
230:
231:                if (imgRep.finishCalled
232:                        && imgRep.drawSucceeded
233:                        && g != null
234:                        && g.data != 0
235:                        && imgRep.imageDrawDirect(g.data, x + g.originX, y
236:                                + g.originY, bg)) {
237:                    return true;
238:                } else {
239:                    return getImageRep().drawImage(g, x, y, bg, observer);
240:                }
241:            }
242:
243:            public boolean draw(QtGraphics g, int x, int y, int width,
244:                    int height, Color bg, ImageObserver observer) {
245:                if (width == 0 || height == 0) {
246:                    return true;
247:                }
248:                if (hasError()) {
249:                    if (observer != null) {
250:                        observer.imageUpdate(this , ImageObserver.ERROR
251:                                | ImageObserver.ABORT, -1, -1, -1, -1);
252:                    }
253:                    return false;
254:                }
255:                return getImageRep().drawScaledImage(g, x, y, width, height,
256:                        bg, observer);
257:            }
258:
259:            public boolean draw(QtGraphics g, int dx1, int dy1, int dx2,
260:                    int dy2, int sx1, int sy1, int sx2, int sy2,
261:                    ImageObserver observer) {
262:                if (dx1 == dx2 || dy1 == dy2) {
263:                    return true;
264:                }
265:                if (hasError()) {
266:                    if (observer != null) {
267:                        observer.imageUpdate(this , ImageObserver.ERROR
268:                                | ImageObserver.ABORT, -1, -1, -1, -1);
269:                    }
270:                    return false;
271:                }
272:                return getImageRep().drawStretchImage(g, dx1, dy1, dx2, dy2,
273:                        sx1, sy1, sx2, sy2, null, observer);
274:            }
275:
276:            public boolean draw(QtGraphics g, int dx1, int dy1, int dx2,
277:                    int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor,
278:                    ImageObserver observer) {
279:                if (dx1 == dx2 || dy1 == dy2) {
280:                    return true;
281:                }
282:                if (hasError()) {
283:                    if (observer != null) {
284:                        observer.imageUpdate(this , ImageObserver.ERROR
285:                                | ImageObserver.ABORT, -1, -1, -1, -1);
286:                    }
287:                    return false;
288:                }
289:                return getImageRep().drawStretchImage(g, dx1, dy1, dx2, dy2,
290:                        sx1, sy1, sx2, sy2, bgcolor, observer);
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.