Revision: 7852
http://svn.sourceforge.net/foray/?rev=7852&view=rev
Author: victormote
Date: 2006-09-02 11:10:09 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
Conform to axsl changes that create a PageMasterResolver class that handle the layout-time issues of keeping track of which page master should be used next.
Added Paths:
-----------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java 2006-09-02 18:10:09 UTC (rev 7852)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/* $Id$ */
+
+package org.foray.fotree.fo.obj;
+
+import org.axsl.foR.FOTreeException;
+import org.axsl.foR.fo.Flow;
+import org.axsl.foR.fo.SimplePageMaster;
+
+/**
+ * Provides pages sequentially for a given {@link PageSequence}.
+ * Implementations may keep track of state information, that is, what
+ * sub-sequence specifiers have already been exhausted and partially exhausted.
+ * Therefore, only one instance of {@link PageMasterResolver} should be used for
+ * a given layout of a {@link PageSequence}.
+ */
+public class PageMasterResolver implements org.axsl.foR.fo.PageMasterResolver {
+
+ /** The parent page-sequence. */
+ private PageSequence pageSequence;
+
+ private int lastDocumentPageNumber = 0;
+
+ public PageMasterResolver(final PageSequence pageSequence,
+ final int lastPageNumber) {
+ this.pageSequence = pageSequence;
+ this.lastDocumentPageNumber = lastPageNumber;
+ this.lastDocumentPageNumber = Math.max(this.lastDocumentPageNumber, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SimplePageMaster getNextPageMaster(final boolean isBlank)
+ throws FOTreeException {
+
+ org.foray.fotree.fo.obj.SimplePageMaster spm = getSimplePageMaster();
+ if (spm != null) {
+ return spm;
+ }
+ final PageSequenceMaster psm = getPageSequenceMaster();
+ if (psm == null) {
+ return null;
+ }
+ final Flow flow = getFlow();
+ this.lastDocumentPageNumber ++;
+ spm = psm.getNextSimplePageMaster(
+ ((this.lastDocumentPageNumber % 2) == 1), isBlank);
+ final Region region = (Region) spm.getRegionBody();
+ if (!flow.traitFlowName().equals(region.traitRegionName())) {
+ throw new FOTreeException("Flow '" + flow.traitFlowName()
+ + "' does not map to the region-body in page-master '"
+ + spm.traitMasterName() + "'");
+ }
+ return spm;
+ }
+
+ private org.foray.fotree.fo.obj.SimplePageMaster getSimplePageMaster() {
+ return this.pageSequence.getSimplePageMaster();
+ }
+
+ private PageSequenceMaster getPageSequenceMaster() {
+ return this.pageSequence.getPageSequenceMaster();
+ }
+
+ private Flow getFlow() {
+ return this.pageSequence.getFlow();
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|