From 1e649a305c5e55904afffcde5e55519d9e486f68 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 23 Apr 2010 14:39:20 +0000 Subject: [PATCH] Improved painting of double rules a bit, fixing a bug causing the message: "Invalid axis rule: unable to draw line" git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@937315 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/afp/AFPBorderPainter.java | 18 ++++++++++++++---- .../org/apache/fop/afp/AFPLineDataInfo.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java index 4c56c0def..85046dbed 100644 --- a/src/java/org/apache/fop/afp/AFPBorderPainter.java +++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java @@ -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; diff --git a/src/java/org/apache/fop/afp/AFPLineDataInfo.java b/src/java/org/apache/fop/afp/AFPLineDataInfo.java index f3acf4f71..a056ebf1f 100644 --- a/src/java/org/apache/fop/afp/AFPLineDataInfo.java +++ b/src/java/org/apache/fop/afp/AFPLineDataInfo.java @@ -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 * -- 2.39.5