You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/20 22:47:35 UTC

svn commit: r687455 - in /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src: java/org/apache/fop/render/intermediate/ java/org/apache/fop/render/pdf/ java/org/apache/fop/traits/ sandbox/org/apache/fop/render/svg/

Author: jeremias
Date: Wed Aug 20 13:47:34 2008
New Revision: 687455

URL: http://svn.apache.org/viewvc?rev=687455&view=rev
Log:
Added support for painting leaders (implemented as drawLine in IFPainter).
Removed unused "stroke" parameter in drawRect and renamed the method to fillRect.

Added:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java   (with props)
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java   (with props)
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/BorderPainter.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFPainter.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderProps.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/AbstractSVGPainter.java

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/BorderPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/BorderPainter.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/BorderPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/BorderPainter.java Wed Aug 20 13:47:34 2008
@@ -20,9 +20,11 @@
 package org.apache.fop.render.intermediate;
 
 import java.awt.Color;
+import java.awt.Point;
 import java.awt.Rectangle;
 
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 
 /**
  * This is an abstract base class for handling border painting.
@@ -198,7 +200,10 @@
 
 
     protected abstract void drawBorderLine(int x1, int y1, int x2, int y2,
-            boolean horz, boolean startOrBefore, int style, Color col);
+            boolean horz, boolean startOrBefore, int style, Color color);
+
+    public abstract void drawLine(Point start, Point end,
+            int width, Color color, RuleStyle style);
 
     protected abstract void moveTo(int x, int y);
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java Wed Aug 20 13:47:34 2008
@@ -46,6 +46,7 @@
     String EL_IMAGE = "image";
     String EL_CLIP_RECT = "clip-rect";
     String EL_RECT = "rect";
+    String EL_LINE = "line";
     String EL_BORDER_RECT = "border-rect";
     String EL_FONT = "font";
     String EL_TEXT = "text";

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java Wed Aug 20 13:47:34 2008
@@ -22,6 +22,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Paint;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.util.Map;
@@ -33,6 +34,7 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 
 /**
  * Interface used to paint whole documents layouted by Apache FOP.
@@ -277,13 +279,12 @@
     //TODO clipRect() shall be considered temporary until verified with SVG and PCL
 
     /**
-     * Draws a rectangle. Either fill or stroke has to be specified.
+     * Fills a rectangular area.
      * @param rect the rectangle's coordinates and extent
-     * @param fill the fill paint (may be null)
-     * @param stroke the stroke color (may be null)
+     * @param fill the fill paint
      * @throws IFException if an error occurs while handling this event
      */
