private void checkBoundaries(CommonBorderAndPadding bap) {
- // TODO! use start and end in BAP!!
- bStartBoundary = (bap.getBorderLeftWidth(false) > 0
- || bap.getPaddingLeft(false) > 0);
- bEndBoundary = (bap.getBorderRightWidth(false) > 0
- || bap.getPaddingRight(false) > 0);
+ bStartBoundary = (bap.getBorderStartWidth(false) > 0
+ || bap.getPaddingStart(false) > 0);
+ bEndBoundary = (bap.getBorderEndWidth(false) > 0
+ || bap.getPaddingEnd(false) > 0);
}
/**
*/
int iSep = properties.get(
"border-separation.inline-progression-direction").getLength().getValue();
- this.startAdjust = iSep / 2 + bp.getBorderLeftWidth(false)
- + bp.getPaddingLeft(false);
- /*
- * int contentOffset = iSep + bp.getBorderStartWidth(false) +
- * bp.getPaddingStart(false);
- */
+ this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false)
+ + bp.getPaddingStart(false);
+
this.widthAdjust = startAdjust + iSep - iSep / 2
- + bp.getBorderRightWidth(false)
- + bp.getPaddingRight(false);
- // bp.getBorderEndWidth(false) + bp.getPaddingEnd(false);
+ + bp.getBorderEndWidth(false)
+ + bp.getPaddingEnd(false);
+
// Offset of content rectangle in the block-progression direction
borderSeparation = properties.get(
"border-separation.block-progression-direction").getLength().getValue();
this.beforeOffset = borderSeparation / 2
- + bp.getBorderTopWidth(false)
- + bp.getPaddingTop(false);
- // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false);
+ + bp.getBorderBeforeWidth(false)
+ + bp.getPaddingBefore(false);
} else {
// System.err.println("Collapse borders");
/* ivan demakov */
- int borderStart = bp.getBorderLeftWidth(false);
- int borderEnd = bp.getBorderRightWidth(false);
- int borderBefore = bp.getBorderTopWidth(false);
- int borderAfter = bp.getBorderBottomWidth(false);
+ int borderStart = bp.getBorderStartWidth(false);
+ int borderEnd = bp.getBorderEndWidth(false);
+ int borderBefore = bp.getBorderBeforeWidth(false);
+ int borderAfter = bp.getBorderAfterWidth(false);
- this.startAdjust = borderStart / 2 + bp.getPaddingLeft(false);
+ this.startAdjust = borderStart / 2 + bp.getPaddingStart(false);
this.widthAdjust = startAdjust + borderEnd / 2
- + bp.getPaddingRight(false);
- this.beforeOffset = borderBefore / 2 + bp.getPaddingTop(false);
+ + bp.getPaddingEnd(false);
+ this.beforeOffset = borderBefore / 2 + bp.getPaddingBefore(false);
// Half border height to fix overestimate of area size!
this.borderHeight = (borderBefore + borderAfter) / 2;
}
public static final int START = 2;
public static final int END = 3;
+/* TODO: need new definitions (below relations not always the same,
+ also unsure if direct access of absolute properties needed;
+ resolution of absolute & relative properties--Spec 5.3.1--can
+ possibly be done within this class alone)
public static final int TOP = BEFORE;
public static final int BOTTOM = AFTER;
public static final int LEFT = START;
public static final int RIGHT = END;
-
+*/
private static class ResolvedCondLength implements Cloneable {
private int iLength; // Resolved length value
private boolean bDiscard;
borderInfo[side].mWidth.iLength = iLength;
}
- public int getBorderLeftWidth(boolean bDiscard) {
- return getBorderWidth(LEFT, bDiscard);
+ public int getBorderStartWidth(boolean bDiscard) {
+ return getBorderWidth(START, bDiscard);
}
- public int getBorderRightWidth(boolean bDiscard) {
- return getBorderWidth(RIGHT, bDiscard);
+ public int getBorderEndWidth(boolean bDiscard) {
+ return getBorderWidth(END, bDiscard);
}
- public int getBorderTopWidth(boolean bDiscard) {
- return getBorderWidth(TOP, bDiscard);
+ public int getBorderBeforeWidth(boolean bDiscard) {
+ return getBorderWidth(BEFORE, bDiscard);
}
- public int getBorderBottomWidth(boolean bDiscard) {
- return getBorderWidth(BOTTOM, bDiscard);
+ public int getBorderAfterWidth(boolean bDiscard) {
+ return getBorderWidth(AFTER, bDiscard);
}
- public int getPaddingLeft(boolean bDiscard) {
- return getPadding(LEFT, bDiscard);
+ public int getPaddingStart(boolean bDiscard) {
+ return getPadding(START, bDiscard);
}
- public int getPaddingRight(boolean bDiscard) {
- return getPadding(RIGHT, bDiscard);
+ public int getPaddingEnd(boolean bDiscard) {
+ return getPadding(END, bDiscard);
}
- public int getPaddingBottom(boolean bDiscard) {
- return getPadding(BOTTOM, bDiscard);
+ public int getPaddingBefore(boolean bDiscard) {
+ return getPadding(BEFORE, bDiscard);
}
- public int getPaddingTop(boolean bDiscard) {
- return getPadding(TOP, bDiscard);
+ public int getPaddingAfter(boolean bDiscard) {
+ return getPadding(AFTER, bDiscard);
}
public int getBorderWidth(int side, boolean bDiscard) {
public String toString() {
return "CommonBordersAndPadding (Before, After, Start, End):\n" +
- "Borders: (" + getBorderTopWidth(false) + ", " + getBorderBottomWidth(false) + ", " +
- getBorderLeftWidth(false) + ", " + getBorderRightWidth(false) + ")\n" +
+ "Borders: (" + getBorderBeforeWidth(false) + ", " + getBorderAfterWidth(false) + ", " +
+ getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n" +
"Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", " +
getBorderColor(START) + ", " + getBorderColor(END) + ")\n" +
- "Padding: (" + getPaddingTop(false) + ", " + getPaddingBottom(false) + ", " +
- getPaddingLeft(false) + ", " + getPaddingRight(false) + ")\n";
+ "Padding: (" + getPaddingBefore(false) + ", " + getPaddingAfter(false) + ", " +
+ getPaddingStart(false) + ", " + getPaddingEnd(false) + ")\n";
}
}
LayoutProcessor curLM; // currently active LM
int ipd = context.getRefIPD();
+ int iIndents = borderProps.getPaddingStart(false)
+ + borderProps.getPaddingEnd(false);
+ ipd -= iIndents;
MinOptMax stackSize = new MinOptMax();
* @param bordProps border properties
*/
public static void addBorders(Area curBlock, CommonBorderAndPadding bordProps) {
- BorderProps bps = getBorderProps(bordProps, CommonBorderAndPadding.TOP);
+ BorderProps bps = getBorderProps(bordProps, CommonBorderAndPadding.BEFORE);
if (bps.width != 0) {
curBlock.addTrait(Trait.BORDER_BEFORE, bps);
}
- bps = getBorderProps(bordProps, CommonBorderAndPadding.BOTTOM);
+ bps = getBorderProps(bordProps, CommonBorderAndPadding.AFTER);
if (bps.width != 0) {
curBlock.addTrait(Trait.BORDER_AFTER, bps);
}
- bps = getBorderProps(bordProps, CommonBorderAndPadding.LEFT);
+ bps = getBorderProps(bordProps, CommonBorderAndPadding.START);
if (bps.width != 0) {
curBlock.addTrait(Trait.BORDER_START, bps);
}
- bps = getBorderProps(bordProps, CommonBorderAndPadding.RIGHT);
+ bps = getBorderProps(bordProps, CommonBorderAndPadding.END);
if (bps.width != 0) {
curBlock.addTrait(Trait.BORDER_END, bps);
}
}
}
+ /**
+ * Handle block traits.
+ * This method is called when the correct ip and bp posiiton is
+ * set. This should be overridden to draw border and background
+ * traits for the block area.
+ *
+ * @param block the block area
+ */
+ protected void handleBlockTraits(Block block) {
+ // draw border and background
+ }
+
+ /**
+ * Renders a block viewport.
+ *
+ * @param bv The block viewport
+ * @param children The children to render within the block viewport
+ */
+ protected void renderBlockViewport(BlockViewport bv, List children) {
+ // clip and position viewport if necessary
+ if (bv.getPositioning() == Block.ABSOLUTE) {
+ // save positions
+ int saveIP = currentIPPosition;
+ int saveBP = currentBPPosition;
+
+ CTM ctm = bv.getCTM();
+ currentIPPosition = 0;
+ currentBPPosition = 0;
+
+ startVParea(ctm);
+ handleBlockTraits(bv);
+ renderBlocks(children);
+ endVParea();
+
+ // clip if necessary
+
+ currentIPPosition = saveIP;
+ currentBPPosition = saveBP;
+ } else {
+ renderBlocks(children);
+ }
+ }
+
+ /**
+ * Renders a list of block areas.
+ *
+ * @param blocks The block areas
+ */
+ protected void renderBlocks(List blocks) {
+ // the position of the containing block is used for
+ // absolutely positioned areas
+ int contBP = currentBPPosition;
+ int contIP = currentIPPosition;
+ containingBPPosition = contBP;
+ containingIPPosition = contIP;
+
+ for (int count = 0; count < blocks.size(); count++) {
+ Object obj = blocks.get(count);
+ if (obj instanceof Block) {
+ containingBPPosition = contBP;
+ containingIPPosition = contIP;
+ renderBlock((Block) obj);
+ containingBPPosition = contBP;
+ containingIPPosition = contIP;
+ } else {
+ // a line area is rendered from the top left position
+ // of the line, each inline object is offset from there
+ LineArea line = (LineArea) obj;
+ currentBlockIPPosition =
+ currentIPPosition + line.getStartIndent();
+ renderLineArea(line);
+ currentBPPosition += line.getHeight();
+ }
+ }
+ }
+
/**
* Renders a block area.
*
}
}
- /**
- * Handle block traits.
- * This method is called when the correct ip and bp posiiton is
- * set. This should be overridden to draw border and background
- * traits for the block area.
- *
- * @param block the block area
- */
- protected void handleBlockTraits(Block block) {
- // draw border and background
- }
-
- /**
- * Renders a block viewport.
- *
- * @param bv The block viewport
- * @param children The children to render within the block viewport
- */
- protected void renderBlockViewport(BlockViewport bv, List children) {
- // clip and position viewport if necessary
- if (bv.getPositioning() == Block.ABSOLUTE) {
- // save positions
- int saveIP = currentIPPosition;
- int saveBP = currentBPPosition;
-
- CTM ctm = bv.getCTM();
- currentIPPosition = 0;
- currentBPPosition = 0;
-
- startVParea(ctm);
- handleBlockTraits(bv);
- renderBlocks(children);
- endVParea();
-
- // clip if necessary
-
- currentIPPosition = saveIP;
- currentBPPosition = saveBP;
- } else {
- renderBlocks(children);
- }
- }
-
/**
* Renders a line area. <p>
*
currentBlockIPPosition = saveIP + ip.getWidth();
}
- /**
- * Renders a list of block areas.
- *
- * @param blocks The block areas
- */
- protected void renderBlocks(List blocks) {
- // the position of the containing block is used for
- // absolutely positioned areas
- int contBP = currentBPPosition;
- int contIP = currentIPPosition;
- containingBPPosition = contBP;
- containingIPPosition = contIP;
-
- for (int count = 0; count < blocks.size(); count++) {
- Object obj = blocks.get(count);
- if (obj instanceof Block) {
- containingBPPosition = contBP;
- containingIPPosition = contIP;
- renderBlock((Block) obj);
- containingBPPosition = contBP;
- containingIPPosition = contIP;
- } else {
- // a line area is rendered from the top left position
- // of the line, each inline object is offset from there
- LineArea line = (LineArea) obj;
- currentBlockIPPosition =
- currentIPPosition + line.getStartIndent();
- renderLineArea(line);
- currentBPPosition += line.getHeight();
- }
- }
- }
-
/**
* Set the default xml handler for the given mime type.
* @param mime MIME type
private StringBuffer wordAreaPDF = new StringBuffer();
/**
- * Offset for rendering text, taking into account borders and padding
+ * Offset for rendering text, taking into account borders and padding for
+ * both region and block.
*/
protected int BPMarginOffset = 0;
/**
- * Offset for rendering text, taking into account borders and padding
+ * Offset for rendering text, taking into account borders and padding for
+ * both the region and block.
*/
protected int IPMarginOffset = 0;
}
/**
- * 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
+ * @see org.apache.fop.render.AbstractRenderer#renderBlock(Block)
*/
- protected void handleBlockTraits(Block block) {
- float startx = (currentIPPosition + IPMarginOffset)/ 1000f;
- float starty = (currentBPPosition + BPMarginOffset)/ 1000f;
- drawBackAndBorders(block, startx, starty,
- block.getWidth() / 1000f, block.getHeight() / 1000f);
- }
+ protected void renderBlock(Block block) {
+ int marginOffset = IPMarginOffset;
+ super.renderBlock(block);
+ // super.renderBlock() may render child blocks (with their own offsets)
+ // so need to restore (this parent's) IPMarginOffset when finished.
+ IPMarginOffset = marginOffset;
+ }
/**
* Handle the traits for a region
float width = (float)(viewArea.getWidth() / 1000f);
float height = (float)(viewArea.getHeight() / 1000f);
- if (region.getRegion().getRegionClass()
+ if (region.getRegion().getRegionClass()
== org.apache.fop.fo.pagination.Region.BODY_CODE)
- {
+ {
BPMarginOffset = region.getBorderAndPaddingWidthBefore();
IPMarginOffset = region.getBorderAndPaddingWidthStart();
}
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) {
+ /* IPMarginOffset for a particular block = region border +
+ * region padding + parent block padding + current block padding
+ */
+ Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
+ if (paddingStart != null) {
+ IPMarginOffset += paddingStart.intValue();
+ }
+
+ float startx = (currentIPPosition + IPMarginOffset) / 1000f;
+ float starty = (currentBPPosition + BPMarginOffset) / 1000f;
+ drawBackAndBorders(block, startx, starty,
+ block.getWidth() / 1000f, block.getHeight() / 1000f);
+ }
+
/**
* Draw the background and borders.
* This draws the background and border traits for an area given
}
// word.getOffset() = only height of text itself
- // currentBlockIPPosition: 0 for beginning of line; nonzero
+ // 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 + text.getOffset();