aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/apps/LayoutHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/apps/LayoutHandler.java')
-rw-r--r--src/org/apache/fop/apps/LayoutHandler.java95
1 files changed, 72 insertions, 23 deletions
diff --git a/src/org/apache/fop/apps/LayoutHandler.java b/src/org/apache/fop/apps/LayoutHandler.java
index 3e5e67b00..35def53f6 100644
--- a/src/org/apache/fop/apps/LayoutHandler.java
+++ b/src/org/apache/fop/apps/LayoutHandler.java
@@ -1,10 +1,53 @@
/*
* $Id$
- * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation and was originally created by
+ * James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// Java
@@ -35,44 +78,44 @@ public class LayoutHandler extends StructureHandler {
// TODO: Collecting of statistics should be configurable
private final boolean collectStatistics = true;
- private final boolean MEM_PROFILE_WITH_GC = false;
+ private static final boolean MEM_PROFILE_WITH_GC = false;
/**
- Somewhere to get our stats from.
+ * Somewhere to get our stats from.
*/
private Runtime runtime;
/**
- Keep track of the number of pages rendered.
+ * Keep track of the number of pages rendered.
*/
private int pageCount;
/**
- Keep track of heap memory allocated,
- for statistical purposes.
+ * Keep track of heap memory allocated,
+ * for statistical purposes.
*/
private long initialMemory;
/**
- Keep track of time used by renderer.
+ * Keep track of time used by renderer.
*/
private long startTime;
/**
- The stream to which this rendering is to be
- written to. <B>Note</B> that some renderers
- do not render to a stream, and that this
- member can therefore be null.
+ * The stream to which this rendering is to be
+ * written to. <B>Note</B> that some renderers
+ * do not render to a stream, and that this
+ * member can therefore be null.
*/
private OutputStream outputStream;
/**
- The renderer being used.
+ * The renderer being used.
*/
private Renderer renderer;
/**
- The FontInfo for this renderer.
+ * The FontInfo for this renderer.
*/
private FontInfo fontInfo = new FontInfo();
@@ -83,6 +126,7 @@ public class LayoutHandler extends StructureHandler {
private AreaTreeModel atModel;
/**
+ * Main constructor
* @param outputStream the stream that the result is rendered to
* @param renderer the renderer to call
* @param store if true then use the store pages model and keep the
@@ -90,8 +134,9 @@ public class LayoutHandler extends StructureHandler {
*/
public LayoutHandler(OutputStream outputStream, Renderer renderer,
boolean store) {
- if (collectStatistics)
+ if (collectStatistics) {
runtime = Runtime.getRuntime();
+ }
this.outputStream = outputStream;
this.renderer = renderer;
@@ -123,14 +168,16 @@ public class LayoutHandler extends StructureHandler {
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);
// check that the "any,normal,400" font exists
- if(!fontInfo.isSetupValid()) {
- throw new SAXException(new FOPException("no default font defined by OutputConverter"));
+ if (!fontInfo.isSetupValid()) {
+ throw new SAXException(new FOPException(
+ "No default font defined by OutputConverter"));
}
renderer.startRenderer(outputStream);
} catch (IOException e) {
@@ -186,7 +233,9 @@ public class LayoutHandler extends StructureHandler {
* @param seqTitle the title of the page sequence
* @param lms the layout master set
*/
- public void startPageSequence(PageSequence pageSeq, org.apache.fop.fo.Title seqTitle, LayoutMasterSet lms) {
+ public void startPageSequence(PageSequence pageSeq,
+ org.apache.fop.fo.Title seqTitle,
+ LayoutMasterSet lms) {
Title title = null;
if (seqTitle != null) {
title = seqTitle.getTitleArea();
@@ -203,7 +252,7 @@ public class LayoutHandler extends StructureHandler {
* @throws FOPException if there is an error formatting the pages
*/
public void endPageSequence(PageSequence pageSequence)
- throws FOPException {
+ throws FOPException {
//areaTree.setFontInfo(fontInfo);
if (collectStatistics) {
@@ -245,7 +294,7 @@ public class LayoutHandler extends StructureHandler {
count++;
}
List list = model.getEndExtensions();
- for(count = 0; count < list.size(); count++) {
+ for (count = 0; count < list.size(); count++) {
TreeExt ext = (TreeExt)list.get(count);
renderer.renderExtension(ext);
}