]> source.dussan.org Git - poi.git/commitdiff
Try to avoid error "Start point cannot equalendpoint"
authorDominik Stadler <centic@apache.org>
Wed, 6 Jan 2021 09:10:35 +0000 (09:10 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 6 Jan 2021 09:10:35 +0000 (09:10 +0000)
Happened when trying to apply a gradient to an empty text,
let's use at least 1 gradient step always to avoid this.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885191 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/sl/draw/PathGradientPaint.java

index c7d3cfbb674262404132794339d4f62c04c96851..40c802ccaca35804c855b0a5120e36e5a4da2b66 100644 (file)
@@ -173,7 +173,9 @@ public class PathGradientPaint implements Paint {
                     lower = mid;
                 }
             }
-            return upper;
+
+            // always report at least one gradient step
+            return Math.max(upper, 1);
         }
 
         public WritableRaster createRaster() {