You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2004/11/29 09:45:14 UTC
cvs commit: xml-fop/src/java/org/apache/fop/render AbstractRenderer.java Renderer.java
gmazza 2004/11/29 00:45:14
Modified: src/java/org/apache/fop/area AreaTreeHandler.java
src/java/org/apache/fop/layoutmgr
PageSequenceLayoutManager.java
src/java/org/apache/fop/render AbstractRenderer.java
Renderer.java
Log:
1.) More cleanup/commenting of AreaTreeHandler. Removed the unused (disabled)
manual garbage collection code.
2.) Removed renderContainer from Renderer interface, not required.
Revision Changes Path
1.18 +43 -62 xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java
Index: AreaTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- AreaTreeHandler.java 27 Nov 2004 19:58:34 -0000 1.17
+++ AreaTreeHandler.java 29 Nov 2004 08:45:14 -0000 1.18
@@ -63,8 +63,6 @@
// 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 @@
// 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 @@
}
/**
- * 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
- */
- 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);
+ * 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 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 @@
//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 @@
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 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 @@
*/
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 {
1.15 +6 -6 xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
Index: PageSequenceLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- PageSequenceLayoutManager.java 27 Nov 2004 19:58:35 -0000 1.14
+++ PageSequenceLayoutManager.java 29 Nov 2004 08:45:14 -0000 1.15
@@ -289,13 +289,13 @@
* 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 @@
* @param id the ID reference to add
*/
public void addIDToPage(String id) {
- areaTreeHandler.addIDRef(id, curPage);
+ areaTreeHandler.associateIDWithPageViewport(id, curPage);
}
/**
1.39 +5 -2 xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java
Index: AbstractRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- AbstractRenderer.java 27 Oct 2004 23:36:33 -0000 1.38
+++ AbstractRenderer.java 29 Nov 2004 08:45:14 -0000 1.39
@@ -644,8 +644,11 @@
// 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;
1.18 +0 -7 xml-fop/src/java/org/apache/fop/render/Renderer.java
Index: Renderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/Renderer.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Renderer.java 27 Oct 2004 23:36:33 -0000 1.17
+++ Renderer.java 29 Nov 2004 08:45:14 -0000 1.18
@@ -147,12 +147,5 @@
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);
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org