You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Ralph LaChance <Ra...@compuserve.com> on 2001/08/07 17:28:13 UTC

AWTRenderer patch

Hi,

Below is a patch to prevent AWTRender from drawing an invisible
border when the value for border-width is too small.  The patch
basically says that no matter how small the border-width is, it will
always render at least 1 pixel on the target graphics context.

I leave it to others to rule on the correctness of this approach
(makes sense to me) and thereby commit the patch or not.

Note however that for the sample fo attached,
(border-width is 0.1pt) both -awt and -print
fail to render a border, while -pdf does.

[Separate problem that the borders are in the wrong place
for all renderers..]

The attached sample fo was submitted to this list earlier by
Koen.Handekyn@alcatel.be


	' Best,
	-Ralph LaChance


----------------------  patch --------------------------------
     /**
      * draw a filled rectangle in the current color.
      * Force 1 pixel wide area if the size rounds to zero.
      *
      * @param x the x position of left edge in millipoints
      * @param y the y position of top edge in millipoints
      * @param w the width in millipoints
      * @param h the height in millipoints
      * @param drawAsOutline true for draw, false for fill
      */

     // helper function by aml/rlc to correct integer roundoff problems
     //
     protected void addRect(int x, int y, int w, int h,
                            boolean drawAsOutline) {
         int startx = (x + 500) / 1000;
         int starty = pageHeight - ((y + 500) / 1000);
         int endx = (x + w + 500) / 1000;
         int endy = pageHeight - ((y + h + 500) / 1000);
         if (drawAsOutline)
             graphics.drawRect(startx, starty, endx - startx, endy - starty);
         else
         {
           //don't round down to zero
           if (w != 0 && endx == startx) endx++;
           if (h != 0 && endy == starty) endy++;
           graphics.fillRect(startx, starty, endx - startx, endy - starty);
         }
     }

---------------------------------------------------------------