-    void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException;
+    void fillRect(Rectangle rect, Paint fill) throws IFException;
 
     /**
      * Draws a border rectangle. The border segments are specified through {@code BorderProps}
@@ -300,6 +301,18 @@
             BorderProps start, BorderProps end) throws IFException;
 
     /**
+     * Draws a line. NOTE: Currently, only horizontal lines are implemented!
+     * @param start the start point of the line
+     * @param end the end point of the line
+     * @param width the line width
+     * @param color the line color
+     * @param style the line style (using the Constants.EN_* constants for the rule-style property)
+     * @throws IFException if an error occurs while handling this event
+     */
+    void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+            throws IFException;
+
+    /**
      * Draws an image identified by a URI inside a given rectangle. This is the equivalent to
      * an fo:external-graphic in XSL-FO.
      * @param uri the image's URI

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java Wed Aug 20 13:47:34 2008
@@ -21,6 +21,7 @@
 
 import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.util.Map;
@@ -50,6 +51,7 @@
 import org.apache.fop.fo.ElementMappingRegistry;
 import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.ColorUtil;
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactoryRegistry;
@@ -138,6 +140,7 @@
             elementHandlers.put(EL_TEXT, new TextHandler());
             elementHandlers.put(EL_CLIP_RECT, new ClipRectHandler());
             elementHandlers.put(EL_RECT, new RectHandler());
+            elementHandlers.put(EL_LINE, new LineHandler());
             elementHandlers.put(EL_BORDER_RECT, new BorderRectHandler());
             elementHandlers.put(EL_IMAGE, new ImageHandler());
         }
@@ -467,13 +470,27 @@
                 } catch (PropertyException pe) {
                     throw new IFException("Error parsing the fill attribute", pe);
                 }
-                Color strokeColor;
+                painter.fillRect(new Rectangle(x, y, width, height), fillColor);
+            }
+
+        }
+
+        private class LineHandler extends AbstractElementHandler {
+
+            public void startElement(Attributes attributes) throws IFException {
+                int x1 = Integer.parseInt(attributes.getValue("x1"));
+                int y1 = Integer.parseInt(attributes.getValue("y1"));
+                int x2 = Integer.parseInt(attributes.getValue("x2"));
+                int y2 = Integer.parseInt(attributes.getValue("y2"));
+                int width = Integer.parseInt(attributes.getValue("stroke-width"));
+                Color color;
                 try {
-                    strokeColor = getAttributeAsColor(attributes, "stroke");
+                    color = getAttributeAsColor(attributes, "color");
                 } catch (PropertyException pe) {
-                    throw new IFException("Error parsing the stroke attribute", pe);
+                    throw new IFException("Error parsing the fill attribute", pe);
                 }
-                painter.drawRect(new Rectangle(x, y, width, height), fillColor, strokeColor);
+                RuleStyle style = RuleStyle.valueOf(attributes.getValue("style"));
+                painter.drawLine(new Point(x1, y1), new Point(x2, y2), width, color, style);
             }
 
         }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java Wed Aug 20 13:47:34 2008
@@ -67,6 +67,7 @@
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.Viewport;
@@ -87,6 +88,7 @@
 import org.apache.fop.render.intermediate.extensions.NamedDestination;
 import org.apache.fop.render.pdf.PDFEventProducer;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 
 /**
  * This renderer implementation is an adapter to the {@code IFPainter} interface. It is used
@@ -993,6 +995,30 @@
     }
 
     /** {@inheritDoc} */
+    public void renderLeader(Leader area) {
+        renderInlineAreaBackAndBorders(area);
+
+        int style = area.getRuleStyle();
+        int ruleThickness = area.getRuleThickness();
+        int startx = currentIPPosition + area.getBorderAndPaddingWidthStart();
+        int starty = currentBPPosition + area.getOffset() + (ruleThickness / 2);
+        int endx = currentIPPosition
+                        + area.getBorderAndPaddingWidthStart()
+                        + area.getIPD();
+        Color col = (Color)area.getTrait(Trait.COLOR);
+
+        Point start = new Point(startx, starty);
+        Point end = new Point(endx, starty);
+        try {
+            painter.drawLine(start, end, ruleThickness, col, RuleStyle.valueOf(style));
+        } catch (IFException ife) {
+            handleIFException(ife);
+        }
+
+        super.renderLeader(area);
+    }
+
+    /** {@inheritDoc} */
     protected void clip() {
         throw new IllegalStateException("Not used");
     }
@@ -1048,9 +1074,9 @@
     /** {@inheritDoc} */
     protected void fillRect(float x, float y, float width, float height) {
         try {
-            painter.drawRect(
+            painter.fillRect(
                     toMillipointRectangle(x, y, width, height),
-                    this.graphicContext.getPaint(), null);
+                    this.graphicContext.getPaint());
         } catch (IFException e) {
             handleIFException(e);
         }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java Wed Aug 20 13:47:34 2008
@@ -22,6 +22,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Paint;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.util.Iterator;
@@ -37,6 +38,7 @@
 
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.ColorUtil;
 import org.apache.fop.util.DOM2SAX;
 import org.apache.fop.util.XMLUtil;
@@ -364,8 +366,8 @@
     }
 
     /** {@inheritDoc} */
