Source Code Cross Referenced for UserAgent.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » designer » cssengine » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.designer.cssengine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        /*
042:
043:         ============================================================================
044:         The Apache Software License, Version 1.1
045:         ============================================================================
046:
047:         Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
048:
049:         Redistribution and use in source and binary forms, with or without modifica-
050:         tion, are permitted provided that the following conditions are met:
051:
052:         1. Redistributions of  source code must  retain the above copyright  notice,
053:         this list of conditions and the following disclaimer.
054:
055:         2. Redistributions in binary form must reproduce the above copyright notice,
056:         this list of conditions and the following disclaimer in the documentation
057:         and/or other materials provided with the distribution.
058:
059:         3. The end-user documentation included with the redistribution, if any, must
060:         include  the following  acknowledgment:  "This product includes  software
061:         developed  by the  Apache Software Foundation  (http://www.apache.org/)."
062:         Alternately, this  acknowledgment may  appear in the software itself,  if
063:         and wherever such third-party acknowledgments normally appear.
064:
065:         4. The names "Batik" and  "Apache Software Foundation" must  not  be
066:         used to  endorse or promote  products derived from  this software without
067:         prior written permission. For written permission, please contact
068:         apache@apache.org.
069:
070:         5. Products  derived from this software may not  be called "Apache", nor may
071:         "Apache" appear  in their name,  without prior written permission  of the
072:         Apache Software Foundation.
073:
074:         THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
075:         INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
076:         FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
077:         APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
078:         INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
079:         DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
080:         OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
081:         ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
082:         (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
083:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
084:
085:         This software  consists of voluntary contributions made  by many individuals
086:         on  behalf of the Apache Software  Foundation. For more  information on the
087:         Apache Software Foundation, please see <http://www.apache.org/>.
088:
089:         */
090:        //package org.apache.batik.swing.svg;
091:        package org.netbeans.modules.visualweb.designer.cssengine;
092:
093:        import org.netbeans.modules.visualweb.spi.designer.cssengine.CssUserAgentInfo;
094:        import java.awt.geom.Dimension2D;
095:        import java.net.URL;
096:
097:        import org.apache.batik.css.engine.CSSEngineUserAgent;
098:        import org.openide.DialogDisplayer;
099:        import org.openide.ErrorManager;
100:        import org.openide.NotifyDescriptor;
101:        import org.w3c.dom.Document;
102:        import org.w3c.dom.DocumentFragment;
103:        import org.w3c.dom.Element;
104:
105:        /**
106:         * Represents the user agent, for computing things like dpi etc.
107:         * Some of this code was copied or derived from Batik's JSVGComponent class,
108:         * so I've left the Batik copyright on the file.
109:         *
110:         * XXX This should represent the designer, so the impl should delegate there,
111:         * probably via the <code>CssUserAgentInfo</code>.
112:         *
113:         * @author Tor Norbye
114:         * @author Peter Zavadsky (the CssUserAgentInfo stuff)
115:         */
116:        public class UserAgent implements  CSSEngineUserAgent {
117:
118:            private final CssUserAgentInfo userAgentInfo;
119:
120:            public UserAgent(CssUserAgentInfo userAgentInfo) {
121:                this .userAgentInfo = userAgentInfo;
122:            }
123:
124:            /**
125:             * Returns the default size of the viewport of this user agent (0, 0).
126:             */
127:            public Dimension2D getViewportSize() {
128:                throw new RuntimeException("Not yet implemented");
129:
130:                //return getSize();
131:            }
132:
133:            /**
134:             * Displays an error message in the User Agent interface.
135:             */
136:            public void displayError(String message) {
137:                ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL,
138:                        message);
139:            }
140:
141:            /**
142:             * Displays an error resulting from the specified Exception.
143:             */
144:            public void displayError(Exception ex) {
145:                ErrorManager.getDefault()
146:                        .notify(ErrorManager.INFORMATIONAL, ex);
147:            }
148:
149:            /**
150:             * Displays a message in the User Agent interface.
151:             */
152:            public void displayMessage(String message) {
153:                ErrorManager.getDefault().log(ErrorManager.USER, message);
154:            }
155:
156:            /**
157:             * Shows an alert dialog box.
158:             */
159:            public void showAlert(String message) {
160:                DialogDisplayer.getDefault().notify(
161:                        new NotifyDescriptor.Message(message,
162:                                NotifyDescriptor.WARNING_MESSAGE));
163:            }
164:
165:            /**
166:             * Shows a prompt dialog box.
167:             */
168:            public String showPrompt(String message) {
169:                // XXX TODO Not Yet Implemented!
170:                Thread.dumpStack();
171:
172:                return "";
173:            }
174:
175:            /**
176:             * Shows a prompt dialog box.
177:             */
178:            public String showPrompt(String message, String defaultValue) {
179:                // XXX TODO Not Yet Implemented!
180:                Thread.dumpStack();
181:
182:                return defaultValue;
183:            }
184:
185:            /**
186:             * Shows a confirm dialog box.
187:             */
188:            public boolean showConfirm(String message) {
189:                // XXX TODO Not Yet Implemented!
190:                Thread.dumpStack();
191:
192:                return false;
193:            }
194:
195:            /**
196:             * Returns the size of a px CSS unit in millimeters.
197:             */
198:            public float getPixelUnitToMillimeter() {
199:                return 0.264583333333333333333f; // 96 dpi
200:            }
201:
202:            /**
203:             * Returns the size of a px CSS unit in millimeters.
204:             * This will be removed after next release.
205:             * @see #getPixelUnitToMillimeter()
206:             */
207:            public float getPixelToMM() {
208:                return getPixelUnitToMillimeter();
209:            }
210:
211:            /**
212:             * Returns the default font family.
213:             */
214:            public String getDefaultFontFamily() {
215:                return "Arial, Helvetica, sans-serif";
216:            }
217:
218:            /**
219:             * Returns the  medium font size.
220:             */
221:            public float getMediumFontSize() {
222:                // 9pt (72pt = 1in)
223:                //        return (9f * 25.4f) / (72f * getPixelUnitToMillimeter());
224:                // #6477752 The default font size could be adjusted.
225:                return userAgentInfo.getDefaultFontSize();
226:            }
227:
228:            /**
229:             * Returns a lighter font-weight.
230:             */
231:            public float getLighterFontWeight(float f) {
232:                // Round f to nearest 100...
233:                int weight = ((int) ((f + 50) / 100)) * 100;
234:
235:                switch (weight) {
236:                case 100:
237:                    return 100;
238:
239:                case 200:
240:                    return 100;
241:
242:                case 300:
243:                    return 200;
244:
245:                case 400:
246:                    return 300;
247:
248:                case 500:
249:                    return 400;
250:
251:                case 600:
252:                    return 400;
253:
254:                case 700:
255:                    return 400;
256:
257:                case 800:
258:                    return 400;
259:
260:                case 900:
261:                    return 400;
262:
263:                default:
264:                    throw new IllegalArgumentException("Bad Font Weight: " + f);
265:                }
266:            }
267:
268:            /**
269:             * Returns a bolder font-weight.
270:             */
271:            public float getBolderFontWeight(float f) {
272:                // Round f to nearest 100...
273:                int weight = ((int) ((f + 50) / 100)) * 100;
274:
275:                switch (weight) {
276:                case 100:
277:                    return 600;
278:
279:                case 200:
280:                    return 600;
281:
282:                case 300:
283:                    return 600;
284:
285:                case 400:
286:                    return 600;
287:
288:                case 500:
289:                    return 600;
290:
291:                case 600:
292:                    return 700;
293:
294:                case 700:
295:                    return 800;
296:
297:                case 800:
298:                    return 900;
299:
300:                case 900:
301:                    return 900;
302:
303:                default:
304:                    throw new IllegalArgumentException("Bad Font Weight: " + f);
305:                }
306:            }
307:
308:            /**
309:             * Returns the language settings.
310:             */
311:            public String getLanguages() {
312:                return "en";
313:            }
314:
315:            /**
316:             * Returns the user stylesheet uri.
317:             * @return null if no user style sheet was specified.
318:             */
319:            public String getUserStyleSheetURI() {
320:                return null;
321:            }
322:
323:            /**
324:             * Returns this user agent's CSS media.
325:             */
326:            public String getMedia() {
327:                return "screen";
328:            }
329:
330:            /**
331:             * Returns this user agent's alternate style-sheet title.
332:             */
333:            public String getAlternateStyleSheet() {
334:                return null;
335:            }
336:
337:            String computeFileName(Object location) {
338:                return userAgentInfo.computeFileName(location);
339:            }
340:
341:            int computeLineNumber(Object location, int lineno) {
342:                return userAgentInfo.computeLineNumber(location, lineno);
343:            }
344:
345:            URL getDocumentUrl(Document document) {
346:                if (document == null) {
347:                    return null;
348:                }
349:                return userAgentInfo.getDocumentUrl(document);
350:            }
351:
352:            void displayErrorForLocation(String message, Object location,
353:                    int lineno, int column) {
354:                userAgentInfo.displayErrorForLocation(message, location,
355:                        lineno, column);
356:            }
357:
358:            Element getHtmlBodyForDocument(Document document) {
359:                return userAgentInfo.getHtmlBodyForDocument(document);
360:            }
361:
362:            DocumentFragment getHtmlDomFragmentForDocument(Document document) {
363:                return userAgentInfo.getHtmlDomFragmentForDocument(document);
364:            }
365:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.