aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2014-07-10 17:04:01 +0000
committerVincent Hennebert <vhennebert@apache.org>2014-07-10 17:04:01 +0000
commit46f24b2b1aca6222f8dc6c2139fe83ee32cc114e (patch)
tree00d140fbfc45475d081966546addc2ca83e4cacc /src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
parent66599dd58aecd3e0e1ee9e889bb12922e43a984f (diff)
downloadxmlgraphics-fop-46f24b2b1aca6222f8dc6c2139fe83ee32cc114e.tar.gz
xmlgraphics-fop-46f24b2b1aca6222f8dc6c2139fe83ee32cc114e.zip
If the start/end stop does not coincide with the start/end of the gradient, repeat the first/last color
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609507 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java')
-rw-r--r--src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
index 1c15e569b..5aca45a10 100644
--- a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
+++ b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
@@ -127,14 +127,6 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
double endX = end.getTranslateX();
double endY = end.getTranslateY();
- double width = endX - startX;
- double height = endY - startY;
-
- startX = startX + width * fractions[0];
- endX = endX - width * (1 - fractions[fractions.length - 1]);
- startY = startY + (height * fractions[0]);
- endY = endY - height * (1 - fractions[fractions.length - 1]);
-
theCoords.add(startX);
theCoords.add(startY);
theCoords.add(endX);
@@ -142,6 +134,9 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
List<Color> someColors = new java.util.ArrayList<Color>();
+ if (fractions[0] > 0f) {
+ someColors.add(cols[0]);
+ }
for (int count = 0; count < cols.length; count++) {
Color c1 = cols[count];
if (c1.getAlpha() != 255) {
@@ -149,10 +144,15 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
}
someColors.add(c1);
}
+ if (fractions[fractions.length - 1] < 1f) {
+ someColors.add(cols[cols.length - 1]);
+ }
List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 1; count < fractions.length - 1; count++) {
+ for (int count = 0; count < fractions.length; count++) {
float offset = fractions[count];
- theBounds.add(Double.valueOf(offset));
+ if (0f < offset && offset < 1f) {
+ theBounds.add(new Double(offset));
+ }
}
PDFDeviceColorSpace colSpace;
colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
@@ -201,13 +201,16 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
theCoords.add(centreX);
theCoords.add(centreY);
- theCoords.add(radius * rgp.getFractions()[0]);
+ theCoords.add(0d);
theCoords.add(focusX);
theCoords.add(focusY);
- theCoords.add(radius * fractions[fractions.length - 1]);
+ theCoords.add(radius);
Color[] cols = rgp.getColors();
List<Color> someColors = new java.util.ArrayList<Color>();
+ if (fractions[0] > 0f) {
+ someColors.add(cols[0]);
+ }
for (int count = 0; count < cols.length; count++) {
Color cc = cols[count];
if (cc.getAlpha() != 255) {
@@ -219,11 +222,16 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
someColors.add(cc);
}
+ if (fractions[fractions.length - 1] < 1f) {
+ someColors.add(cols[cols.length - 1]);
+ }
List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 1; count < fractions.length - 1; count++) {
+ for (int count = 0; count < fractions.length; count++) {
float offset = fractions[count];
- theBounds.add(Double.valueOf(offset));
+ if (0f < offset && offset < 1f) {
+ theBounds.add(new Double(offset));
+ }
}
PDFDeviceColorSpace colSpace;
colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);