Author: gadams
Date: Sun Nov  9 08:12:42 2014
New Revision: 1637637

URL: http://svn.apache.org/r1637637
Log:
Enable new background-padding property.

Modified:
    
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java

Modified: 
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java?rev=1637637&r1=1637636&r2=1637637&view=diff
==============================================================================
--- 
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
 (original)
+++ 
xmlgraphics/batik/branches/text-background/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
 Sun Nov  9 08:12:42 2014
@@ -887,10 +887,10 @@ public class StrokingTextPainter extends
                     BackgroundMode mode = tpi.backgroundMode;
                     if (paint != null) {
                         if ((paint instanceof Color) && 
(((Color)paint).getAlpha() != 0)) {
-                            float[] padding = (float[]) 
textAttributes.get(BACKGROUND_PADDING);
                             Rectangle2D bounds = computeBackgroundBounds(node, 
textRuns, mode);
                             if (!bounds.isEmpty()) {
                                 g2d.setPaint(paint);
+                                adjustForPadding(bounds, (float[]) 
textAttributes.get(BACKGROUND_PADDING));
                                 g2d.fill(bounds);
                             }
                         }
@@ -961,10 +961,11 @@ public class StrokingTextPainter extends
                                                 p.append(bRun, false);
                                             }
                                         }
-                                        Rectangle2D b = p.getBounds2D();
-                                        if (!b.isEmpty()) {
+                                        Rectangle2D bounds = p.getBounds2D();
+                                        if (!bounds.isEmpty()) {
                                             g2d.setPaint(paint);
-                                            g2d.fill(b);
+                                            adjustForPadding(bounds, (float[]) 
runaci.getAttribute(BACKGROUND_PADDING));
+                                            g2d.fill(bounds);
                                         }
                                     }
                                 }
@@ -1011,6 +1012,20 @@ public class StrokingTextPainter extends
         return new Rectangle2D.Double(x, y, w, h);
     }
 
+    private void adjustForPadding(Rectangle2D b, float[] padding) {
+        if (padding != null) {
+            double x = b.getX();
+            double y = b.getY();
+            double w = b.getWidth();
+            double h = b.getHeight();
+            x -= padding[3];
+            y -= padding[0];
+            w += padding[1] + padding[3];
+            h += padding[0] + padding[2];
+            b.setFrame(x, y, w, h);
+        }
+    }
+
     /**
      * Paints decorations of the specified type.
      */


Reply via email to