aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2003-10-26 19:29:14 +0000
committerGlen Mazza <gmazza@apache.org>2003-10-26 19:29:14 +0000
commita25886fa6eb7c702e71c46e2921e57c449344ee2 (patch)
tree86ac2990b0e710e3ddeccf7bdee463fde32f1fd5 /src/java/org/apache
parente1c96a10fe9674951a2184a6789fd61225bcecbd (diff)
downloadxmlgraphics-fop-a25886fa6eb7c702e71c46e2921e57c449344ee2.tar.gz
xmlgraphics-fop-a25886fa6eb7c702e71c46e2921e57c449344ee2.zip
1. TraitSetter modified to provide padding properties for regions.
2. PDFRenderer modified to take into account region borders and region padding when rendering text. (Possibly temporary solution--may need to move code to base AbstractRenderer in future.) Work incomplete--will need to also reduce line length accordingly to account for region borders and padding. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196972 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/layoutmgr/TraitSetter.java20
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java83
2 files changed, 83 insertions, 20 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
index 017a7258c..6c0ff71e7 100644
--- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
@@ -148,6 +148,26 @@ public class TraitSetter {
if (bps.width != 0) {
curBlock.addTrait(Trait.BORDER_END, bps);
}
+
+ int padding = bordProps.getPadding(CommonBorderAndPadding.START, false);
+ if (padding != 0) {
+ curBlock.addTrait(Trait.PADDING_START, new java.lang.Integer(padding));
+ }
+
+ padding = bordProps.getPadding(CommonBorderAndPadding.END, false);
+ if (padding != 0) {
+ curBlock.addTrait(Trait.PADDING_END, new java.lang.Integer(padding));
+ }
+
+ padding = bordProps.getPadding(CommonBorderAndPadding.BEFORE, false);
+ if (padding != 0) {
+ curBlock.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding));
+ }
+
+ padding = bordProps.getPadding(CommonBorderAndPadding.AFTER, false);
+ if (padding != 0) {
+ curBlock.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding));
+ }
}
private static BorderProps getBorderProps(CommonBorderAndPadding bordProps, int side) {
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index ccbe28ba0..bc631660d 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -227,6 +227,16 @@ public class PDFRenderer extends PrintRenderer {
private StringBuffer wordAreaPDF = new StringBuffer();
/**
+ * Offset for rendering text, taking into account borders and padding
+ */
+ protected int BPMarginOffset = 0;
+
+ /**
+ * Offset for rendering text, taking into account borders and padding
+ */
+ protected int IPMarginOffset = 0;
+
+ /**
* create the PDF renderer
*/
public PDFRenderer() {
@@ -467,7 +477,6 @@ public class PDFRenderer extends PrintRenderer {
this.pdfDoc.output(ostream);
}
-
/**
* @see org.apache.fop.render.AbstractRenderer#startVParea(CTM)
*/
@@ -494,6 +503,21 @@ public class PDFRenderer extends PrintRenderer {
}
/**
+ * Handle block traits.
+ * The block could be any sort of block with any positioning
+ * so this should render the traits such as border and background
+ * in its position.
+ *
+ * @param block the block to render the traits
+ */
+ protected void handleBlockTraits(Block block) {
+ float startx = currentIPPosition / 1000f;
+ float starty = currentBPPosition / 1000f;
+ drawBackAndBorders(block, startx, starty,
+ block.getWidth() / 1000f, block.getHeight() / 1000f);
+ }
+
+ /**
* Handle the traits for a region
* This is used to draw the traits for the given page region.
* (See Sect. 6.4.1.2 of XSL-FO spec.)
@@ -510,22 +534,35 @@ public class PDFRenderer extends PrintRenderer {
Trait.Background back;
back = (Trait.Background)region.getTrait(Trait.BACKGROUND);
*/
- drawBackAndBorders(region, startx, starty, width, height);
- }
- /**
- * Handle block traits.
- * The block could be any sort of block with any positioning
- * so this should render the traits such as border and background
- * in its position.
- *
- * @param block the block to render the traits
- */
- protected void handleBlockTraits(Block block) {
- float startx = currentIPPosition / 1000f;
- float starty = currentBPPosition / 1000f;
- drawBackAndBorders(block, startx, starty,
- block.getWidth() / 1000f, block.getHeight() / 1000f);
+ if (region.getRegion().getRegionClass() == org.apache.fop.fo.pagination.Region.BODY_CODE)
+ {
+ // need to collect vertical and horizontal offsets
+ // for body-region (for rendering of text)
+ BorderProps bps = (BorderProps) region.getTrait(Trait.BORDER_BEFORE);
+ if (bps != null) {
+ BPMarginOffset = bps.width;
+ }
+
+ bps = (BorderProps) region.getTrait(Trait.BORDER_START);
+ if (bps != null) {
+ IPMarginOffset = bps.width;
+ }
+
+ java.lang.Integer padWidth = (java.lang.Integer)
+ region.getTrait(Trait.PADDING_BEFORE);
+ if (padWidth != null) {
+ BPMarginOffset += padWidth.intValue();
+ }
+
+ padWidth = (java.lang.Integer)
+ region.getTrait(Trait.PADDING_START);
+ if (padWidth != null) {
+ IPMarginOffset += padWidth.intValue();
+ }
+ }
+
+ drawBackAndBorders(region, startx, starty, width, height);
}
/**
@@ -848,7 +885,6 @@ public class PDFRenderer extends PrintRenderer {
* @see org.apache.fop.render.Renderer#renderCharacter(Character)
*/
public void renderCharacter(Character ch) {
-
super.renderCharacter(ch);
}
@@ -875,9 +911,16 @@ public class PDFRenderer extends PrintRenderer {
updateColor(ct, true, pdf);
}
- int rx = currentBlockIPPosition;
- // int bl = pageHeight - currentBPPosition;
- int bl = currentBPPosition + word.getOffset();
+ // word.getOffset() = only height of text itself
+ // currentBlockIPPosition: 0 for beginning of line; nonzero
+ // where previous line area failed to take up entire allocated space
+ int rx = currentBlockIPPosition + IPMarginOffset;
+ int bl = currentBPPosition + BPMarginOffset + word.getOffset();
+
+/* System.out.println("BlockIP Position: " + currentBlockIPPosition +
+ "; currentBPPosition: " + currentBPPosition +
+ "; offset: " + word.getOffset() +
+ "; Word = " + word.getWord()); */
// Set letterSpacing
//float ls = fs.getLetterSpacing() / this.currentFontSize;