int dx = xoffset;
for (int x = 0; x < gridUnits.length; x++) {
GridUnit gu = gridUnits[x];
if (gu.hasBorders()) {
//Blocks for painting grid unit borders
Block block = new Block();
block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
block.setPositioning(Block.ABSOLUTE);
int bpd = spannedGridRowHeights[y - startRow];
bpd -= gu.getBorders().getBorderBeforeWidth(false) / 2;
bpd -= gu.getBorders().getBorderAfterWidth(false) / 2;
block.setBPD(bpd);
if (log.isTraceEnabled()) {
log.trace("pgu: " + primaryGridUnit + "; gu: " + gu + "; yoffset: "
+ (dy - gu.getBorders().getBorderBeforeWidth(false) / 2)
+ "; bpd: " + bpd);
}
int ipd = gu.getColumn().getColumnWidth().getValue(
(PercentBaseContext) getParent());
int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2;
ipd -= borderStartWidth;
ipd -= gu.getBorders().getBorderEndWidth(false) / 2;
block.setIPD(ipd);
block.setXOffset(dx + borderStartWidth);
block.setYOffset(dy - gu.getBorders().getBorderBeforeWidth(false) / 2);
outer[0] = gu.getFlag(GridUnit.FIRST_IN_TABLE);
outer[1] = gu.getFlag(GridUnit.LAST_IN_TABLE);
outer[2] = gu.getFlag(GridUnit.IN_FIRST_COLUMN);
outer[3] = gu.getFlag(GridUnit.IN_LAST_COLUMN);
TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer, this);
parentLM.addChildArea(block);
}
dx += gu.getColumn().getColumnWidth().getValue(
(PercentBaseContext) getParent());
}
dy += spannedGridRowHeights[y - startRow];
}
}
}
TraitSetter.addPadding(curBlockArea, primaryGridUnit.getBorders(),
false, false, false, false, this);
//Handle display-align
int contentBPD = getContentHeight(primaryGridUnit);
if (usedBPD < contentBPD) {
if (getTableCell().getDisplayAlign() == EN_CENTER) {
Block space = new Block();
space.setBPD((contentBPD - usedBPD) / 2);
curBlockArea.addBlock(space);
} else if (getTableCell().getDisplayAlign() == EN_AFTER) {
Block space = new Block();
space.setBPD((contentBPD - usedBPD));
curBlockArea.addBlock(space);
}
}
AreaAdditionUtil.addAreas(this, parentIter, layoutContext);