summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkitfox2012-08-30 22:31:44 +0200
committerkitfox2012-08-30 22:31:44 +0200
commit6f284f4b80e213850225fe85aa1becaa2e27a850 (patch)
tree38aaa465cee41a125ff5e15ad7fabda4080dbb58 /src
parentFixing parsing empty content in style attribute. (diff)
downloadsvg-salamander-core-6f284f4b80e213850225fe85aa1becaa2e27a850.tar.gz
svg-salamander-core-6f284f4b80e213850225fe85aa1becaa2e27a850.tar.xz
svg-salamander-core-6f284f4b80e213850225fe85aa1becaa2e27a850.zip
Can now handle gradients where first and last points are coincident.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@123 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/kitfox/svg/LinearGradient.java23
-rw-r--r--src/main/java/com/kitfox/svg/RadialGradient.java23
2 files changed, 26 insertions, 20 deletions
diff --git a/src/main/java/com/kitfox/svg/LinearGradient.java b/src/main/java/com/kitfox/svg/LinearGradient.java
index 06a1503..81be3d5 100644
--- a/src/main/java/com/kitfox/svg/LinearGradient.java
+++ b/src/main/java/com/kitfox/svg/LinearGradient.java
@@ -27,15 +27,12 @@
package com.kitfox.svg;
-import com.kitfox.svg.xml.StyleAttribute;
import java.awt.geom.*;
import java.awt.*;
import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
//import org.apache.batik.ext.awt.*;
-import com.kitfox.svg.batik.*;
/**
@@ -110,13 +107,19 @@ public class LinearGradient extends Gradient {
break;
}
- com.kitfox.svg.batik.LinearGradientPaint paint;
- if (gradientUnits == GU_USER_SPACE_ON_USE)
+ Paint paint;
+ Point2D.Float pt1 = new Point2D.Float(x1, y1);
+ Point2D.Float pt2 = new Point2D.Float(x2, y2);
+ if (pt1.equals(pt2))
+ {
+ Color[] colors = getStopColors();
+ paint = colors.length > 0 ? colors[0] : Color.black;
+ }
+ else if (gradientUnits == GU_USER_SPACE_ON_USE)
{
-// paint = new LinearGradientPaint(x1, y1, x2, y2, getStopFractions(), getStopColors(), method);
paint = new com.kitfox.svg.batik.LinearGradientPaint(
- new Point2D.Float(x1, y1),
- new Point2D.Float(x2, y2),
+ pt1,
+ pt2,
getStopFractions(),
getStopColors(),
method,
@@ -138,8 +141,8 @@ public class LinearGradient extends Gradient {
viewXform.concatenate(gradientTransform);
paint = new com.kitfox.svg.batik.LinearGradientPaint(
- new Point2D.Float(x1, y1),
- new Point2D.Float(x2, y2),
+ pt1,
+ pt2,
getStopFractions(),
getStopColors(),
method,
diff --git a/src/main/java/com/kitfox/svg/RadialGradient.java b/src/main/java/com/kitfox/svg/RadialGradient.java
index 37b9414..6f6c23f 100644
--- a/src/main/java/com/kitfox/svg/RadialGradient.java
+++ b/src/main/java/com/kitfox/svg/RadialGradient.java
@@ -27,15 +27,12 @@
package com.kitfox.svg;
-import com.kitfox.svg.xml.StyleAttribute;
import java.awt.geom.*;
import java.awt.*;
import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
//import org.apache.batik.ext.awt.*;
-import com.kitfox.svg.batik.*;
/**
@@ -116,14 +113,20 @@ public class RadialGradient extends Gradient {
break;
}
- com.kitfox.svg.batik.RadialGradientPaint paint;
-
- if (gradientUnits == GU_USER_SPACE_ON_USE)
+ Paint paint;
+ Point2D.Float pt1 = new Point2D.Float(cx, cy);
+ Point2D.Float pt2 = new Point2D.Float(fx, fy);
+ if (pt1.equals(pt2))
+ {
+ Color[] colors = getStopColors();
+ paint = colors.length > 0 ? colors[0] : Color.black;
+ }
+ else if (gradientUnits == GU_USER_SPACE_ON_USE)
{
paint = new com.kitfox.svg.batik.RadialGradientPaint(
- new Point2D.Float(cx, cy),
+ pt1,
r,
- new Point2D.Float(fx, fy),
+ pt2,
getStopFractions(),
getStopColors(),
method,
@@ -139,9 +142,9 @@ public class RadialGradient extends Gradient {
viewXform.concatenate(gradientTransform);
paint = new com.kitfox.svg.batik.RadialGradientPaint(
- new Point2D.Float(cx, cy),
+ pt1,
r,
- new Point2D.Float(fx, fy),
+ pt2,
getStopFractions(),
getStopColors(),
method,