aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-04-10 10:42:58 +0000
committerJeremias Maerki <jeremias@apache.org>2006-04-10 10:42:58 +0000
commit58c137a7e685be701c9df214309aa81be9e9128a (patch)
tree7e6d0c2c76881df1f59cd70eb31036beac959539
parent82b2e14a9784f581ab227744bd74f65af10eb7a1 (diff)
downloadxmlgraphics-fop-58c137a7e685be701c9df214309aa81be9e9128a.tar.gz
xmlgraphics-fop-58c137a7e685be701c9df214309aa81be9e9128a.zip
Bugzilla #39033:
Enancement: convert java.awt.GradientPaint to Batik's LinearGradientPaint to avoid rasterization when painting. This is useful when someone uses PDFGraphics2D outside FOP. Submitted by: Michal Sevcenko <sevcenko.at.vc.cvut.cz> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@392917 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 16c3573cb..1709caba7 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -60,6 +60,7 @@ import java.awt.Color;
import java.awt.GraphicsConfiguration;
/* java.awt.Font is not imported to avoid confusion with
org.apache.fop.fonts.Font */
+import java.awt.GradientPaint;
import java.awt.Image;
import java.awt.Shape;
import java.awt.Stroke;
@@ -852,6 +853,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
*
* @param paint the paint to convert to PDF
* @param fill true if the paint should be set for filling
+ * @return true if the paint is handled natively, false if the paint should be rasterized
*/
protected boolean applyPaint(Paint paint, boolean fill) {
preparePainting();
@@ -859,6 +861,18 @@ public class PDFGraphics2D extends AbstractGraphics2D {
if (paint instanceof Color) {
return true;
}
+ // convert java.awt.GradientPaint to LinearGradientPaint to avoid rasterization
+ if (paint instanceof GradientPaint) {
+ GradientPaint gpaint = (GradientPaint) paint;
+ paint = new LinearGradientPaint(
+ (float) gpaint.getPoint1().getX(),
+ (float) gpaint.getPoint1().getY(),
+ (float) gpaint.getPoint2().getX(),
+ (float) gpaint.getPoint2().getY(),
+ new float[] {0, 1},
+ new Color[] {gpaint.getColor1(), gpaint.getColor2()},
+ gpaint.isCyclic() ? LinearGradientPaint.REPEAT : LinearGradientPaint.NO_CYCLE);
+ }
if (paint instanceof LinearGradientPaint) {
LinearGradientPaint gp = (LinearGradientPaint)paint;