Source Code Cross Referenced for SVGRadialGradientElementBridge.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 java.awt.Color;
022:        import java.awt.Paint;
023:        import java.awt.geom.AffineTransform;
024:        import java.awt.geom.Point2D;
025:
026:        import org.apache.batik.ext.awt.MultipleGradientPaint;
027:        import org.apache.batik.ext.awt.RadialGradientPaint;
028:        import org.apache.batik.gvt.GraphicsNode;
029:        import org.w3c.dom.Element;
030:
031:        /**
032:         * Bridge class for the <radialGradient> element.
033:         *
034:         * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
035:         * @version $Id: SVGRadialGradientElementBridge.java 475477 2006-11-15 22:44:28Z cam $
036:         */
037:        public class SVGRadialGradientElementBridge extends
038:                AbstractSVGGradientElementBridge {
039:
040:            /**
041:             * Constructs a new SVGRadialGradientElementBridge.
042:             */
043:            public SVGRadialGradientElementBridge() {
044:            }
045:
046:            /**
047:             * Returns 'radialGradient'.
048:             */
049:            public String getLocalName() {
050:                return SVG_RADIAL_GRADIENT_TAG;
051:            }
052:
053:            /**
054:             * Builds a radial gradient according to the specified parameters.
055:             *
056:             * @param paintElement the element that defines a Paint
057:             * @param paintedElement the element referencing the paint
058:             * @param paintedNode the graphics node on which the Paint will be applied
059:             * @param spreadMethod the spread method
060:             * @param colorSpace the color space (sRGB | LinearRGB)
061:             * @param transform the gradient transform
062:             * @param colors the colors of the gradient
063:             * @param offsets the offsets
064:             * @param ctx the bridge context to use
065:             */
066:            protected Paint buildGradient(Element paintElement,
067:                    Element paintedElement, GraphicsNode paintedNode,
068:                    MultipleGradientPaint.CycleMethodEnum spreadMethod,
069:                    MultipleGradientPaint.ColorSpaceEnum colorSpace,
070:                    AffineTransform transform, Color[] colors, float[] offsets,
071:                    BridgeContext ctx) {
072:
073:                // 'cx' attribute - default is 50%
074:                String cxStr = SVGUtilities.getChainableAttributeNS(
075:                        paintElement, null, SVG_CX_ATTRIBUTE, ctx);
076:                if (cxStr.length() == 0) {
077:                    cxStr = SVG_RADIAL_GRADIENT_CX_DEFAULT_VALUE;
078:                }
079:
080:                // 'cy' attribute - default is 50%
081:                String cyStr = SVGUtilities.getChainableAttributeNS(
082:                        paintElement, null, SVG_CY_ATTRIBUTE, ctx);
083:                if (cyStr.length() == 0) {
084:                    cyStr = SVG_RADIAL_GRADIENT_CY_DEFAULT_VALUE;
085:                }
086:
087:                // 'r' attribute - default is 50%
088:                String rStr = SVGUtilities.getChainableAttributeNS(
089:                        paintElement, null, SVG_R_ATTRIBUTE, ctx);
090:                if (rStr.length() == 0) {
091:                    rStr = SVG_RADIAL_GRADIENT_R_DEFAULT_VALUE;
092:                }
093:
094:                // 'fx' attribute - default is same as cx
095:                String fxStr = SVGUtilities.getChainableAttributeNS(
096:                        paintElement, null, SVG_FX_ATTRIBUTE, ctx);
097:                if (fxStr.length() == 0) {
098:                    fxStr = cxStr;
099:                }
100:
101:                // 'fy' attribute - default is same as cy
102:                String fyStr = SVGUtilities.getChainableAttributeNS(
103:                        paintElement, null, SVG_FY_ATTRIBUTE, ctx);
104:                if (fyStr.length() == 0) {
105:                    fyStr = cyStr;
106:                }
107:
108:                // 'gradientUnits' attribute - default is objectBoundingBox
109:                short coordSystemType;
110:                String s = SVGUtilities.getChainableAttributeNS(paintElement,
111:                        null, SVG_GRADIENT_UNITS_ATTRIBUTE, ctx);
112:                if (s.length() == 0) {
113:                    coordSystemType = SVGUtilities.OBJECT_BOUNDING_BOX;
114:                } else {
115:                    coordSystemType = SVGUtilities.parseCoordinateSystem(
116:                            paintElement, SVG_GRADIENT_UNITS_ATTRIBUTE, s, ctx);
117:                }
118:
119:                // additional transform to move to objectBoundingBox coordinate system
120:                if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX) {
121:                    transform = SVGUtilities.toObjectBBox(transform,
122:                            paintedNode);
123:                }
124:                UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
125:                        paintElement);
126:
127:                float r = SVGUtilities.convertLength(rStr, SVG_R_ATTRIBUTE,
128:                        coordSystemType, uctx);
129:                // A value of zero will cause the area to be painted as a single color
130:                // using the color and opacity of the last gradient stop.
131:                if (r == 0) {
132:                    return colors[colors.length - 1];
133:                } else {
134:                    Point2D c = SVGUtilities.convertPoint(cxStr,
135:                            SVG_CX_ATTRIBUTE, cyStr, SVG_CY_ATTRIBUTE,
136:                            coordSystemType, uctx);
137:
138:                    Point2D f = SVGUtilities.convertPoint(fxStr,
139:                            SVG_FX_ATTRIBUTE, fyStr, SVG_FY_ATTRIBUTE,
140:                            coordSystemType, uctx);
141:
142:                    // <!> FIXME: colorSpace ignored for radial gradient at this time
143:                    return new RadialGradientPaint(c, r, f, offsets, colors,
144:                            spreadMethod, RadialGradientPaint.SRGB, transform);
145:                }
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.