aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area/AreaTreeHandler.java
diff options
context:
space:
mode:
authorSimon Pepping <spepping@apache.org>2004-12-24 12:06:26 +0000
committerSimon Pepping <spepping@apache.org>2004-12-24 12:06:26 +0000
commitc6dcfcd8dd37b9b40b65d93f2d57d21cd43097b6 (patch)
tree4903fae598b0d92b31a4c701e6ccf31d88658270 /src/java/org/apache/fop/area/AreaTreeHandler.java
parent43decd1c0ddf36756615f96bbc089f6b7027afa0 (diff)
downloadxmlgraphics-fop-c6dcfcd8dd37b9b40b65d93f2d57d21cd43097b6.tar.gz
xmlgraphics-fop-c6dcfcd8dd37b9b40b65d93f2d57d21cd43097b6.zip
This patch implements a pluggable LayoutManagers system, according
to the ideas of Finn Bock and his patch in bug 30500. Created a LayoutManagerMaker interface, with method makeLayoutManagers(FONode, List), and two convenience methods on top of it. Created an implementation: LayoutManagerMapping. This is along the pattern of FOElementMapping. It creates a Map from FObj class to Maker objects. There are many static inner classes which are subclasses of Maker. Each subclass implements its own version of the make method. FOUserAgent has a setter and getter for LayoutManagerMakerOverride. AreaTreeHandler creates a LayoutManagerMaker, taking the user's override into account, using LayoutManagerMapping as the default. It has a get method for it. The LayoutManager interface has a get method for the AreaTreeHandler object, a reference to which is held in PageSequenceLM, the top of the LM tree. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198208 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area/AreaTreeHandler.java')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeHandler.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java
index df60e0cbb..fe0972da9 100644
--- a/src/java/org/apache/fop/area/AreaTreeHandler.java
+++ b/src/java/org/apache/fop/area/AreaTreeHandler.java
@@ -40,6 +40,8 @@ import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Root;
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
+import org.apache.fop.layoutmgr.LayoutManagerMaker;
+import org.apache.fop.layoutmgr.LayoutManagerMapping;
/**
* Area tree handler for formatting objects.
@@ -72,6 +74,9 @@ public class AreaTreeHandler extends FOEventHandler {
// time used in rendering (for statistics)
private long startTime;
+ // the LayoutManager maker
+ private LayoutManagerMaker lmMaker;
+
// count of number of pages rendered
private int pageCount;
@@ -106,6 +111,11 @@ public class AreaTreeHandler extends FOEventHandler {
model = new RenderPagesModel(userAgent, renderType, fontInfo,
stream);
+ lmMaker = userAgent.getLayoutManagerMakerOverride();
+ if (lmMaker == null) {
+ lmMaker = new LayoutManagerMapping();
+ }
+
outputStatistics = log.isDebugEnabled();
if (outputStatistics) {
@@ -123,6 +133,15 @@ public class AreaTreeHandler extends FOEventHandler {
}
/**
+ * Get the LayoutManager maker for this area tree.
+ *
+ * @return LayoutManagerMaker the LayoutManager maker being used for this area tree
+ */
+ public LayoutManagerMaker getLayoutManagerMaker() {
+ return lmMaker;
+ }
+
+ /**
* 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.
@@ -210,8 +229,10 @@ public class AreaTreeHandler extends FOEventHandler {
// If no main flow, nothing to layout!
if (pageSequence.getMainFlow() != null) {
- PageSequenceLayoutManager pageSLM
- = new PageSequenceLayoutManager(this, pageSequence);
+ PageSequenceLayoutManager pageSLM =
+ (PageSequenceLayoutManager)
+ getLayoutManagerMaker().makeLayoutManager(pageSequence);
+ pageSLM.setAreaTreeHandler(this);
pageSLM.activateLayout();
}
}