[FOray-commit] SF.net SVN: foray: [9558] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-05-21 23:43:00
|
Revision: 9558
http://svn.sourceforge.net/foray/?rev=9558&view=rev
Author: victormote
Date: 2007-05-21 16:43:01 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Move testing of leader length minimum <= optimum <= maximum rule from Fo Tree to Area Tree.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Leader.java
trunk/foray/foray-layout/src/java/org/foray/layout/LayoutStrategy.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java 2007-05-21 22:44:59 UTC (rev 9557)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/InlineArea.java 2007-05-21 23:43:01 UTC (rev 9558)
@@ -29,6 +29,7 @@
package org.foray.area;
import org.axsl.areaR.RenderVisitor;
+import org.axsl.areaW.AreaWException;
import org.axsl.foR.FoText;
import org.axsl.foR.fo.ExternalGraphic;
import org.axsl.foR.fo.GraftingPoint;
@@ -150,7 +151,7 @@
*/
public LeaderArea makeLeaderArea(
final Leader leader, final int ipd,
- final GraftingPoint graftingPoint) {
+ final GraftingPoint graftingPoint) throws AreaWException {
final LeaderArea newLeaderArea = LeaderArea.makeLeaderArea(leader, this,
graftingPoint, ipd);
this.children.add(newLeaderArea);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2007-05-21 22:44:59 UTC (rev 9557)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2007-05-21 23:43:01 UTC (rev 9558)
@@ -29,6 +29,7 @@
package org.foray.area;
import org.axsl.areaR.RenderVisitor;
+import org.axsl.areaW.AreaWException;
import org.axsl.common.value.LeaderAlignment;
import org.axsl.common.value.LeaderPattern;
import org.axsl.common.value.RuleStyle;
@@ -104,16 +105,31 @@
* area.
* @param initialProgressionDimension The initial size, in millipoints,
* of this Area.
+ * @throws AreaWException If the minimum length is greater than the optimum
+ * length, or if the optimum length is greater than the maximum length.
*/
private static void initLeaderArea(final LeaderArea newLeaderArea,
final Leader generatedBy, final GraftingPoint graftingPoint,
- final int initialProgressionDimension) {
+ final int initialProgressionDimension) throws AreaWException {
newLeaderArea.generatedBy = newLeaderArea.linkage(generatedBy,
graftingPoint);
newLeaderArea.registerWithLinkage(graftingPoint);
newLeaderArea.initializeProgressionDimension();
newLeaderArea.initializeAnteriorSpace();
newLeaderArea.init(initialProgressionDimension);
+
+ /* This cannot be fully validated during FO parsing because percentages
+ * cannot be resolved entirely there, so we validate it here. */
+ if (newLeaderArea.traitLeaderLengthMin()
+ > newLeaderArea.traitLeaderLengthOpt()) {
+ throw new AreaWException("leader-length.minimum may not exceed "
+ + "leader-length.optimum");
+ }
+ if (newLeaderArea.traitLeaderLengthOpt()
+ > newLeaderArea.traitLeaderLengthMax()) {
+ throw new AreaWException("leader-length.optimum may not exceed "
+ + "leader-length.maximum");
+ }
}
/**
@@ -125,11 +141,13 @@
* @param initialProgressionDimension The initial size, in millipoints,
* of this Area.
* @return The new instance.
+ * @throws AreaWException If the minimum length is greater than the optimum
+ * length, or if the optimum length is greater than the maximum length.
*/
static LeaderArea makeLeaderArea(final Leader generatedBy,
final LineArea parentArea,
final GraftingPoint graftingPoint,
- final int initialProgressionDimension) {
+ final int initialProgressionDimension) throws AreaWException {
final LeaderArea newLeaderArea = new LeaderArea(parentArea);
LeaderArea.initLeaderArea(newLeaderArea, generatedBy, graftingPoint,
initialProgressionDimension);
@@ -145,11 +163,13 @@
* @param initialProgressionDimension The initial size, in millipoints,
* of this Area.
* @return The new instance.
+ * @throws AreaWException If the minimum length is greater than the optimum
+ * length, or if the optimum length is greater than the maximum length.
*/
static LeaderArea makeLeaderArea(final Leader generatedBy,
final AbstractInlineArea parentArea,
final GraftingPoint graftingPoint,
- final int initialProgressionDimension) {
+ final int initialProgressionDimension) throws AreaWException {
final LeaderArea newLeaderArea = new LeaderArea(parentArea);
LeaderArea.initLeaderArea(newLeaderArea, generatedBy, graftingPoint,
initialProgressionDimension);
@@ -399,7 +419,7 @@
*/
public LeaderArea makeLeaderArea(
final Leader leader, final int ipd,
- final GraftingPoint graftingPoint) {
+ final GraftingPoint graftingPoint) throws AreaWException {
final LeaderArea newLeaderArea = LeaderArea.makeLeaderArea(leader, this,
graftingPoint, ipd);
this.children.add(newLeaderArea);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2007-05-21 22:44:59 UTC (rev 9557)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2007-05-21 23:43:01 UTC (rev 9558)
@@ -990,9 +990,8 @@
/**
* {@inheritDoc}
*/
- public LeaderArea makeLeaderArea(
- final Leader leader, final int ipd,
- final GraftingPoint graftingPoint) {
+ public LeaderArea makeLeaderArea(final Leader leader, final int ipd,
+ final GraftingPoint graftingPoint) throws AreaWException {
final LeaderArea newLeaderArea = LeaderArea.makeLeaderArea(leader, this,
graftingPoint, ipd);
this.children.add(newLeaderArea);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Leader.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Leader.java 2007-05-21 22:44:59 UTC (rev 9557)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Leader.java 2007-05-21 23:43:01 UTC (rev 9558)
@@ -49,22 +49,6 @@
*/
public class Leader extends FObjMixed implements org.axsl.foR.fo.Leader {
- /** A constant IPD value used for testing submitted property values. */
- private static final int TEST_IPD = 1000000;
-
- /** A static context useful for testing submitted property values. */
- private static final FoContext TEST_CONTEXT = new FoContext() {
- public GraftingPoint getGraftingPoint() {
- return null;
- }
- public int ipdNearestBlockLevel() {
- return 0;
- }
- public int bpdNearestBlockLevel() {
- return TEST_IPD;
- }
- };
-
/** The parent of this node. */
private FObj parent;
@@ -92,19 +76,10 @@
* {@inheritDoc}
*/
protected void validateProperties() throws FoTreeException {
- /* Using a null context here is OK, because we are not computing
- * a length to be used anywhere, only testing the relative values of
- * the min, max, and optimum. */
- if (traitLeaderLengthMin(TEST_CONTEXT)
- > traitLeaderLengthOpt(TEST_CONTEXT)) {
- throwException("leader-length.minimum may not exceed "
- + "leader-length.optimum");
- }
- if (traitLeaderLengthOpt(TEST_CONTEXT)
- > traitLeaderLengthMax(TEST_CONTEXT)) {
- throwException("leader-length.optimum may not exceed "
- + "leader-length.maximum");
- }
+ /* It is tempting, but not possible, to test that minimum <= optimum
+ * <= maximum, because of the possibility of percentages.
+ * TODO: Consider adding the above tests for the case where percentages
+ * do not exist in the actual data. */
}
/**
Modified: trunk/foray/foray-layout/src/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/java/org/foray/layout/LayoutStrategy.java 2007-05-21 22:44:59 UTC (rev 9557)
+++ trunk/foray/foray-layout/src/java/org/foray/layout/LayoutStrategy.java 2007-05-21 23:43:01 UTC (rev 9558)
@@ -185,7 +185,11 @@
graftingPoint);
} else if (nonTextToUse instanceof Leader) {
final Leader leader = (Leader) nonTextToUse;
- lineArea.makeLeaderArea(leader, sizeInline, graftingPoint);
+ try {
+ lineArea.makeLeaderArea(leader, sizeInline, graftingPoint);
+ } catch (final AreaWException e) {
+ throw new TextException(e);
+ }
} else if (nonTextToUse instanceof PageNumberCitation) {
final PageNumberCitation citation = (PageNumberCitation)
nonTextToUse;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|