| Method from org.apache.fop.apps.StreamRenderer Detail: |
public void addExtension(ExtensionObj ext) {
extensions.add(ext);
}
|
public PageSequence getCurrentPageSequence() {
return currentPageSequence;
}
|
public ArrayList getCurrentPageSequenceMarkers() {
return currentPageSequenceMarkers;
}
|
public ArrayList getDocumentMarkers() {
return documentMarkers;
}
|
public IDReferences getIDReferences() {
return idReferences;
}
|
public FormattingResults getResults() {
return this.results;
}
|
public synchronized void queuePage(Page page) throws IOException, FOPException {
// process markers
PageSequence pageSequence = page.getPageSequence();
if (pageSequence != currentPageSequence) {
currentPageSequence = pageSequence;
currentPageSequenceMarkers = null;
}
ArrayList markers = page.getMarkers();
if (markers != null) {
if (documentMarkers == null) {
documentMarkers = new ArrayList();
}
if (currentPageSequenceMarkers == null) {
currentPageSequenceMarkers = new ArrayList();
}
for (int i=0;i< markers.size();i++) {
Marker marker = (Marker)markers.get(i);
marker.releaseRegistryArea();
currentPageSequenceMarkers.add(marker);
documentMarkers.add(marker);
}
}
/*
Try to optimise on the common case that there are
no pages pending and that all ID references are
valid on the current pages. This short-cuts the
pipeline and renders the area immediately.
*/
if ((renderQueue.size() == 0) && idReferences.isEveryIdValid()) {
renderer.render(page, outputStream);
} else {
RenderQueueEntry entry = new RenderQueueEntry(page);
renderQueue.add(entry);
/*
The just-added entry could (possibly) resolve the
waiting entries, so we try to process the queue
now to see.
*/
processQueue(false);
}
pageCount++;
}
|
public void render(PageSequence pageSequence) throws SAXException {
AreaTree a = new AreaTree(this);
a.setFontInfo(fontInfo);
for(int i = 0; i < extensions.size(); i++ ) {
ExtensionObj ext = (ExtensionObj)extensions.get(i);
try {
ext.format(a);
} catch (FOPException fope) {
throw new SAXException(fope);
}
}
try {
pageSequence.format(a);
} catch (FOPException e) {
throw new SAXException(e);
}
this.results.haveFormattedPageSequence(pageSequence);
log.debug("Last page-sequence produced "+pageSequence.getPageCount()+" pages.");
}
Format the PageSequence. The PageSequence
formats Pages and adds them to the AreaTree,
which subsequently calls the StreamRenderer
instance (this) again to render the page.
At this time the page might be printed
or it might be queued. A page might not
be renderable immediately if the IDReferences
are not all valid. In this case we defer
the rendering until they are all valid. |
public void setLogger(Logger logger) {
log = logger;
}
|
public void startRenderer() throws SAXException {
pageCount = 0;
if (MEM_PROFILE_WITH_GC)
System.gc(); // This takes time but gives better results
initialMemory = runtime.totalMemory() - runtime.freeMemory();
startTime = System.currentTimeMillis();
try {
renderer.setupFontInfo(fontInfo);
renderer.startRenderer(outputStream);
} catch (FOPException fe) {
throw new SAXException(fe);
} catch (IOException e) {
throw new SAXException(e);
}
}
|
public void stopRenderer() throws SAXException {
/*
Force the processing of any more queue elements,
even if they are not resolved.
*/
try {
processQueue(true);
renderer.stopRenderer(outputStream);
} catch (FOPException e) {
throw new SAXException(e);
}
catch (IOException e) {
throw new SAXException(e);
}
if (MEM_PROFILE_WITH_GC)
System.gc(); // This takes time but gives better results
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
log.debug("Initial heap size: " + (initialMemory/1024L) + "Kb");
log.debug("Current heap size: " + (memoryNow/1024L) + "Kb");
log.debug("Total memory used: " + memoryUsed + "Kb");
if (!MEM_PROFILE_WITH_GC) {
log.debug(" Memory use is indicative; no GC was performed");
log.debug(" These figures should not be used comparatively");
}
long timeUsed = System.currentTimeMillis() - startTime;
log.debug("Total time used: " + timeUsed + "ms");
log.debug("Pages rendered: " + pageCount);
if (pageCount != 0) {
log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
}
}
|