aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
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
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')
-rw-r--r--src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java36
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java22
2 files changed, 40 insertions, 18 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);
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 42d79a931..c6727057f 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -875,6 +875,9 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
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) {
@@ -884,10 +887,13 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
//PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(),
// c1.getBlue());
someColors.add(c1);
- if (count > 0 && count < cols.length - 1) {
+ if (0f < fractions[count] && fractions[count] < 1f) {
theBounds.add(new Double(fractions[count]));
}
}
+ if (fractions[fractions.length - 1] < 1f) {
+ someColors.add(cols[cols.length - 1]);
+ }
//Gradients are currently restricted to sRGB
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
@@ -948,8 +954,12 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
theCoords.add(new Double(ac.getY()));
theCoords.add(new Double(ar));
+ float[] fractions = rgp.getFractions();
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) {
@@ -958,12 +968,16 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
someColors.add(cc);
}
+ if (fractions[fractions.length - 1] < 1f) {
+ someColors.add(cols[cols.length - 1]);
+ }
- float[] fractions = rgp.getFractions();
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(new Double(offset));
+ if (0f < offset && offset < 1f) {
+ theBounds.add(new Double(offset));
+ }
}
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = (PDFGradientFactory) GradientFactory.newInstance(this);