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


001:        /*
002:         * @(#)GdkGraphicsEnvironment.java	1.20 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:        package sun.awt.gtk;
028:
029:        import java.awt.Graphics2D;
030:        import java.awt.GraphicsEnvironment;
031:        import java.awt.GraphicsDevice;
032:        import java.awt.image.BufferedImage;
033:        import java.util.Locale;
034:        import sun.io.FileIO;
035:        import sun.io.FileIOFactory;
036:        import sun.io.CharacterEncoding;
037:        import java.io.InputStream;
038:        import java.io.BufferedInputStream;
039:        import java.util.Properties;
040:        import java.util.List;
041:        import java.util.ArrayList;
042:        import java.util.Iterator;
043:
044:        public class GdkGraphicsEnvironment extends GraphicsEnvironment {
045:
046:            private static final String DEFAULT_NATIVE_FONT_NAME = "-adobe-courier-medium-r-normal--0-%d-0-0-m-0-iso8859-1";
047:            private static String defaultNativeFontName = null;
048:
049:            public GraphicsDevice getDefaultScreenDevice() {
050:                return graphicsDevice;
051:            }
052:
053:            public GraphicsDevice[] getScreenDevices() {
054:                return new GraphicsDevice[] { graphicsDevice };
055:            }
056:
057:            public String[] getAvailableFontFamilyNames() {
058:
059:                /* Call the static version in GPlatformFont */
060:
061:                return GPlatformFont.getAvailableFontFamilyNames();
062:
063:                /*		
064:                 List fontNames = new ArrayList();
065:                 Iterator fonts = defaultProperties.keySet().iterator();
066:                 int dotidx;
067:                 while (fonts.hasNext()) {
068:                 String fontName = (String) fonts.next();
069:                 if ((dotidx = fontName.indexOf('.')) == -1)
070:                 dotidx = fontName.length();
071:                 fontName = fontName.substring(0, dotidx);
072:                 if (!fontNames.contains(fontName))
073:                 fontNames.add(fontName);
074:                 }
075:                 if (!fontNames.contains("default"))
076:                 fontNames.add("default");
077:                 return (String[]) fontNames.toArray(new String[fontNames.size()]);
078:                 */
079:            }
080:
081:            public String[] getAvailableFontFamilyNames(Locale l) {
082:
083:                /* FIXME... add the locale version to GPlatformFont */
084:
085:                return getAvailableFontFamilyNames();
086:            }
087:
088:            /**
089:             * Returns a <code>Graphics2D</code> object for rendering into the
090:             * specified {@link BufferedImage}.
091:             * @param img the specified <code>BufferedImage</code>
092:             * @return a <code>Graphics2D</code> to be used for rendering into
093:             * the specified <code>BufferedImage</code>.
094:             */
095:            public Graphics2D createGraphics(BufferedImage img) {
096:                return img.createGraphics();
097:            }
098:
099:            /* Given the name and style of a font this method will detrmine the fontset name
100:             that needs to be loaded by gdk_fontset_load. */
101:
102:            static String getNativeFontName(String name, int style) {
103:
104:                /* Call the static version in GPlatformFont */
105:
106:                return GPlatformFont.getNativeFontName(name, style);
107:
108:                /*		
109:                String nativeName;
110:                name = name.toLowerCase();
111:                nativeName = defaultProperties.getProperty(name + "." + style);
112:                if (nativeName == null) {
113:                    // Check if plain version exists
114:                	
115:                    nativeName = defaultProperties.getProperty(name + ".0");
116:
117:                // Get the default native font name from a system property if
118:                //   exists as a system property
119:                    if (nativeName == null) {
120:                if (defaultNativeFontName == null) {
121:                    String fontNameTmp = 
122:                	System.getProperty("j2me.pp.gtk.default.font");
123:                    if (fontNameTmp == null) {
124:                	defaultNativeFontName = DEFAULT_NATIVE_FONT_NAME;
125:                    }
126:                    else {
127:                	defaultNativeFontName = fontNameTmp;
128:                    }
129:                }
130:                nativeName = defaultNativeFontName;
131:                }
132:                }
133:                return nativeName;
134:                
135:                 */
136:
137:            }
138:
139:            private GdkGraphicsDevice graphicsDevice = new GdkGraphicsDevice();
140:            /* The font propertiues used to map from font names to fonset names. */
141:
142:            //    private static Properties defaultProperties;
143:            static {
144:                //        defaultProperties = new Properties();
145:                // Ensure the lib is loaded.
146:                java.awt.Toolkit.getDefaultToolkit();
147:                /*
148:                 java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
149:                 public Object run() {
150:                 String jhome = System.getProperty("java.home");
151:                 String uhome = System.getProperty("user.home");
152:                 if (jhome == null) {
153:                 throw new Error("java.home property not set");
154:                 }
155:                 String language = System.getProperty("user.language", "en");
156:                 String region = System.getProperty("user.region");
157:                 // Translate the raw encoding name returned by the VM to the canonical
158:                 // name from the alias table in CharacterEncoding. Map unlisted raw
159:                 // encoding names to themselves. -bug 4163038
160:                
161:                 String rawEncoding = System.getProperty("file.encoding");
162:                 String encoding = CharacterEncoding.aliasName(rawEncoding);
163:                 if (encoding == null)
164:                 encoding = rawEncoding;
165:                 try {
166:                 FileIO f = null;
167:                 if (region != null) {
168:                 f = tryOpeningFontProp(
169:                 f, uhome, language, region + "_" + encoding);
170:                 f = tryOpeningFontProp(
171:                 f, jhome, language, region + "_" + encoding);
172:                 f = tryOpeningFontProp(f, uhome, language, region);
173:                 f = tryOpeningFontProp(f, jhome, language, region);
174:                 }
175:                 f = tryOpeningFontProp(f, uhome, language, encoding);
176:                 f = tryOpeningFontProp(f, jhome, language, encoding);
177:                 f = tryOpeningFontProp(f, uhome, language, null);
178:                 f = tryOpeningFontProp(f, jhome, language, null);
179:                 f = tryOpeningFontProp(f, uhome, encoding, null);
180:                 f = tryOpeningFontProp(f, jhome, encoding, null);
181:                 f = tryOpeningFontProp(f, uhome, null, null);
182:                 f = tryOpeningFontProp(f, jhome, null, null);
183:                 // Load property file
184:                 InputStream in = new BufferedInputStream(f.getInputStream());
185:                 defaultProperties.load(in);
186:                 in.close();
187:                 } // If anything goes wrong then resort to default properties.
188:                 catch (Exception e) {
189:                 defaultProperties.put("serif.0", "-URW-Times-medium-r-normal--0-%d-0-0-p-0-iso8859-1");
190:                 defaultProperties.put("serif.1", "-URW-Times-bold-r-normal--0-%d-0-0-p-0-iso8859-1");
191:                 defaultProperties.put("serif.2", "-URW-Times-medium-i-normal--0-%d-0-0-p-0-iso8859-1");
192:                 defaultProperties.put("serif.3", "-URW-Times-bold-i-normal--0-%d-0-0-p-0-iso8859-1");
193:                 defaultProperties.put("sansserif.0", "-URW-Helvetica-medium-r-normal--0-%d-0-0-p-0-iso8859-1");
194:                 defaultProperties.put("sansserif.1", "-URW-Helvetica-bold-r-normal--0-%d-0-0-p-0-iso8859-1");
195:                 defaultProperties.put("sansserif.2", "-URW-Helvetica-medium-o-normal--0-%d-0-0-p-0-iso8859-1");
196:                 defaultProperties.put("sansserif.3", "-URW-Helvetica-bold-o-normal--0-%d-0-0-p-0-iso8859-1");
197:                 defaultProperties.put("monospaced.0", "-URW-Courier-medium-r-normal--0-%d-0-0-p-0-iso8859-1");
198:                 defaultProperties.put("monospaced.1", "-URW-Courier-bold-r-normal--0-%d-0-0-p-0-iso8859-1");
199:                 defaultProperties.put("monospaced.2", "-URW-Courier-medium-o-normal--0-%d-0-0-p-0-iso8859-1");
200:                 defaultProperties.put("monospaced.3", "-URW-Courier-bold-o-normal--0-%d-0-0-p-0-iso8859-1");
201:                 defaultProperties.put("dialog.0", "-URW-Helvetica-medium-r-normal--0-%d-0-0-p-0-iso8859-1");
202:                 defaultProperties.put("dialog.1", "-URW-Helvetica-bold-r-normal--0-%d-0-0-p-0-iso8859-1");
203:                 defaultProperties.put("dialog.2", "-URW-Helvetica-medium-o-normal--0-%d-0-0-p-0-iso8859-1");
204:                 defaultProperties.put("dialog.3", "-URW-Helvetica-bold-o-normal--0-%d-0-0-p-0-iso8859-1");
205:                 defaultProperties.put("dialoginput.0", "-URW-Courier-medium-r-normal--0-%d-0-0-p-0-iso8859-1");
206:                 defaultProperties.put("dialoginput.1", "-URW-Courier-bold-r-normal--0-%d-0-0-p-0-iso8859-1");
207:                 defaultProperties.put("dialoginput.2", "-URW-Courier-medium-o-normal--0-%d-0-0-p-0-iso8859-1");
208:                 defaultProperties.put("dialoginput.3", "-URW-Courier-bold-o-normal--0-%d-0-0-p-0-iso8859-1");
209:                 }
210:                 return null;
211:                 }
212:                 }
213:                 );
214:                 */
215:
216:            }
217:
218:            /*	
219:             private static FileIO tryOpeningFontProp(FileIO f, String homedir, String language, String ext) {
220:             if (f != null)
221:             return f;       // already validated
222:             String filename = homedir + FileIO.separator
223:             + "lib" + FileIO.separator
224:             + "font.properties";
225:             if (language != null) {
226:             filename += "." + language;
227:             if (ext != null)
228:             filename += "_" + ext;
229:             }
230:             FileIO propsFile = FileIOFactory.newInstance(filename);
231:             if ((propsFile != null) && propsFile.canRead()) {
232:             return propsFile;
233:             }
234:             return null;
235:             }
236:             */
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.