Source Code Cross Referenced for SVGFontElementBridge.java in  » Graphic-Library » batik » org » apache » batik » bridge » 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 » Graphic Library » batik » org.apache.batik.bridge 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.bridge;
020:
021:        import org.apache.batik.gvt.text.ArabicTextHandler;
022:        import org.apache.batik.gvt.font.GVTFontFace;
023:        import org.w3c.dom.Element;
024:        import org.w3c.dom.NodeList;
025:
026:        /**
027:         * Bridge class for the <font> element.
028:         *
029:         * @author <a href="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
030:         * @version $Id: SVGFontElementBridge.java 475685 2006-11-16 11:16:05Z cam $
031:         */
032:        public class SVGFontElementBridge extends AbstractSVGBridge {
033:
034:            /**
035:             * Constructs a new bridge for the &lt;font> element.
036:             */
037:            public SVGFontElementBridge() {
038:            }
039:
040:            /**
041:             * Returns 'font'.
042:             */
043:            public String getLocalName() {
044:                return SVG_FONT_TAG;
045:            }
046:
047:            /**
048:             * Constructs a new SVGGVTFont that represents the specified &lt;font> element
049:             * at the requested size.
050:             *
051:             * @param ctx The current bridge context.
052:             * @param fontElement The font element to base the SVGGVTFont construction on.
053:             * @param textElement The text element that will use the new font.
054:             * @param size The size of the new font.
055:             * @param fontFace The font face object that contains the font attributes.
056:             *
057:             * @return The new SVGGVTFont.
058:             */
059:            public SVGGVTFont createFont(BridgeContext ctx,
060:                    Element fontElement, Element textElement, float size,
061:                    GVTFontFace fontFace) {
062:
063:                // construct a list of glyph codes that this font can display and
064:                // a list of the glyph elements
065:                NodeList glyphElements = fontElement.getElementsByTagNameNS(
066:                        SVG_NAMESPACE_URI, SVG_GLYPH_TAG);
067:                int numGlyphs = glyphElements.getLength();
068:                String[] glyphCodes = new String[numGlyphs];
069:                String[] glyphNames = new String[numGlyphs];
070:                String[] glyphLangs = new String[numGlyphs];
071:                String[] glyphOrientations = new String[numGlyphs];
072:                String[] glyphForms = new String[numGlyphs];
073:                Element[] glyphElementArray = new Element[numGlyphs];
074:
075:                for (int i = 0; i < numGlyphs; i++) {
076:                    Element glyphElement = (Element) glyphElements.item(i);
077:                    glyphCodes[i] = glyphElement.getAttributeNS(null,
078:                            SVG_UNICODE_ATTRIBUTE);
079:                    if (glyphCodes[i].length() > 1) {
080:                        // ligature, may need to reverse if arabic so that it is in visual order
081:                        if (ArabicTextHandler.arabicChar(glyphCodes[i]
082:                                .charAt(0))) {
083:                            glyphCodes[i] = (new StringBuffer(glyphCodes[i]))
084:                                    .reverse().toString();
085:                        }
086:                    }
087:                    glyphNames[i] = glyphElement.getAttributeNS(null,
088:                            SVG_GLYPH_NAME_ATTRIBUTE);
089:                    glyphLangs[i] = glyphElement.getAttributeNS(null,
090:                            SVG_LANG_ATTRIBUTE);
091:                    glyphOrientations[i] = glyphElement.getAttributeNS(null,
092:                            SVG_ORIENTATION_ATTRIBUTE);
093:                    glyphForms[i] = glyphElement.getAttributeNS(null,
094:                            SVG_ARABIC_FORM_ATTRIBUTE);
095:                    glyphElementArray[i] = glyphElement;
096:                }
097:
098:                // get the missing glyph element
099:                NodeList missingGlyphElements = fontElement
100:                        .getElementsByTagNameNS(SVG_NAMESPACE_URI,
101:                                SVG_MISSING_GLYPH_TAG);
102:                Element missingGlyphElement = null;
103:                if (missingGlyphElements.getLength() > 0) {
104:                    missingGlyphElement = (Element) missingGlyphElements
105:                            .item(0);
106:                }
107:
108:                // get the hkern elements
109:                NodeList hkernElements = fontElement.getElementsByTagNameNS(
110:                        SVG_NAMESPACE_URI, SVG_HKERN_TAG);
111:                Element[] hkernElementArray = new Element[hkernElements
112:                        .getLength()];
113:
114:                for (int i = 0; i < hkernElementArray.length; i++) {
115:                    Element hkernElement = (Element) hkernElements.item(i);
116:                    hkernElementArray[i] = hkernElement;
117:                }
118:
119:                // get the vkern elements
120:                NodeList vkernElements = fontElement.getElementsByTagNameNS(
121:                        SVG_NAMESPACE_URI, SVG_VKERN_TAG);
122:                Element[] vkernElementArray = new Element[vkernElements
123:                        .getLength()];
124:
125:                for (int i = 0; i < vkernElementArray.length; i++) {
126:                    Element vkernElement = (Element) vkernElements.item(i);
127:                    vkernElementArray[i] = vkernElement;
128:                }
129:
130:                // return the new SVGGVTFont
131:                return new SVGGVTFont(size, fontFace, glyphCodes, glyphNames,
132:                        glyphLangs, glyphOrientations, glyphForms, ctx,
133:                        glyphElementArray, missingGlyphElement,
134:                        hkernElementArray, vkernElementArray, textElement);
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.