// the LayoutManager maker
private LayoutManagerMaker lmMaker;
- // count of number of pages rendered
- private int pageCount;
-
// AreaTreeModel in use
private AreaTreeModel model;
public void startDocument() throws SAXException {
//Initialize statistics
if (outputStatistics) {
- pageCount = 0;
initialMemory = runtime.totalMemory() - runtime.freeMemory();
startTime = System.currentTimeMillis();
}
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
long timeUsed = System.currentTimeMillis() - startTime;
+ int pageCount = rootFObj.getRunningPageNumberCounter();
log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
log.debug("Total memory used: " + memoryUsed + "Kb");
log.debug("Total time used: " + timeUsed + "ms");
- log.debug("Pages rendered: " + rootFObj.getRunningPageNumberCounter());
+ log.debug("Pages rendered: " + pageCount);
if (pageCount > 0) {
log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
}
model.handleOffDocumentItem(odi);
}
}
-
- /**
- * Called by the PageSequenceLayoutManager to notify the AreaTreeHandler
- * of a new page being started.
- * @param pageNumber page number
- */
- public void notifyNewPage(String pageNumber) {
- pageCount++;
- }
}
* It manages all page-related layout.
*/
public class PageSequenceLayoutManager extends AbstractLayoutManager {
- private PageSequence fobj;
+ private PageSequence pageSeq;
private static class BlockBreakPosition extends LeafPosition {
protected BreakPoss breakps;
*
* @param pageseq the page sequence fo
*/
- public PageSequenceLayoutManager(PageSequence pageseq) {
- super(pageseq);
- fobj = pageseq;
- if (fobj.getPageSequenceMaster() != null) {
- fobj.getPageSequenceMaster().reset();
+ public PageSequenceLayoutManager(PageSequence pageSeq) {
+ super(pageSeq);
+ this.pageSeq = pageSeq;
+ if (pageSeq.getPageSequenceMaster() != null) {
+ pageSeq.getPageSequenceMaster().reset();
}
}
return areaTreeHandler;
}
- /**
- * Set the page counting for this page sequence.
- * This sets the initial page number and the page number formatter.
- *
- * @param pc the starting page number
- * @param generator the page number generator
- */
- private void setPageCounting(int pc, PageNumberGenerator generator) {
- pageCount = pc;
- pageNumberGenerator = generator;
- pageNumberString = pageNumberGenerator.makeFormattedPageNumber(pageCount);
- }
-
/**
* Get the page count.
* Used to get the last page number for reference for
* which creates and adds all the pages to the area tree.
*/
public void activateLayout() {
- fobj.initPageNumber();
- setPageCounting(fobj.getCurrentPageNumber(),
- fobj.getPageNumberGenerator());
+ pageSeq.initPageNumber();
+ pageCount = pageSeq.getCurrentPageNumber();
+ pageNumberGenerator = pageSeq.getPageNumberGenerator();
+ pageNumberString = pageNumberGenerator.makeFormattedPageNumber(pageCount);
LineArea title = null;
- if (fobj.getTitleFO() != null) {
- title = getTitleArea(fobj.getTitleFO());
+ if (pageSeq.getTitleFO() != null) {
+ title = getTitleArea(pageSeq.getTitleFO());
}
areaTreeModel.startPageSequence(title);
pageCount--;
log.debug("Ending layout");
flush();
- fobj.setCurrentPageNumber(getPageCount());
+ pageSeq.setCurrentPageNumber(getPageCount());
}
/**
childLC.setRefIPD(flowIPD);
if (!curLM.isFinished()) {
- fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
- fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
+ pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
+ pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
bp = curLM.getNextBreakPoss(childLC);
}
if (bp != null) {
if (log.isDebugEnabled()) {
log.debug("[" + curPage.getPageNumber() + "]");
}
- areaTreeHandler.notifyNewPage(curPage.getPageNumber());
RegionViewport rv = curPage.getPage().getRegionViewport(
FO_REGION_BODY);
curBody = (BodyRegion) rv.getRegion();
if (region == null) {
return;
}
- StaticContent flow = fobj.getStaticContent(region.getRegionName());
+ StaticContent flow = pageSeq.getStaticContent(region.getRegionName());
if (flow == null) {
return;
}
throws FOPException {
currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank);
Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY);
- if (!fobj.getMainFlow().getFlowName().equals(body.getRegionName())) {
- throw new FOPException("Flow '" + fobj.getMainFlow().getFlowName()
+ if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {
+ throw new FOPException("Flow '" + pageSeq.getMainFlow().getFlowName()
+ "' does not map to the region-body in page-master '"
+ currentSimplePageMaster.getMasterName() + "'");
}
private SimplePageMaster getSimplePageMasterToUse(boolean bIsBlank)
throws FOPException {
- if (fobj.getPageSequenceMaster() == null) {
- return fobj.getSimplePageMaster();
+ if (pageSeq.getPageSequenceMaster() == null) {
+ return pageSeq.getSimplePageMaster();
}
boolean isOddPage = ((pageCount % 2) == 1);
- return fobj.getPageSequenceMaster()
+ return pageSeq.getPageSequenceMaster()
.getNextSimplePageMaster(isOddPage, isFirstPage, bIsBlank);
}
int pageHeight = spm.getPageHeight().getValue();
// Set the page dimension as the toplevel containing block for margin.
- ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
- ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
+ ((FObj) pageSeq.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
+ ((FObj) pageSeq.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
// Get absolute margin properties (top, left, bottom, right)
CommonMarginBlock mProps = spm.getCommonMarginBlock();