-    public void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException {
-        if (fill == null && stroke == null) {
+    public void fillRect(Rectangle rect, Paint fill) throws IFException {
+        if (fill == null) {
             return;
         }
         try {
@@ -374,15 +376,10 @@
             addAttribute(atts, "y", Integer.toString(rect.y));
             addAttribute(atts, "width", Integer.toString(rect.width));
             addAttribute(atts, "height", Integer.toString(rect.height));
-            if (fill != null) {
-                addAttribute(atts, "fill", toString(fill));
-            }
-            if (stroke != null) {
-                addAttribute(atts, "stroke", toString(stroke));
-            }
+            addAttribute(atts, "fill", toString(fill));
             element(EL_RECT, atts);
         } catch (SAXException e) {
-            throw new IFException("SAX error in drawRect()", e);
+            throw new IFException("SAX error in fillRect()", e);
         }
     }
 
@@ -417,6 +414,24 @@
     }
 
     /** {@inheritDoc} */
+    public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+            throws IFException {
+        try {
+            AttributesImpl atts = new AttributesImpl();
+            addAttribute(atts, "x1", Integer.toString(start.x));
+            addAttribute(atts, "y1", Integer.toString(start.y));
+            addAttribute(atts, "x2", Integer.toString(end.x));
+            addAttribute(atts, "y2", Integer.toString(end.y));
+            addAttribute(atts, "stroke-width", Integer.toString(width));
+            addAttribute(atts, "color", Integer.toString(width));
+            addAttribute(atts, "style", style.getName());
+            element(EL_LINE, atts);
+        } catch (SAXException e) {
+            throw new IFException("SAX error in drawLine()", e);
+        }
+    }
+
+    /** {@inheritDoc} */
     public void drawText(int x, int y, int[] dx, int[] dy, String text) throws IFException {
         try {
             AttributesImpl atts = new AttributesImpl();

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java Wed Aug 20 13:47:34 2008
@@ -20,6 +20,8 @@
 package org.apache.fop.render.pdf;
 
 import java.awt.Color;
+import java.awt.Point;
+import java.awt.Rectangle;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,6 +29,7 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.render.PrintRenderer;
 import org.apache.fop.render.intermediate.BorderPainter;
+import org.apache.fop.traits.RuleStyle;
 
 /**
  * PDF-specific implementation of the {@code BorderPainter}.
@@ -221,6 +224,65 @@
         }
     }
 
+    /** {@inheritDoc} */
+    public void drawLine(Point start, Point end,
+            int width, Color color, RuleStyle style) {
+        if (start.y != end.y) {
+            //TODO Support arbitrary lines if necessary
+            throw new UnsupportedOperationException(
+                    "Can only deal with horizontal lines right now");
+        }
+
+        saveGraphicsState();
+        int half = width / 2;
+        int starty = start.y - half;
+        Rectangle boundingRect = new Rectangle(start.x, start.y - half, end.x - start.x, width);
+        switch (style.getEnumValue()) {
+        case Constants.EN_SOLID:
+        case Constants.EN_DASHED:
+        case Constants.EN_DOUBLE:
+            drawBorderLine(start.x, start.y - half, end.x, end.y + half,
+                    true, true, style.getEnumValue(), color);
+            break;
+        case Constants.EN_DOTTED:
+            generator.clipRect(boundingRect);
+            //This displaces the dots to the right by half a dot's width
+            //TODO There's room for improvement here
+            generator.add("1 0 0 1 " + format(half) + " 0 cm\n");
+            drawBorderLine(start.x, start.y - half, end.x, end.y + half,
+                    true, true, style.getEnumValue(), color);
+            break;
+        case Constants.EN_GROOVE:
+        case Constants.EN_RIDGE:
+            generator.setColor(PrintRenderer.lightenColor(color, 0.6f), true);
+            generator.add(format(start.x) + " " + format(starty) + " m\n");
+            generator.add(format(end.x) + " " + format(starty) + " l\n");
+            generator.add(format(end.x) + " " + format(starty + 2 * half) + " l\n");
+            generator.add(format(start.x) + " " + format(starty + 2 * half) + " l\n");
+            generator.add("h\n");
+            generator.add("f\n");
+            generator.setColor(color, true);
+            if (style == RuleStyle.GROOVE) {
+                generator.add(format(start.x) + " " + format(starty) + " m\n");
+                generator.add(format(end.x) + " " + format(starty) + " l\n");
+                generator.add(format(end.x) + " " + format(starty + half) + " l\n");
+                generator.add(format(start.x + half) + " " + format(starty + half) + " l\n");
+                generator.add(format(start.x) + " " + format(starty + 2 * half) + " l\n");
+            } else {
+                generator.add(format(end.x) + " " + format(starty) + " m\n");
+                generator.add(format(end.x) + " " + format(starty + 2 * half) + " l\n");
+                generator.add(format(start.x) + " " + format(starty + 2 * half) + " l\n");
+                generator.add(format(start.x) + " " + format(starty + half) + " l\n");
+                generator.add(format(end.x - half) + " " + format(starty + half) + " l\n");
+            }
+            generator.add("h\n");
+            generator.add("f\n");
+            break;
+        default:
+            throw new UnsupportedOperationException("rule style not supported");
+        }
+        restoreGraphicsState();
+    }
 
     static final String format(int coordinate) {
         return format(coordinate / 1000f);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java Wed Aug 20 13:47:34 2008
@@ -20,6 +20,7 @@
 package org.apache.fop.render.pdf;
 
 import java.awt.Color;
+import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -210,6 +211,19 @@
     }
 
     /**
+     * Intersects the current clip region with the given rectangle.
+     * @param rect the clip rectangle
+     */
+    public void clipRect(Rectangle rect) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(format(rect.x / 1000f)).append(' ');
+        sb.append(format(rect.y / 1000f)).append(' ');
+        sb.append(format(rect.width / 1000f)).append(' ');
+        sb.append(format(rect.height / 1000f)).append(" re W n\n");
+        add(sb.toString());
+    }
+
+    /**
      * Adds content to the stream.
      * @param content the PDF content
      */

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFPainter.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFPainter.java Wed Aug 20 13:47:34 2008
@@ -22,6 +22,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Paint;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
@@ -65,6 +66,7 @@
 import org.apache.fop.render.intermediate.extensions.GoToXYAction;
 import org.apache.fop.render.intermediate.extensions.NamedDestination;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.CharUtilities;
 
 /**
@@ -327,17 +329,12 @@
     /** {@inheritDoc} */
     public void clipRect(Rectangle rect) throws IFException {
         generator.endTextObject();
-        StringBuffer sb = new StringBuffer();
-        sb.append(format(rect.x)).append(' ');
-        sb.append(format(rect.y)).append(' ');
-        sb.append(format(rect.width)).append(' ');
-        sb.append(format(rect.height)).append(" re W n\n");
-        generator.add(sb.toString());
+        generator.clipRect(rect);
     }
 
     /** {@inheritDoc} */
-    public void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException {
-        if (fill == null && stroke == null) {
+    public void fillRect(Rectangle rect, Paint fill) throws IFException {
+        if (fill == null) {
             return;
         }
         generator.endTextObject();
@@ -349,9 +346,6 @@
                     throw new UnsupportedOperationException("Non-Color paints NYI");
                 }
             }
-            if (stroke != null) {
-                throw new UnsupportedOperationException("stroke NYI");
-            }
             StringBuffer sb = new StringBuffer();
             sb.append(format(rect.x)).append(' ');
             sb.append(format(rect.y)).append(' ');
@@ -360,9 +354,10 @@
             if (fill != null) {
                 sb.append(" f");
             }
+            /* Removed from method signature as it is currently not used
             if (stroke != null) {
                 sb.append(" S");
-            }
+            }*/
             sb.append('\n');
             generator.add(sb.toString());
         }
@@ -377,6 +372,13 @@
         }
     }
 
