Revision: 7868
http://svn.sourceforge.net/foray/?rev=7868&view=rev
Author: victormote
Date: 2006-09-03 12:29:50 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
Add and use infrastructure allowing better validation of sub-sequence specifiers and better integration between page sequencing and flows.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceTemplate.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -58,6 +58,15 @@
if (name == null || name.equals("")) {
throwException(getFullName() + "requires a 'flow-name'.");
}
+ /* Make sure that this flow name can be laid out on every page that can
+ * be created in the page-sequence. */
+ final AbstractPageMaster problemPage = getPageSequence().flowValid(
+ this);
+ if (problemPage != null) {
+ throwException(this.getFullName() + " '" + traitFlowName()
+ + "' cannot flow into page-master '"
+ + problemPage.traitMasterName() + "'");
+ }
}
public boolean isRAGenerator() {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -60,4 +60,12 @@
}
}
+ /**
+ * Indicates whether this page has a region matching a given flow name.
+ * @param flowName The flow name sought.
+ * @return True iff this page has a region whose name matches
+ * <tt>flowName</tt>.
+ */
+ public abstract boolean hasRegion(String flowName);
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -34,6 +34,8 @@
import org.axsl.foR.fo.Flow;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
/**
* A "page-sequence" object in XSL-FO.
@@ -264,4 +266,29 @@
return null;
}
+ /**
+ * Make sure that a given flow can be laid out on every page in this
+ * page-sequence.
+ * @param flow The abstract flow to be tested.
+ * @return The first page-master detected which cannot take content from
+ * <tt>flow</tt>, or null if the flow can be laid out on all pages.
+ */
+ protected AbstractPageMaster flowValid(final AbstractFlow flow) {
+ final Set pageMasters;
+ if (this.getSimplePageMaster() != null) {
+ pageMasters = this.getSimplePageMaster().getPages();
+ } else {
+ pageMasters = this.getPageSequenceMaster().getPages();
+ }
+ final Iterator iterator = pageMasters.iterator();
+ while (iterator.hasNext()) {
+ final AbstractPageMaster pageMaster = (AbstractPageMaster)
+ iterator.next();
+ if (! pageMaster.hasRegion(flow.traitFlowName())) {
+ return pageMaster;
+ }
+ }
+ return null;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -33,10 +33,13 @@
import org.axsl.foR.FOTreeException;
import org.axsl.foR.ProxyFactory;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* A "page-sequence-master" object in XSL-FO.
*/
-public class PageSequenceMaster extends FObj {
+public class PageSequenceMaster extends FObj implements PageSequenceTemplate {
private SubSequenceSpecifier currentSubSequence;
@@ -189,4 +192,17 @@
return factory.makeProxy(this);
}
+ /**
+ * {@inheritDoc}
+ */
+ public Set getPages() {
+ final Set returnSet = new HashSet();
+ for (int i = 0; i < this.children.size(); i++) {
+ final Object child = this.children.get(i);
+ final SubSequenceSpecifier specifier = (SubSequenceSpecifier) child;
+ returnSet.addAll(specifier.getPages());
+ }
+ return returnSet;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceTemplate.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceTemplate.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceTemplate.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -24,6 +24,8 @@
package org.foray.fotree.fo.obj;
+import java.util.Set;
+
/**
* Abstraction of the formatting objects that can be used as a template to
* generate sequences of pages for a page-sequence.
@@ -37,6 +39,6 @@
* @return The page-master instances that can be generated from this
* template.
*/
- AbstractPageMaster[] getPages() ;
+ Set getPages() ;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -34,6 +34,9 @@
import org.axsl.foR.FOTreeException;
import org.axsl.foR.ProxyFactory;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* A "repeatable-page-master-alternatives" object in XSL-FO.
*/
@@ -123,4 +126,30 @@
return factory.makeProxy(this);
}
+ /**
+ * The parent.
+ * @return The parent, properly cast.
+ */
+ public PageSequenceMaster pageSequenceMaster() {
+ /* Cast verified at construction. */
+ return (PageSequenceMaster) this.parentFO();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getPages() {
+ final Set returnSet = new HashSet();
+ final LayoutMasterSet layoutSet = this.pageSequenceMaster()
+ .layoutMasterSet();
+ for (int i = 0; i < this.children.size(); i++) {
+ final ConditionalPageMasterReference conditional =
+ (ConditionalPageMasterReference) this.children.get(i);
+ final AbstractPageMaster pageMaster = layoutSet.getSimplePageMaster(
+ conditional.traitMasterReference());
+ returnSet.add(pageMaster);
+ }
+ return returnSet;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -34,6 +34,9 @@
import org.axsl.foR.FOTreeException;
import org.axsl.foR.ProxyFactory;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* A "repeatable-page-master-reference" object in XSL-FO.
*/
@@ -120,4 +123,26 @@
return factory.makeProxy(this);
}
+ /**
+ * The parent.
+ * @return The parent, properly cast.
+ */
+ public PageSequenceMaster pageSequenceMaster() {
+ /* Cast verified at construction. */
+ return (PageSequenceMaster) this.parentFO();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getPages() {
+ final Set returnSet = new HashSet(1);
+ final LayoutMasterSet layoutSet = this.pageSequenceMaster()
+ .layoutMasterSet();
+ final AbstractPageMaster pageMaster = layoutSet.getSimplePageMaster(
+ this.traitMasterReference());
+ returnSet.add(pageMaster);
+ return returnSet;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -33,11 +33,14 @@
import org.axsl.foR.FOTreeException;
import org.axsl.foR.ProxyFactory;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* A "simple-page-master" object in XSL-FO.
*/
public class SimplePageMaster extends AbstractPageMaster
- implements org.axsl.foR.fo.SimplePageMaster {
+ implements org.axsl.foR.fo.SimplePageMaster, PageSequenceTemplate {
// Fallback values for "auto" page size: 8x11in
public static final int FALLBACK_PAGE_HEIGHT = 792000;
public static final int FALLBACK_PAGE_WIDTH = 576000;
@@ -274,4 +277,26 @@
return factory.makeProxy(this);
}
+ /**
+ * {@inheritDoc}
+ */
+ public Set getPages() {
+ final Set returnSet = new HashSet(1);
+ returnSet.add(this);
+ return returnSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasRegion(final String flowName) {
+ for (int i = 0; i < this.children.size(); i++) {
+ final Region region = (Region) this.children.get(i);
+ if (region.traitRegionName().equals(flowName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -32,7 +32,10 @@
import org.axsl.foR.FOTreeException;
import org.axsl.foR.ProxyFactory;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* A "single-page-master-reference" object in XSl-FO.
*/
@@ -125,4 +128,17 @@
return factory.makeProxy(this);
}
+ /**
+ * {@inheritDoc}
+ */
+ public Set getPages() {
+ final Set returnSet = new HashSet(1);
+ final LayoutMasterSet layoutSet = this.pageSequenceMaster()
+ .layoutMasterSet();
+ final AbstractPageMaster pageMaster = layoutSet.getSimplePageMaster(
+ this.traitMasterReference());
+ returnSet.add(pageMaster);
+ return returnSet;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-03 18:43:33 UTC (rev 7867)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-03 19:29:50 UTC (rev 7868)
@@ -26,6 +26,8 @@
import org.axsl.foR.FOTreeException;
+import java.util.Set;
+
/**
* Interface specifying requirements for a sub-sequence-specifier in XSL-FO,
* that is, items capable of looking up an appropriate PageMaster.
@@ -45,4 +47,11 @@
* with the method of the same signature in FONode. */
void reset();
+ /**
+ * Returns the page-master instances that are included in this template.
+ * @return The page-master instances that can be generated from this
+ * template.
+ */
+ Set getPages() ;
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|