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 vm...@apache.org on 2003/08/20 19:25:44 UTC
cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LayoutManagerLS.java
vmote 2003/08/20 10:25:44
Modified: src/java/org/apache/fop/control Document.java
src/java/org/apache/fop/fo/pagination PageSequence.java
Root.java
src/java/org/apache/fop/layout LayoutStrategy.java
src/java/org/apache/fop/layoutmgr LayoutManagerLS.java
Log:
move startup of laying out a PageSequence from PageSequence.format() and Document.foPageSequenceComplete to the LayoutStrategy implementation (layoutmgr/LayoutManagerLS)
Revision Changes Path
1.6 +5 -11 xml-fop/src/java/org/apache/fop/control/Document.java
Index: Document.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/control/Document.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Document.java 20 Aug 2003 16:35:27 -0000 1.5
+++ Document.java 20 Aug 2003 17:25:43 -0000 1.6
@@ -63,7 +63,6 @@
import org.apache.fop.fo.FOTreeEvent;
import org.apache.fop.fo.FOTreeListener;
import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.area.Title;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.layout.LayoutStrategy;
@@ -94,7 +93,7 @@
* TODO: this actually belongs in the RenderContext class, when it is
* created
*/
- private LayoutStrategy ls = null;
+ private LayoutStrategy layoutStrategy = null;
/**
* The current AreaTree for the PageSequence being rendered.
@@ -294,14 +293,14 @@
* @param ls the LayoutStrategy object to be used to process this Document
*/
public void setLayoutStrategy(LayoutStrategy ls) {
- this.ls = ls;
+ this.layoutStrategy = ls;
}
/**
* @return this Document's LayoutStrategy object
*/
public LayoutStrategy getLayoutStrategy () {
- return ls;
+ return layoutStrategy;
}
public Driver getDriver() {
@@ -316,12 +315,7 @@
*/
public void foPageSequenceComplete (FOTreeEvent event) throws FOPException {
PageSequence pageSeq = event.getPageSequence();
- Title title = null;
- if (pageSeq.getTitleFO() != null) {
- title = pageSeq.getTitleFO().getTitleArea();
- }
- areaTree.startPageSequence(title);
- pageSeq.format(areaTree);
+ layoutStrategy.format(pageSeq, areaTree);
}
/**
1.8 +20 -52 xml-fop/src/java/org/apache/fop/fo/pagination/PageSequence.java
Index: PageSequence.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/PageSequence.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PageSequence.java 19 Aug 2003 00:53:54 -0000 1.7
+++ PageSequence.java 20 Aug 2003 17:25:43 -0000 1.8
@@ -358,59 +358,9 @@
}
/**
- * Runs the formatting of this page sequence into the given area tree
- *
- * @param areaTree the area tree to format this page sequence into
- * @throws FOPException if there is an error formatting the contents
- */
- public void format(AreaTree areaTree) throws FOPException {
- // Make a new PageLayoutManager and a FlowLayoutManager
- // Run the PLM in a thread
- // Wait for them to finish.
-
- // If no main flow, nothing to layout!
- if (this.mainFlow == null) {
- return;
- }
-
- // Initialize if already used?
- // this.layoutMasterSet.resetPageMasters();
- if (pageSequenceMaster != null) {
- pageSequenceMaster.reset();
- }
-
- int firstAvailPageNumber = 0;
- initPageNumber();
-
- // This will layout pages and add them to the area tree
- PageLayoutManager pageLM = new PageLayoutManager(areaTree, this);
- pageLM.setUserAgent(getUserAgent());
- pageLM.setFObj(this);
- pageLM.setPageCounting(currentPageNumber, pageNumberGenerator);
-
- // For now, skip the threading and just call run directly.
- pageLM.run();
-
- // Thread layoutThread = new Thread(pageLM);
-// layoutThread.start();
-// log.debug("Layout thread started");
-
-// // wait on both managers
-// try {
-// layoutThread.join();
-// log.debug("Layout thread done");
-// } catch (InterruptedException ie) {
-// log.error("PageSequence.format() interrupted waiting on layout");
-// }
- this.currentPageNumber = pageLM.getPageCount();
- // Tell the root the last page number we created.
- this.root.setRunningPageNumberCounter(this.currentPageNumber);
- }
-
- /**
* Initialize the current page number for the start of the page sequence.
*/
- private void initPageNumber() {
+ public void initPageNumber() {
this.currentPageNumber = this.root.getRunningPageNumberCounter() + 1;
if (this.pageNumberType == AUTO_ODD) {
@@ -826,5 +776,23 @@
fotv.serveVisitor(this);
}
-}
+ public Flow getMainFlow() {
+ return mainFlow;
+ }
+
+ public PageSequenceMaster getPageSequenceMaster() {
+ return pageSequenceMaster;
+ }
+
+ public PageNumberGenerator getPageNumberGenerator() {
+ return pageNumberGenerator;
+ }
+
+ public void setCurrentPageNumber(int currentPageNumber) {
+ this.currentPageNumber = currentPageNumber;
+ }
+ public Root getRoot() {
+ return root;
+ }
+}
1.7 +1 -1 xml-fop/src/java/org/apache/fop/fo/pagination/Root.java
Index: Root.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Root.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Root.java 19 Aug 2003 05:19:21 -0000 1.6
+++ Root.java 20 Aug 2003 17:25:43 -0000 1.7
@@ -97,7 +97,7 @@
* Sets the overall page number counter.
* @param count the new page count
*/
- protected void setRunningPageNumberCounter(int count) {
+ public void setRunningPageNumberCounter(int count) {
this.runningPageNumberCounter = count;
}
1.3 +7 -1 xml-fop/src/java/org/apache/fop/layout/LayoutStrategy.java
Index: LayoutStrategy.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layout/LayoutStrategy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LayoutStrategy.java 19 Aug 2003 00:53:54 -0000 1.2
+++ LayoutStrategy.java 20 Aug 2003 17:25:43 -0000 1.3
@@ -51,6 +51,10 @@
package org.apache.fop.layout;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.area.AreaTree;
+import org.apache.fop.fo.pagination.PageSequence;
+
/**
* Abstract class defining the highest-level information for a layout strategy.
* Subclasses implement a layout strategy that converts an FO Tree into an
@@ -68,4 +72,6 @@
return name;
}
+ public abstract void format (PageSequence pageSeq, AreaTree areaTree)
+ throws FOPException;
}
1.3 +61 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java
Index: LayoutManagerLS.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LayoutManagerLS.java 19 Aug 2003 00:53:54 -0000 1.2
+++ LayoutManagerLS.java 20 Aug 2003 17:25:44 -0000 1.3
@@ -50,7 +50,11 @@
*/
package org.apache.fop.layoutmgr;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.layout.LayoutStrategy;
+import org.apache.fop.area.AreaTree;
+import org.apache.fop.area.Title;
+import org.apache.fop.fo.pagination.PageSequence;
/**
* The implementation of LayoutStrategy for the "redesign" or second generation
@@ -59,5 +63,61 @@
public class LayoutManagerLS extends LayoutStrategy {
private static String name = "layoutmgr";
+
+ /**
+ * Runs the formatting of this page sequence into the given area tree
+ *
+ * @param areaTree the area tree to format this page sequence into
+ * @throws FOPException if there is an error formatting the contents
+ */
+ public void format(PageSequence pageSeq, AreaTree areaTree) throws FOPException {
+ Title title = null;
+ if (pageSeq.getTitleFO() != null) {
+ title = pageSeq.getTitleFO().getTitleArea();
+ }
+ areaTree.startPageSequence(title);
+ // Make a new PageLayoutManager and a FlowLayoutManager
+ // Run the PLM in a thread
+ // Wait for them to finish.
+
+ // If no main flow, nothing to layout!
+ if (pageSeq.getMainFlow() == null) {
+ return;
+ }
+
+ // Initialize if already used?
+ // this.layoutMasterSet.resetPageMasters();
+ if (pageSeq.getPageSequenceMaster() != null) {
+ pageSeq.getPageSequenceMaster().reset();
+ }
+
+ int firstAvailPageNumber = 0;
+ pageSeq.initPageNumber();
+
+ // This will layout pages and add them to the area tree
+ PageLayoutManager pageLM = new PageLayoutManager(areaTree, pageSeq);
+ pageLM.setUserAgent(pageSeq.getUserAgent());
+ pageLM.setFObj(pageSeq);
+ pageLM.setPageCounting(pageSeq.getCurrentPageNumber(),
+ pageSeq.getPageNumberGenerator());
+
+ // For now, skip the threading and just call run directly.
+ pageLM.run();
+
+ // Thread layoutThread = new Thread(pageLM);
+// layoutThread.start();
+// log.debug("Layout thread started");
+
+// // wait on both managers
+// try {
+// layoutThread.join();
+// log.debug("Layout thread done");
+// } catch (InterruptedException ie) {
+// log.error("PageSequence.format() interrupted waiting on layout");
+// }
+ pageSeq.setCurrentPageNumber(pageLM.getPageCount());
+ // Tell the root the last page number we created.
+ pageSeq.getRoot().setRunningPageNumberCounter(pageSeq.getCurrentPageNumber());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org