Author: vhennebert
Date: Thu Jul 10 17:04:01 2014
New Revision: 1609507

URL: http://svn.apache.org/r1609507
Log:
If the start/end stop does not coincide with the start/end of the gradient, 
repeat the first/last color

Modified:
    
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
    
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java

Modified: 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java?rev=1609507&r1=1609506&r2=1609507&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
 (original)
+++ 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
 Thu Jul 10 17:04:01 2014
@@ -127,14 +127,6 @@ public class PSSVGGraphics2D extends PSG
         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 PSG
 
 
         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 PSG
             }
             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 PSG
 
         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 PSG
 
             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);

Modified: 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1609507&r1=1609506&r2=1609507&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
 (original)
+++ 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
 Thu Jul 10 17:04:01 2014
@@ -875,6 +875,9 @@ public class PDFGraphics2D extends Abstr
 
             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 Abstr
                 //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 Abstr
             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 Abstr
 
                 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);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to