Changeset 10787 in josm for trunk/src/com/kitfox/svg/RadialGradient.java
- Timestamp:
- 2016-08-12T03:16:58+02:00 (10 years ago)
- File:
-
- 1 edited
-
trunk/src/com/kitfox/svg/RadialGradient.java (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/RadialGradient.java
r8084 r10787 4 4 * All rights reserved. 5 5 * 6 * Redistribution and use in source and binary forms, with or 6 * Redistribution and use in source and binary forms, with or 7 7 * without modification, are permitted provided that the following 8 8 * conditions are met: 9 9 * 10 * - Redistributions of source code must retain the above 10 * - Redistributions of source code must retain the above 11 11 * copyright notice, this list of conditions and the following 12 12 * disclaimer. 13 13 * - Redistributions in binary form must reproduce the above 14 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 15 * disclaimer in the documentation and/or other materials 16 16 * provided with the distribution. 17 17 * … … 27 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 31 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 32 32 * projects can be found at http://www.kitfox.com … … 36 36 package com.kitfox.svg; 37 37 38 import com.kitfox.svg.xml.StyleAttribute; 39 import java.awt.Color; 38 import java.awt.MultipleGradientPaint; 40 39 import java.awt.Paint; 40 import java.awt.RadialGradientPaint; 41 41 import java.awt.geom.AffineTransform; 42 42 import java.awt.geom.Point2D; 43 43 import java.awt.geom.Rectangle2D; 44 import java.util.Arrays; 45 46 import com.kitfox.svg.xml.StyleAttribute; 44 47 45 48 /** … … 53 56 float cx = 0.5f; 54 57 float cy = 0.5f; 55 float fx = 0.5f; 56 float fy = 0.5f; 58 boolean hasFocus = false; 59 float fx = 0f; 60 float fy = 0f; 57 61 float r = 0.5f; 58 62 … … 64 68 } 65 69 70 @Override 66 71 public String getTagName() 67 72 { … … 69 74 } 70 75 76 @Override 71 77 protected void build() throws SVGException 72 78 { … … 85 91 } 86 92 93 hasFocus = false; 87 94 if (getPres(sty.setName("fx"))) 88 95 { 89 96 fx = sty.getFloatValueWithUnits(); 97 hasFocus = true; 90 98 } 91 99 … … 93 101 { 94 102 fy = sty.getFloatValueWithUnits(); 103 hasFocus = true; 95 104 } 96 105 … … 101 110 } 102 111 112 @Override 103 113 public Paint getPaint(Rectangle2D bounds, AffineTransform xform) 104 114 { 105 com.kitfox.svg.batik.MultipleGradientPaint.CycleMethodEnummethod;115 MultipleGradientPaint.CycleMethod method; 106 116 switch (spreadMethod) 107 117 { 108 118 default: 109 119 case SM_PAD: 110 method = com.kitfox.svg.batik.MultipleGradientPaint.NO_CYCLE;120 method = MultipleGradientPaint.CycleMethod.NO_CYCLE; 111 121 break; 112 122 case SM_REPEAT: 113 method = com.kitfox.svg.batik.MultipleGradientPaint.REPEAT;123 method = MultipleGradientPaint.CycleMethod.REPEAT; 114 124 break; 115 125 case SM_REFLECT: 116 method = com.kitfox.svg.batik.MultipleGradientPaint.REFLECT;126 method = MultipleGradientPaint.CycleMethod.REFLECT; 117 127 break; 118 128 } … … 120 130 Paint paint; 121 131 Point2D.Float pt1 = new Point2D.Float(cx, cy); 122 Point2D.Float pt2 = new Point2D.Float(fx, fy); 132 Point2D.Float pt2 = hasFocus ? new Point2D.Float(fx, fy) : pt1; 123 133 if (gradientUnits == GU_USER_SPACE_ON_USE) 124 134 { 125 paint = new com.kitfox.svg.batik.RadialGradientPaint(135 paint = new RadialGradientPaint( 126 136 pt1, 127 137 r, … … 130 140 getStopColors(), 131 141 method, 132 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,142 MultipleGradientPaint.ColorSpaceType.SRGB, 133 143 gradientTransform); 134 144 } else … … 140 150 viewXform.concatenate(gradientTransform); 141 151 142 paint = new com.kitfox.svg.batik.RadialGradientPaint(152 paint = new RadialGradientPaint( 143 153 pt1, 144 154 r, … … 147 157 getStopColors(), 148 158 method, 149 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,159 MultipleGradientPaint.ColorSpaceType.SRGB, 150 160 viewXform); 151 161 } … … 161 171 * update 162 172 */ 173 @Override 163 174 public boolean updateTime(double curTime) throws SVGException 164 175 {
Note:
See TracChangeset
for help on using the changeset viewer.