+    /** {@inheritDoc} */
+    public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+        throws IFException {
+        generator.endTextObject();
+        this.borderPainter.drawLine(start, end, width, color, style);
+    }
+
     private Typeface getTypeface(String fontName) {
         if (fontName == null) {
             throw new NullPointerException("fontName must not be null");

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java Wed Aug 20 13:47:34 2008
@@ -91,6 +91,7 @@
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.CharUtilities;
 
 /**
@@ -167,6 +168,7 @@
 
     /** The current content generator to produce PDF commands with */
     protected PDFContentGenerator generator;
+    private PDFBorderPainter borderPainter;
 
     /**
      * the current annotation list to add annotations to
@@ -189,6 +191,7 @@
     /** Image handler registry */
     private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry();
 
+
     /**
      * create the PDF renderer
      */
@@ -460,17 +463,8 @@
         pageHeight = (int) h;
 
         this.generator = new PDFContentGenerator(this.pdfDoc, this.ostream, this.currentPage);
-        /*
-        currentStream = this.pdfDoc.getFactory()
-            .makeStream(PDFFilterList.CONTENT_FILTER, false);
-        this.textutil = new PDFTextUtil() {
-            protected void write(String code) {
-                currentStream.add(code);
-            }
-        };
+        this.borderPainter = new PDFBorderPainter(this.generator);
 
-        currentState = new PDFState();
-        */
         // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's
         AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0,
                 pageHeight / 1000f);
@@ -1223,66 +1217,17 @@
     public void renderLeader(Leader area) {
         renderInlineAreaBackAndBorders(area);
 
-        getState().push();
-        saveGraphicsState();
         int style = area.getRuleStyle();
-        float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
-        float starty = (currentBPPosition + area.getOffset()) / 1000f;
-        float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
-                        + area.getIPD()) / 1000f;
-        float ruleThickness = area.getRuleThickness() / 1000f;
+        int ruleThickness = area.getRuleThickness();
+        int startx = currentIPPosition + area.getBorderAndPaddingWidthStart();
+        int starty = currentBPPosition + area.getOffset() + (ruleThickness / 2);
+        int endx = currentIPPosition
+                        + area.getBorderAndPaddingWidthStart()
+                        + area.getIPD();
         Color col = (Color)area.getTrait(Trait.COLOR);
 
-        switch (style) {
-            case EN_SOLID:
-            case EN_DASHED:
-            case EN_DOUBLE:
-                drawBorderLine(startx, starty, endx, starty + ruleThickness,
-                        true, true, style, col);
-                break;
-            case EN_DOTTED:
-                clipRect(startx, starty, endx - startx, ruleThickness);
-                //This displaces the dots to the right by half a dot's width
-                //TODO There's room for improvement here
-                generator.add("1 0 0 1 " + format(ruleThickness / 2) + " 0 cm\n");
-                drawBorderLine(startx, starty, endx, starty + ruleThickness,
-                        true, true, style, col);
-                break;
-            case EN_GROOVE:
-            case EN_RIDGE:
-                float half = area.getRuleThickness() / 2000f;
-
-                generator.setColor(lightenColor(col, 0.6f), true);
-                generator.add(format(startx) + " " + format(starty) + " m\n");
-                generator.add(format(endx) + " " + format(starty) + " l\n");
-                generator.add(format(endx) + " " + format(starty + 2 * half) + " l\n");
-                generator.add(format(startx) + " " + format(starty + 2 * half) + " l\n");
-                generator.add("h\n");
-                generator.add("f\n");
-                generator.setColor(col, true);
-                if (style == EN_GROOVE) {
-                    generator.add(format(startx) + " " + format(starty) + " m\n");
-                    generator.add(format(endx) + " " + format(starty) + " l\n");
-                    generator.add(format(endx) + " " + format(starty + half) + " l\n");
-                    generator.add(format(startx + half) + " " + format(starty + half) + " l\n");
-                    generator.add(format(startx) + " " + format(starty + 2 * half) + " l\n");
-                } else {
-                    generator.add(format(endx) + " " + format(starty) + " m\n");
-                    generator.add(format(endx) + " " + format(starty + 2 * half) + " l\n");
-                    generator.add(format(startx) + " " + format(starty + 2 * half) + " l\n");
-                    generator.add(format(startx) + " " + format(starty + half) + " l\n");
-                    generator.add(format(endx - half) + " " + format(starty + half) + " l\n");
-                }
-                generator.add("h\n");
-                generator.add("f\n");
-                break;
-            default:
-                throw new UnsupportedOperationException("rule style not supported");
-        }
-
-        restoreGraphicsState();
-        getState().pop();
-        beginTextObject();
+        borderPainter.drawLine(new Point(startx, starty), new Point(endx, starty),
+                ruleThickness, col, RuleStyle.valueOf(style));
         super.renderLeader(area);
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderProps.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderProps.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderProps.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderProps.java Wed Aug 20 13:47:34 2008
@@ -25,13 +25,12 @@
 import java.util.regex.Pattern;
 
 import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.util.ColorUtil;
 
 /**
  * Border properties.
- * Class to store border trait propties for the area tree.
+ * Class to store border trait properties for the area tree.
  */
 public class BorderProps implements Serializable {
 
@@ -89,45 +88,11 @@
     }
 
     private String getStyleString() {
-        switch (style) {
-        case Constants.EN_NONE: return "none";
-        case Constants.EN_HIDDEN: return "hidden";
-        case Constants.EN_DOTTED: return "dotted";
-        case Constants.EN_DASHED: return "dashed";
-        case Constants.EN_SOLID: return "solid";
-        case Constants.EN_DOUBLE: return "double";
-        case Constants.EN_GROOVE: return "groove";
-        case Constants.EN_RIDGE: return "ridge";
-        case Constants.EN_INSET: return "inset";
-        case Constants.EN_OUTSET: return "outset";
-        default: throw new IllegalStateException("Illegal border style: " + style);
-        }
+        return BorderStyle.valueOf(style).getName();
     }
 
     private static int getConstantForStyle(String style) {
-        if ("none".equalsIgnoreCase(style)) {
-            return Constants.EN_NONE;
-        } else if ("hidden".equalsIgnoreCase(style)) {
-            return Constants.EN_HIDDEN;
-        } else if ("dotted".equalsIgnoreCase(style)) {
-            return Constants.EN_DOTTED;
-        } else if ("dashed".equalsIgnoreCase(style)) {
-            return Constants.EN_DASHED;
-        } else if ("solid".equalsIgnoreCase(style)) {
-            return Constants.EN_SOLID;
-        } else if ("double".equalsIgnoreCase(style)) {
-            return Constants.EN_DOUBLE;
-        } else if ("groove".equalsIgnoreCase(style)) {
-            return Constants.EN_GROOVE;
-        } else if ("ridge".equalsIgnoreCase(style)) {
-            return Constants.EN_RIDGE;
-        } else if ("inset".equalsIgnoreCase(style)) {
-            return Constants.EN_INSET;
-        } else if ("outset".equalsIgnoreCase(style)) {
-            return Constants.EN_OUTSET;
-        } else {
-            throw new IllegalStateException("Illegal border style: " + style);
-        }
+        return BorderStyle.valueOf(style).getEnumValue();
     }
 
     /** {@inheritDoc} */

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java?rev=687455&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java Wed Aug 20 13:47:34 2008
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.traits;
+
+import java.io.ObjectStreamException;
+
+import org.apache.fop.fo.Constants;
+
+/** Enumeration class for border styles. */
+public final class BorderStyle extends TraitEnum {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String[] BORDER_STYLE_NAMES = new String[]
+            {"none", "hidden", "dotted", "dashed",
+             "solid", "double", "groove", "ridge",
+             "inset", "outset"};
+
+    private static final int[] BORDER_STYLE_VALUES = new int[]
+            {Constants.EN_NONE, Constants.EN_HIDDEN, Constants.EN_DOTTED, Constants.EN_DASHED,
+             Constants.EN_SOLID, Constants.EN_DOUBLE, Constants.EN_GROOVE, Constants.EN_RIDGE,
+             Constants.EN_INSET, Constants.EN_OUTSET};
+
+    /** border-style: none */
+    public static final BorderStyle NONE = new BorderStyle(0);
+    /** border-style: hidden */
+    public static final BorderStyle HIDDEN = new BorderStyle(1);
+    /** border-style: dotted */
+    public static final BorderStyle DOTTED = new BorderStyle(2);
+    /** border-style: dashed */
+    public static final BorderStyle DASHED = new BorderStyle(3);
+    /** border-style: solid */
+    public static final BorderStyle SOLID = new BorderStyle(4);
+    /** border-style: double */
+    public static final BorderStyle DOUBLE = new BorderStyle(5);
+    /** border-style: groove */
+    public static final BorderStyle GROOVE = new BorderStyle(6);
+    /** border-style: ridge */
+    public static final BorderStyle RIDGE = new BorderStyle(7);
+    /** border-style: inset */
+    public static final BorderStyle INSET = new BorderStyle(8);
+    /** border-style: outset */
+    public static final BorderStyle OUTSET = new BorderStyle(9);
+
+    private static final BorderStyle[] STYLES = new BorderStyle[] {
+        NONE, HIDDEN, DOTTED, DASHED, SOLID, DOUBLE, GROOVE, RIDGE, INSET, OUTSET};
+
+    private BorderStyle(int index) {
+        super(BORDER_STYLE_NAMES[index], BORDER_STYLE_VALUES[index]);
+    }
+
+    /**
+     * Returns the enumeration/singleton object based on its name.
+     * @param name the name of the enumeration value
+     * @return the enumeration object
+     */
+    public static BorderStyle valueOf(String name) {
+        for (int i = 0; i < STYLES.length; i++) {
+            if (STYLES[i].getName().equalsIgnoreCase(name)) {
+                return STYLES[i];
+            }
+        }
+        throw new IllegalArgumentException("Illegal border style: " + name);
+    }
+
+    /**
+     * Returns the enumeration/singleton object based on its name.
+     * @param enumValue the enumeration value
+     * @return the enumeration object
+     */
+    public static BorderStyle valueOf(int enumValue) {
+        for (int i = 0; i < STYLES.length; i++) {
+            if (STYLES[i].getEnumValue() == enumValue) {
+                return STYLES[i];
+            }
+        }
+        throw new IllegalArgumentException("Illegal border style: " + enumValue);
+    }
+
+    private Object readResolve() throws ObjectStreamException {
+        return valueOf(getName());
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "BorderStyle:" + getName();
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/BorderStyle.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java?rev=687455&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java Wed Aug 20 13:47:34 2008
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.traits;
+
+import java.io.ObjectStreamException;
+
+import org.apache.fop.fo.Constants;
+
+/** Enumeration class for rule styles. */
+public final class RuleStyle extends TraitEnum {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String[] RULE_STYLE_NAMES = new String[]
+            {"none", "dotted", "dashed",
+             "solid", "double", "groove", "ridge"};
+
+    private static final int[] RULE_STYLE_VALUES = new int[]
+            {Constants.EN_NONE, Constants.EN_DOTTED, Constants.EN_DASHED,
+             Constants.EN_SOLID, Constants.EN_DOUBLE, Constants.EN_GROOVE, Constants.EN_RIDGE};
+
+    /** rule-style: none */
+    public static final RuleStyle NONE = new RuleStyle(0);
+    /** rule-style: dotted */
+    public static final RuleStyle DOTTED = new RuleStyle(1);
+    /** rule-style: dashed */
+    public static final RuleStyle DASHED = new RuleStyle(2);
+    /** rule-style: solid */
+    public static final RuleStyle SOLID = new RuleStyle(3);
+    /** rule-style: double */
+    public static final RuleStyle DOUBLE = new RuleStyle(4);
+    /** rule-style: groove */
+    public static final RuleStyle GROOVE = new RuleStyle(5);
+    /** rule-style: ridge */
+    public static final RuleStyle RIDGE = new RuleStyle(6);
+
+    private static final RuleStyle[] STYLES = new RuleStyle[] {
+        NONE, DOTTED, DASHED, SOLID, DOUBLE, GROOVE, RIDGE};
+
+    private RuleStyle(int index) {
+        super(RULE_STYLE_NAMES[index], RULE_STYLE_VALUES[index]);
+    }
+
+    /**
+     * Returns the enumeration/singleton object based on its name.
+     * @param name the name of the enumeration value
+     * @return the enumeration object
+     */
+    public static RuleStyle valueOf(String name) {
+        for (int i = 0; i < STYLES.length; i++) {
+            if (STYLES[i].getName().equalsIgnoreCase(name)) {
+                return STYLES[i];
+            }
+        }
+        throw new IllegalArgumentException("Illegal rule style: " + name);
+    }
+
+    /**
+     * Returns the enumeration/singleton object based on its name.
+     * @param enumValue the enumeration value
+     * @return the enumeration object
+     */
+    public static RuleStyle valueOf(int enumValue) {
+        for (int i = 0; i < STYLES.length; i++) {
+            if (STYLES[i].getEnumValue() == enumValue) {
+                return STYLES[i];
+            }
+        }
+        throw new IllegalArgumentException("Illegal rule style: " + enumValue);
+    }
+
+    private Object readResolve() throws ObjectStreamException {
+        return valueOf(getName());
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "RuleStyle:" + getName();
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/RuleStyle.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java?rev=687455&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java Wed Aug 20 13:47:34 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.traits;
+
+import java.io.Serializable;
+
+/** Base class for enumeration classes representing traits. */
+public abstract class TraitEnum implements Serializable {
+
+    private String name;
+    private int enumValue;
+
+    /**
+     * Constructor to add a new named item.
+     * @param name Name of the item.
+     * @param enumValue the {@code Constants}.EN_* value
+     */
+    protected TraitEnum(String name, int enumValue) {
+        this.name = name;
+        this.enumValue = enumValue;
+    }
+
+    /**
+     * Returns the name of the enumeration.
+     * @return the name of the enumeration
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * Returns the enumeration value (one of {@code Constants}.EN_*).
+     * @return the enumeration value
+     */
+    public int getEnumValue() {
+        return this.enumValue;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/traits/TraitEnum.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/AbstractSVGPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/AbstractSVGPainter.java?rev=687455&r1=687454&r2=687455&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/AbstractSVGPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/AbstractSVGPainter.java Wed Aug 20 13:47:34 2008
@@ -22,6 +22,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Paint;
+import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.io.FileNotFoundException;
@@ -52,6 +53,7 @@
 import org.apache.fop.render.intermediate.IFException;
 import org.apache.fop.render.intermediate.IFState;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.ColorUtil;
 
 /**
@@ -284,8 +286,8 @@
     }
 
     /** {@inheritDoc} */
-    public void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException {
-        if (fill == null && stroke == null) {
+    public void fillRect(Rectangle rect, Paint fill) throws IFException {
+        if (fill == null) {
             return;
         }
         try {
@@ -298,12 +300,13 @@
             if (fill != null) {
                 atts.addAttribute("", "fill", "fill", CDATA, toString(fill));
             }
+            /* disabled
             if (stroke != null) {
-                atts.addAttribute("", "stroke", "sroke", CDATA, toString(stroke));
-            }
+                atts.addAttribute("", "stroke", "stroke", CDATA, toString(stroke));
+            }*/
             element("rect", atts);
         } catch (SAXException e) {
-            throw new IFException("SAX error in drawRect()", e);
+            throw new IFException("SAX error in fillRect()", e);
         }
     }
 
@@ -314,6 +317,25 @@
     }
 
     /** {@inheritDoc} */
+    public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+            throws IFException {
+        try {
+            establish(MODE_NORMAL);
+            AttributesImpl atts = new AttributesImpl();
+            atts.addAttribute("", "x1", "x1", CDATA, Integer.toString(start.x));
+            atts.addAttribute("", "y1", "y1", CDATA, Integer.toString(start.y));
+            atts.addAttribute("", "x2", "x2", CDATA, Integer.toString(end.x));
+            atts.addAttribute("", "y2", "y2", CDATA, Integer.toString(end.y));
+            atts.addAttribute("", "stroke-width", "stroke-width", CDATA, toString(color));
+            atts.addAttribute("", "fill", "fill", CDATA, toString(color));
+            //TODO Handle style parameter
+            element("line", atts);
+        } catch (SAXException e) {
+            throw new IFException("SAX error in drawLine()", e);
+        }
+    }
+
+    /** {@inheritDoc} */
     public void drawText(int x, int y, int[] dx, int[] dy, String text) throws IFException {
         try {
             establish(MODE_TEXT);



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org