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


001:        /*
002:         * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.java2d.pipe;
027:
028:        import java.awt.font.FontRenderContext;
029:        import java.awt.font.GlyphVector;
030:        import java.awt.font.TextLayout;
031:        import sun.java2d.SunGraphics2D;
032:        import sun.font.GlyphList;
033:        import sun.awt.SunHints;
034:
035:        import java.awt.Shape;
036:        import java.awt.geom.AffineTransform;
037:        import java.awt.font.TextLayout;
038:
039:        /**
040:         * A delegate pipe of SG2D for drawing "large" text with 
041:         * a solid source colour to an opaque destination.
042:         * The text is drawn as a filled outline.
043:         * Since the developer is not explicitly requesting this way of
044:         * rendering, this should not be used if the current paint is not
045:         * a solid colour.
046:         * 
047:         * If text anti-aliasing is requested by the application, and
048:         * filling path, an anti-aliasing fill pipe needs to
049:         * be invoked.
050:         * This involves making some of the same decisions as in the
051:         * validatePipe call, which may be in a SurfaceData subclass, so
052:         * its awkward to always ensure that the correct pipe is used.
053:         * The easiest thing, rather than reproducing much of that logic
054:         * is to call validatePipe() which works but is expensive, although
055:         * probably not compared to the cost of filling the path.
056:         * Note if AA hint is ON but text-AA hint is OFF this logic will
057:         * produce AA text which perhaps isn't what the user expected.
058:         * Note that the glyphvector obeys its FRC, not the G2D.
059:         */
060:
061:        public class OutlineTextRenderer implements  TextPipe {
062:
063:            // Text with a height greater than the threshhold will be 
064:            // drawn via this pipe.
065:            public static final int THRESHHOLD = 100;
066:
067:            public void drawChars(SunGraphics2D g2d, char data[], int offset,
068:                    int length, int x, int y) {
069:
070:                String s = new String(data, offset, length);
071:                drawString(g2d, s, x, y);
072:            }
073:
074:            public void drawString(SunGraphics2D g2d, String str, double x,
075:                    double y) {
076:
077:                if ("".equals(str)) {
078:                    return; // TextLayout constructor throws IAE on "".
079:                }
080:                TextLayout tl = new TextLayout(str, g2d.getFont(), g2d
081:                        .getFontRenderContext());
082:                Shape s = tl.getOutline(AffineTransform.getTranslateInstance(x,
083:                        y));
084:
085:                int textAAHint = g2d.getFontInfo().aaHint;
086:
087:                int prevaaHint = -1;
088:                if (textAAHint != SunHints.INTVAL_TEXT_ANTIALIAS_OFF
089:                        && g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
090:                    prevaaHint = g2d.antialiasHint;
091:                    g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_ON;
092:                    g2d.validatePipe();
093:                } else if (textAAHint == SunHints.INTVAL_TEXT_ANTIALIAS_OFF
094:                        && g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_OFF) {
095:                    prevaaHint = g2d.antialiasHint;
096:                    g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
097:                    g2d.validatePipe();
098:                }
099:
100:                g2d.fill(s);
101:
102:                if (prevaaHint != -1) {
103:                    g2d.antialiasHint = prevaaHint;
104:                    g2d.validatePipe();
105:                }
106:            }
107:
108:            public void drawGlyphVector(SunGraphics2D g2d, GlyphVector gv,
109:                    float x, float y) {
110:
111:                Shape s = gv.getOutline(x, y);
112:                int prevaaHint = -1;
113:                FontRenderContext frc = gv.getFontRenderContext();
114:                boolean aa = frc.isAntiAliased();
115:
116:                /* aa will be true if any AA mode has been specified.
117:                 * ie for LCD and 'gasp' modes too.
118:                 * We will check if 'gasp' has resolved AA to be "OFF", and
119:                 * in all other cases (ie AA ON and all LCD modes) use AA outlines.
120:                 */
121:                if (aa) {
122:                    if (g2d.getGVFontInfo(gv.getFont(), frc).aaHint == SunHints.INTVAL_TEXT_ANTIALIAS_OFF) {
123:                        aa = false;
124:                    }
125:                }
126:
127:                if (aa && g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
128:                    prevaaHint = g2d.antialiasHint;
129:                    g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_ON;
130:                    g2d.validatePipe();
131:                } else if (!aa
132:                        && g2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_OFF) {
133:                    prevaaHint = g2d.antialiasHint;
134:                    g2d.antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
135:                    g2d.validatePipe();
136:                }
137:
138:                g2d.fill(s);
139:
140:                if (prevaaHint != -1) {
141:                    g2d.antialiasHint = prevaaHint;
142:                    g2d.validatePipe();
143:                }
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.