Source Code Cross Referenced for X11Toolkit.java in  » 6.0-JDK-Modules » j2me » java » awt » 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 » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)X11Toolkit.java	1.19 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.ImageObserver;
032:        import java.awt.image.ImageProducer;
033:        import java.awt.datatransfer.Clipboard;
034:        import java.net.URL;
035:        import java.util.Properties;
036:        import sun.awt.image.ByteArrayImageSource;
037:        import sun.awt.image.FileImageSource;
038:        import sun.awt.image.URLImageSource;
039:
040:        /** The toolkit used by this AWT implementation based on the X11 library.
041:         @version 1.14, 08/19/02
042:         */
043:
044:        class X11Toolkit extends Toolkit {
045:            private EventQueue eventQueue;
046:            private static Clipboard clipboard = new Clipboard("System");
047:            private static X11GraphicsConfig config = (X11GraphicsConfig) (GraphicsEnvironment
048:                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
049:                    .getDefaultConfiguration());
050:
051:            /** Pushes a new modal dislog onto the modal dialog stack. If events go to a window that does
052:             not belong to the modal dialog on the top of the stack then we just beep. */
053:
054:            static native void pushModal(int xwindow);
055:
056:            /** Pops the specified dialog off the modal stack. */
057:
058:            static native void popModal(int xwindow);
059:
060:            public X11Toolkit() {
061:                eventQueue = new EventQueue();
062:            }
063:
064:            /**
065:             * Gets the size of the screen.
066:             * @return    the size of this toolkit's screen, in pixels.
067:             * @since     JDK1.0
068:             */
069:            public Dimension getScreenSize() {
070:                Rectangle dims = config.getBounds();
071:                return new Dimension(dims.width, dims.height);
072:                //		return new Dimension (screenWidth, screenHeight);
073:            }
074:
075:            /**
076:             * Returns the screen resolution in dots-per-inch.
077:             * @return    this toolkit's screen resolution, in dots-per-inch.
078:             * @since     JDK1.0
079:             */
080:            public native int getScreenResolution();
081:
082:            /**
083:             * Determines the color model of this toolkit's screen.
084:             * <p>
085:             * <code>ColorModel</code> is an  class that
086:             * encapsulates the ability to translate between the
087:             * pixel values of an image and its red, green, blue,
088:             * and alpha components.
089:             * <p>
090:             * This toolkit method is called by the
091:             * <code>getColorModel</code> method
092:             * of the <code>Component</code> class.
093:             * @return    the color model of this toolkit's screen.
094:             * @see       java.awt.image.ColorModel
095:             * @see       java.awt.Component#getColorModel
096:             * @since     JDK1.0
097:             */
098:            public ColorModel getColorModel() {
099:                return config.getColorModel();
100:            }
101:
102:            /**
103:             * Returns the names of the available fonts in this toolkit.<p>
104:             * For 1.1, the following font names are deprecated (the replacement
105:             * name follows):
106:             * <ul>
107:             * <li>TimesRoman (use Serif)
108:             * <li>Helvetica (use SansSerif)
109:             * <li>Courier (use Monospaced)
110:             * </ul><p>
111:             * The ZapfDingbats font is also deprecated in 1.1, but only as a
112:             * separate fontname.  Unicode defines the ZapfDingbat characters
113:             * starting at \u2700, and as of 1.1 Java supports those characters.
114:             * @return    the names of the available fonts in this toolkit.
115:             * @since     JDK1.0
116:             */
117:            public String[] getFontList() {
118:                return X11FontMetrics.getFontList();
119:            }
120:
121:            /**
122:             * Gets the screen metrics of the font.
123:             * @param     font   a font.
124:             * @return    the screen metrics of the specified font in this toolkit.
125:             * @since     JDK1.0
126:             */
127:            public FontMetrics getFontMetrics(Font font) {
128:                return font.getX11FontMetrics();
129:            }
130:
131:            /**
132:             * Synchronizes this toolkit's graphics state. Some window systems
133:             * may do buffering of graphics events.
134:             * <p>
135:             * This method ensures that the display is up-to-date. It is useful
136:             * for animation.
137:             * @since     JDK1.0
138:             */
139:            public native void sync();
140:
141:            /**
142:             * Returns an image which gets pixel data from the specified file.
143:             * The underlying toolkit attempts to resolve multiple requests
144:             * with the same filename to the same returned Image.
145:             * Since the mechanism required to facilitate this sharing of
146:             * Image objects may continue to hold onto images that are no
147:             * longer of use for an indefinite period of time, developers
148:             * are encouraged to implement their own caching of images by
149:             * using the createImage variant wherever available.
150:             * <h3>Compatibility</h3>
151:             * PersonalJava does not require support of the PNG image file format.
152:             * @param filename Filename must reference an image format that
153:             *                 is recognized by this toolkit. The toolkit must be able
154:             *                 to create images from the following image file formats:
155:             *                   GIF, JPEG(JFIF), XBM, and PNG.
156:             * @return    an image which gets its pixel data from
157:             *                         the specified file.
158:             * @see       java.awt.Image
159:             * @see       java.awt.Toolkit#createImage(java.lang.String)
160:             */
161:            public Image getImage(String filename) {
162:                return createImage(filename);
163:            }
164:
165:            /**
166:             * Returns an image which gets pixel data from the specified URL.
167:             * The underlying toolkit attempts to resolve multiple requests
168:             * with the same URL to the same returned Image.
169:             * Since the mechanism required to facilitate this sharing of
170:             * Image objects may continue to hold onto images that are no
171:             * longer of use for an indefinite period of time, developers
172:             * are encouraged to implement their own caching of images by
173:             * using the createImage variant wherever available.
174:             * <h3>Compatibility</h3>
175:             * PersonalJava does not require support of the PNG image file format.
176:             * @param url URL must reference an image format that
177:             *            is recognized by this toolkit. The toolkit must be
178:             *            able to create images from the following image file formats:
179:             *                  GIF, JPEG(JFIF), XBM, and PNG.
180:             * @return    an image which gets its pixel data from
181:             *                         the specified URL.
182:             * @see       java.awt.Image
183:             * @see       java.awt.Toolkit#createImage(java.net.URL)
184:             */
185:            public Image getImage(URL url) {
186:                return createImage(url);
187:            }
188:
189:            /**
190:             * Returns an image which gets pixel data from the specified file.
191:             * The returned Image is a new object which will not be shared
192:             * with any other caller of this method or its getImage variant.
193:             * @param     filename   the name of a file containing pixel data
194:             *                         in a recognized file format.
195:             * @return    an image which gets its pixel data from
196:             *                         the specified file.
197:             * @see       java.awt.Toolkit#getImage(java.lang.String)
198:             */
199:
200:            public Image createImage(String filename) {
201:                ImageProducer ip = new FileImageSource(filename);
202:                Image newImage = createImage(ip);
203:                return newImage;
204:            }
205:
206:            /**
207:             * Returns an image which gets pixel data from the specified URL.
208:             * The returned Image is a new object which will not be shared
209:             * with any other caller of this method or its getImage variant.
210:             * @param     url   the URL to use in fetching the pixel data.
211:             * @return    an image which gets its pixel data from
212:             *                         the specified URL.
213:             * @see       java.awt.Toolkit#getImage(java.net.URL)
214:             */
215:
216:            public Image createImage(URL url) {
217:                ImageProducer ip = new URLImageSource(url);
218:                Image newImage = createImage(ip);
219:                return newImage;
220:            }
221:
222:            /**
223:             * Prepares an image for rendering.
224:             * <p>
225:             * If the values of the width and height arguments are both
226:             * <code>-1</code>, this method prepares the image for rendering
227:             * on the default screen; otherwise, this method prepares an image
228:             * for rendering on the default screen at the specified width and height.
229:             * <p>
230:             * The image data is downloaded asynchronously in another thread,
231:             * and an appropriately scaled screen representation of the image is
232:             * generated.
233:             * <p>
234:             * This method is called by components <code>prepareImage</code>
235:             * methods.
236:             * <p>
237:             * Information on the flags returned by this method can be found
238:             * with the definition of the <code>ImageObserver</code> interface.
239:
240:             * @param     image      the image for which to prepare a
241:             *                           screen representation.
242:             * @param     width      the width of the desired screen
243:             *                           representation, or <code>-1</code>.
244:             * @param     height     the height of the desired screen
245:             *                           representation, or <code>-1</code>.
246:             * @param     observer   the <code>ImageObserver</code>
247:             *                           object to be notified as the
248:             *                           image is being prepared.
249:             * @return    <code>true</code> if the image has already been
250:             *                 fully prepared; <code>false</code> otherwise.
251:             * @see       java.awt.Component#prepareImage(java.awt.Image,
252:             *                 java.awt.image.ImageObserver)
253:             * @see       java.awt.Component#prepareImage(java.awt.Image,
254:             *                 int, int, java.awt.image.ImageObserver)
255:             * @see       java.awt.image.ImageObserver
256:             * @since     JDK1.0
257:             */
258:            public boolean prepareImage(Image image, int width, int height,
259:                    ImageObserver observer) {
260:                return false;
261:            }
262:
263:            /**
264:             * Indicates the construction status of a specified image that is
265:             * being prepared for display.
266:             * <p>
267:             * If the values of the width and height arguments are both
268:             * <code>-1</code>, this method returns the construction status of
269:             * a screen representation of the specified image in this toolkit.
270:             * Otherwise, this method returns the construction status of a
271:             * scaled representation of the image at the specified width
272:             * and height.
273:             * <p>
274:             * This method does not cause the image to begin loading.
275:             * An application must call <code>prepareImage</code> to force
276:             * the loading of an image.
277:             * <p>
278:             * This method is called by the component's <code>checkImage</code>
279:             * methods.
280:             * <p>
281:             * Information on the flags returned by this method can be found
282:             * with the definition of the <code>ImageObserver</code> interface.
283:             * @param     image   the image whose status is being checked.
284:             * @param     width   the width of the scaled version whose status is
285:             *                 being checked, or <code>-1</code>.
286:             * @param     height  the height of the scaled version whose status
287:             *                 is being checked, or <code>-1</code>.
288:             * @param     observer   the <code>ImageObserver</code> object to be
289:             *                 notified as the image is being prepared.
290:             * @return    the bitwise inclusive <strong>OR</strong> of the
291:             *                 <code>ImageObserver</code> flags for the
292:             *                 image data that is currently available.
293:             * @see       java.awt.Toolkit#prepareImage(java.awt.Image,
294:             *                 int, int, java.awt.image.ImageObserver)
295:             * @see       java.awt.Component#checkImage(java.awt.Image,
296:             *                 java.awt.image.ImageObserver)
297:             * @see       java.awt.Component#checkImage(java.awt.Image,
298:             *                 int, int, java.awt.image.ImageObserver)
299:             * @see       java.awt.image.ImageObserver
300:             * @since     JDK1.0
301:             */
302:            public int checkImage(Image image, int width, int height,
303:                    ImageObserver observer) {
304:                return ImageObserver.ALLBITS;
305:            }
306:
307:            /**
308:             * Creates an image with the specified image producer.
309:             * @param     producer the image producer to be used.
310:             * @return    an image with the specified image producer.
311:             * @see       java.awt.Image
312:             * @see       java.awt.image.ImageProducer
313:             * @see       java.awt.Component#createImage(java.awt.image.ImageProducer)
314:             * @since     JDK1.0
315:             */
316:            public Image createImage(ImageProducer producer) {
317:                return new X11Image(producer);
318:            }
319:
320:            /**
321:             * Creates an image which decodes the image stored in the specified
322:             * byte array, and at the specified offset and length.
323:             * The data must be in some image format, such as GIF or JPEG,
324:             * that is supported by this toolkit.
325:             * @param     imagedata   an array of bytes, representing
326:             *                         image data in a supported image format.
327:             * @param     imageoffset  the offset of the beginning
328:             *                         of the data in the array.
329:             * @param     imagelength  the length of the data in the array.
330:             * @return    an image.
331:             * @since     JDK1.1
332:             */
333:            public Image createImage(byte[] imagedata, int imageoffset,
334:                    int imagelength) {
335:                ImageProducer ip = new ByteArrayImageSource(imagedata,
336:                        imageoffset, imagelength);
337:                Image newImage = createImage(ip);
338:                return newImage;
339:            }
340:
341:            /**
342:             * This method creates and returns a new <code>PrintJob</code>
343:             * instance which is the result of initiating a print operation
344:             * on the toolkit's platform.
345:             * <h3>Compatibility</h3>
346:             * In Both PersonalJava and Personal Profile, the PrintJob class
347:             * is optional If the platform does not support printing,
348:             * an <code>UnsupportedOperationException</code> is thrown.
349:             * @return    a <code>PrintJob</code> object, or
350:             *                  <code>null</code> if the user
351:             *                  cancelled the print job.
352:             * @exception UnsupportedOperationException if the implementation does not support printing.
353:             * @see       java.awt.PrintJob
354:             * @since     JDK1.1
355:             */
356:            public PrintJob getPrintJob(Frame frame, String jobtitle,
357:                    Properties props) {
358:                throw new UnsupportedOperationException();
359:            }
360:
361:            /**
362:             * Emits an audio beep.
363:             * @since     JDK1.1
364:             */
365:            public native void beep();
366:
367:            /**
368:             * Gets an instance of the system clipboard which interfaces
369:             * with clipboard facilities provided by the native platform.
370:             * <p>
371:             * This clipboard enables data transfer between Java programs
372:             * and native applications which use native clipboard facilities.
373:             * @return    an instance of the system clipboard.
374:             * @see       java.awt.datatransfer.Clipboard
375:             * @since     JDK1.1
376:             */
377:            public Clipboard getSystemClipboard() {
378:                return clipboard;
379:            }
380:
381:            /*
382:             * Get the application's or applet's EventQueue instance, without
383:             * checking access.  For security reasons, this can only be called
384:             * from a Toolkit subclass.  Implementations wishing to modify
385:             * the default EventQueue support should subclass this method.
386:             */
387:            protected EventQueue getSystemEventQueueImpl() {
388:                return eventQueue;
389:            }
390:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.