]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Improved painting of double rules a bit, fixing a bug causing the message: "Invalid...
authorJeremias Maerki <jeremias@apache.org>
Fri, 23 Apr 2010 14:39:20 +0000 (14:39 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 23 Apr 2010 14:39:20 +0000 (14:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@937315 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/afp/AFPBorderPainter.java
src/java/org/apache/fop/afp/AFPLineDataInfo.java

index 4c56c0def3d190f52d90d1dde102d0ae5f4ccc18..85046dbed3fc4735283652c565404a424e43232a 100644 (file)
@@ -91,26 +91,36 @@ public class AFPBorderPainter extends AbstractAFPPainter {
         lineDataInfo.setRotation(paintingState.getRotation());
         lineDataInfo.x1 = Math.round(x1);
         lineDataInfo.y1 = Math.round(y1);
+        float thickness;
         if (borderPaintInfo.isHorizontal()) {
-            lineDataInfo.setThickness(Math.round(y2 - y1));
+            thickness = y2 - y1;
         } else {
-            lineDataInfo.setThickness(Math.round(x2 - x1));
+            thickness = x2 - x1;
         }
+        lineDataInfo.setThickness(Math.round(thickness));
 
         // handle border-*-style
         switch (borderPaintInfo.getStyle()) {
         case Constants.EN_DOUBLE:
+            int thickness3 = (int)Math.floor(thickness / 3f);
+            lineDataInfo.setThickness(thickness3);
             if (borderPaintInfo.isHorizontal()) {
                 lineDataInfo.x2 = Math.round(x2);
                 lineDataInfo.y2 = lineDataInfo.y1;
                 dataStream.createLine(lineDataInfo);
-                lineDataInfo.y1 += Math.round((lineDataInfo.thickness / 3) * 2);
+                int distance = thickness3 * 2;
+                lineDataInfo = new AFPLineDataInfo(lineDataInfo);
+                lineDataInfo.y1 += distance;
+                lineDataInfo.y2 += distance;
                 dataStream.createLine(lineDataInfo);
             } else {
                 lineDataInfo.x2 = lineDataInfo.x1;
                 lineDataInfo.y2 = Math.round(y2);
                 dataStream.createLine(lineDataInfo);
-                lineDataInfo.x1 += Math.round((lineDataInfo.thickness / 3) * 2);
+                int distance = thickness3 * 2;
+                lineDataInfo = new AFPLineDataInfo(lineDataInfo);
+                lineDataInfo.x1 += distance;
+                lineDataInfo.x2 += distance;
                 dataStream.createLine(lineDataInfo);
             }
             break;
index f3acf4f71171c827a134cd8eb1c1e4a9132d6b58..a056ebf1fc74612ace0b356193f12ff6131ead36 100644 (file)
@@ -51,6 +51,20 @@ public class AFPLineDataInfo {
     public AFPLineDataInfo() {
     }
 
+    /**
+     * Copy constructor.
+     * @param template the object to copy
+     */
+    public AFPLineDataInfo(AFPLineDataInfo template) {
+        this.x1 = template.x1;
+        this.y1 = template.y1;
+        this.x2 = template.x2;
+        this.y2 = template.y2;
+        this.thickness = template.thickness;
+        this.color = template.color;
+        this.rotation = template.rotation;
+    }
+
     /**
      * Returns the X1 coordinate
      *