diff options
author | Luca Furini <lfurini@apache.org> | 2008-06-23 09:24:14 +0000 |
---|---|---|
committer | Luca Furini <lfurini@apache.org> | 2008-06-23 09:24:14 +0000 |
commit | 770ac265542a8fd68033ece8457108ef0ec59046 (patch) | |
tree | 4298cfd3b41f1e68cc41d852a8a696c2fddae9df /src/java/org/apache/fop/render | |
parent | 9c1e622432f126a45cb2d0971029364eaa63d60e (diff) | |
download | xmlgraphics-fop-770ac265542a8fd68033ece8457108ef0ec59046.tar.gz xmlgraphics-fop-770ac265542a8fd68033ece8457108ef0ec59046.zip |
Added support for non-zero borders and padding on page regions.
Testcase included, now disabled because it is supposed to run with relaxed validation switched on.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@670492 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r-- | src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java | 86 |
1 files changed, 74 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index eb0668d8b..a6c08747f 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -38,6 +38,7 @@ import org.apache.fop.area.Block; import org.apache.fop.area.BlockViewport; import org.apache.fop.area.CTM; import org.apache.fop.area.NormalFlow; +import org.apache.fop.area.RegionReference; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.ForeignObject; @@ -96,19 +97,20 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { */ protected void handleRegionTraits(RegionViewport region) { Rectangle2D viewArea = region.getViewArea(); + RegionReference referenceArea = region.getRegionReference(); float startx = (float)(viewArea.getX() / 1000f); float starty = (float)(viewArea.getY() / 1000f); float width = (float)(viewArea.getWidth() / 1000f); float height = (float)(viewArea.getHeight() / 1000f); - if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) { - currentBPPosition = region.getBorderAndPaddingWidthBefore(); - currentIPPosition = region.getBorderAndPaddingWidthStart(); - } - drawBackAndBorders(region, startx, starty, width, height); + // adjust the current position according to region borders and padding + currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore(); + currentIPPosition = referenceArea.getBorderAndPaddingWidthStart(); + // draw background (traits are in the RegionViewport) + // and borders (traits are in the RegionReference) + drawBackAndBorders(region, referenceArea, startx, starty, width, height); } - /** * Draw the background and borders. * This draws the background and border traits for an area given @@ -123,15 +125,57 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { protected void drawBackAndBorders(Area area, float startx, float starty, float width, float height) { + drawBackAndBorders(area, area, startx, starty, width, height); + } + + /** + * Draw the background and borders. + * This draws the background and border traits for an area given + * the position. + * + * @param backgroundArea the area to get the background traits from + * @param borderArea the area to get the border traits from + * @param startx the start x position + * @param starty the start y position + * @param width the width of the area + * @param height the height of the area + */ + protected void drawBackAndBorders(Area backgroundArea, Area borderArea, + float startx, float starty, + float width, float height) { // draw background then border - BorderProps bpsBefore = (BorderProps)area.getTrait(Trait.BORDER_BEFORE); - BorderProps bpsAfter = (BorderProps)area.getTrait(Trait.BORDER_AFTER); - BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START); - BorderProps bpsEnd = (BorderProps)area.getTrait(Trait.BORDER_END); + BorderProps bpsBefore = (BorderProps)borderArea.getTrait(Trait.BORDER_BEFORE); + BorderProps bpsAfter = (BorderProps)borderArea.getTrait(Trait.BORDER_AFTER); + BorderProps bpsStart = (BorderProps)borderArea.getTrait(Trait.BORDER_START); + BorderProps bpsEnd = (BorderProps)borderArea.getTrait(Trait.BORDER_END); - Trait.Background back; - back = (Trait.Background)area.getTrait(Trait.BACKGROUND); + drawBackground(startx, starty, width, height, + (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND), + bpsBefore, bpsAfter, bpsStart, bpsEnd); + drawBorders(startx, starty, width, height, + bpsBefore, bpsAfter, bpsStart, bpsEnd); + } + + /** + * Draw the background. + * This draws the background given the position and the traits. + * + * @param startx the start x position + * @param starty the start y position + * @param width the width of the area + * @param height the height of the area + * @param back the background traits + * @param bpsBefore the border-before traits + * @param bpsAfter the border-after traits + * @param bpsStart the border-start traits + * @param bpsEnd the border-end traits + */ + protected void drawBackground(float startx, float starty, + float width, float height, + Trait.Background back, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) { if (back != null) { endTextObject(); @@ -202,7 +246,25 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { restoreGraphicsState(); } } + } + /** + * Draw the borders. + * This draws the border traits given the position and the traits. + * + * @param startx the start x position + * @param starty the start y position + * @param width the width of the area + * @param height the height of the area + * @param bpsBefore the border-before traits + * @param bpsAfter the border-after traits + * @param bpsStart the border-start traits + * @param bpsEnd the border-end traits + */ + protected void drawBorders(float startx, float starty, + float width, float height, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) { Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height); drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd); } |