summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-11-29 08:45:14 +0000
committerGlen Mazza <gmazza@apache.org>2004-11-29 08:45:14 +0000
commit2c6954ddf9c905ee271c25f41ff2aa99e22f3104 (patch)
tree946fbb9e0027774b43ddbc4d9e1a49bedeaf4b3d
parentac08f884b6bdcb776accaacacc92e3c9b27bc063 (diff)
downloadxmlgraphics-fop-2c6954ddf9c905ee271c25f41ff2aa99e22f3104.tar.gz
xmlgraphics-fop-2c6954ddf9c905ee271c25f41ff2aa99e22f3104.zip
PR:
Obtained from: Submitted by: Reviewed by: 1.) More cleanup/commenting of AreaTreeHandler. Removed the unused (disabled) manual garbage collection code. 2.) Removed renderContainer from Renderer interface, not required. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198177 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/area/AreaTreeHandler.java101
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/render/AbstractRenderer.java7
-rw-r--r--src/java/org/apache/fop/render/Renderer.java7
4 files changed, 51 insertions, 74 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java
index abd9f529a..881e259bb 100644
--- a/src/java/org/apache/fop/area/AreaTreeHandler.java
+++ b/src/java/org/apache/fop/area/AreaTreeHandler.java
@@ -63,8 +63,6 @@ public class AreaTreeHandler extends FOEventHandler {
// show statistics after document complete?
private boolean outputStatistics;
- private static final boolean MEM_PROFILE_WITH_GC = false;
-
// for statistics gathering
private Runtime runtime;
@@ -80,7 +78,8 @@ public class AreaTreeHandler extends FOEventHandler {
// AreaTreeModel in use
private AreaTreeModel model;
- // hashmap of arraylists containing pages with id area
+ // HashMap of ID's whose area is located on one or more PageViewports
+ // Each ID has an arraylist of PageViewports sharing the area with this ID
private Map idLocations = new HashMap();
// idref's whose corresponding id's have yet to be found
@@ -120,35 +119,42 @@ public class AreaTreeHandler extends FOEventHandler {
}
/**
- * Add an id reference pointing to a page viewport.
- * @param id the id of the reference
- * @param pv the page viewport that contains the id reference
+ * Tie a PageViewport with an ID found on a child area of the PV.
+ * Note that an area with a given ID may be on more than one PV, hence
+ * an ID may have more than one PV associated with it.
+ * @param id the property ID of the area
+ * @param pv a page viewport that contains the area with this ID
*/
- public void addIDRef(String id, PageViewport pv) {
- List list = (List)idLocations.get(id);
- if (list == null) {
- list = new ArrayList();
- idLocations.put(id, list);
- }
- list.add(pv);
-
- Set todo = (Set) unresolvedIDRefs.get(id);
- if (todo != null) {
- for (Iterator iter = todo.iterator(); iter.hasNext();) {
- Resolvable res = (Resolvable)iter.next();
- res.resolve(id, list);
+ public void associateIDWithPageViewport(String id, PageViewport pv) {
+ List pvList = (List) idLocations.get(id);
+ if (pvList == null) { // first time ID located
+ pvList = new ArrayList();
+ idLocations.put(id, pvList);
+ pvList.add(pv);
+
+ /* See if this ID is in the unresolved idref list. Note:
+ * unresolving occurs at first PV found for a given area.
+ */
+ Set todo = (Set) unresolvedIDRefs.get(id);
+ if (todo != null) {
+ for (Iterator iter = todo.iterator(); iter.hasNext();) {
+ Resolvable res = (Resolvable) iter.next();
+ res.resolve(id, pvList);
+ }
+ unresolvedIDRefs.remove(id);
}
- unresolvedIDRefs.remove(id);
+ } else {
+ pvList.add(pv);
}
}
/**
- * Get the list of id references for an id.
+ * Get the list of page viewports that have an area with a given id.
* @param id the id to lookup
- * @return the list of id references.
+ * @return the list of PageViewports
*/
- public List getIDReferences(String id) {
- return (List)idLocations.get(id);
+ public List getPageViewportsContainingID(String id) {
+ return (List) idLocations.get(id);
}
/**
@@ -176,10 +182,6 @@ public class AreaTreeHandler extends FOEventHandler {
//Initialize statistics
if (outputStatistics) {
pageCount = 0;
- if (MEM_PROFILE_WITH_GC) {
- System.gc(); // This takes time but gives better results
- }
-
initialMemory = runtime.totalMemory() - runtime.freeMemory();
startTime = System.currentTimeMillis();
}
@@ -206,26 +208,16 @@ public class AreaTreeHandler extends FOEventHandler {
model.endDocument();
if (outputStatistics) {
- if (MEM_PROFILE_WITH_GC) {
- // This takes time but gives better results
- System.gc();
- }
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
long timeUsed = System.currentTimeMillis() - startTime;
- if (log != null && log.isDebugEnabled()) {
- 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");
- }
- log.debug("Total time used: " + timeUsed + "ms");
- log.debug("Pages rendered: " + pageCount);
- if (pageCount > 0) {
- log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
- }
+ 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: " + pageCount);
+ if (pageCount > 0) {
+ log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
}
}
}
@@ -240,14 +232,8 @@ public class AreaTreeHandler extends FOEventHandler {
public void endPageSequence(PageSequence pageSequence) {
if (outputStatistics) {
- if (MEM_PROFILE_WITH_GC) {
- // This takes time but gives better results
- System.gc();
- }
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- if (log != null) {
- log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
- }
+ log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
}
// If no main flow, nothing to layout!
@@ -305,18 +291,13 @@ public class AreaTreeHandler extends FOEventHandler {
*/
private void addOffDocumentItem(OffDocumentItem ext) {
if (ext instanceof Resolvable) {
- Resolvable res = (Resolvable)ext;
+ Resolvable res = (Resolvable) ext;
String[] ids = res.getIDs();
for (int count = 0; count < ids.length; count++) {
if (idLocations.containsKey(ids[count])) {
- res.resolve(ids[count], (List)idLocations.get(ids[count]));
+ res.resolve(ids[count], (List) idLocations.get(ids[count]));
} else {
- Set todo = (Set) unresolvedIDRefs.get(ids[count]);
- if (todo == null) {
- todo = new HashSet();
- unresolvedIDRefs.put(ids[count], todo);
- }
- todo.add(ext);
+ addUnresolvedIDRef(ids[count], res);
}
}
} else {
diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
index a7ff35a26..08130fca2 100644
--- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
@@ -289,13 +289,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
* This resolves a reference ID and returns the first PageViewport
* that contains the reference ID or null if reference not found.
*
- * @param ref the reference ID to lookup
+ * @param id the reference ID to lookup
* @return the first page viewport that contains the reference
*/
- public PageViewport resolveRefID(String ref) {
- List list = areaTreeHandler.getIDReferences(ref);
+ public PageViewport resolveRefID(String id) {
+ List list = areaTreeHandler.getPageViewportsContainingID(id);
if (list != null && list.size() > 0) {
- return (PageViewport)list.get(0);
+ return (PageViewport) list.get(0);
}
return null;
}
@@ -323,7 +323,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
* @param id the ID reference to add
*/
public void addIDToPage(String id) {
- areaTreeHandler.addIDRef(id, curPage);
+ areaTreeHandler.associateIDWithPageViewport(id, curPage);
}
/**
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index a6542a4a8..7fb27999b 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -644,8 +644,11 @@ public abstract class AbstractRenderer
// Some renderers (ex. Text) don't support images.
}
- /** @see org.apache.fop.render.Renderer */
- public void renderContainer(Container cont) {
+ /**
+ * Tells the renderer to render an inline container.
+ * @param cont The inline container area
+ */
+ protected void renderContainer(Container cont) {
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java
index e45ed6560..52eb2d2e3 100644
--- a/src/java/org/apache/fop/render/Renderer.java
+++ b/src/java/org/apache/fop/render/Renderer.java
@@ -147,12 +147,5 @@ public interface Renderer {
void renderPage(PageViewport page)
throws IOException, FOPException;
- /**
- * Tells the renderer to render an inline container.
- *
- * @param cont The inline container area
- */
- void renderContainer(Container cont);
-
}