diff options
author | Karen Lease <klease@apache.org> | 2001-11-09 22:12:34 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-11-09 22:12:34 +0000 |
commit | 436971e03e6b9cbcb610fe2c6e9406a4e53c724c (patch) | |
tree | 3a5ba85bd0a682117f1afb8dc8b0178746212b1d /src | |
parent | 671cd7fedc4e62aa6f75e240bbb020e79ce921f5 (diff) | |
download | xmlgraphics-fop-436971e03e6b9cbcb610fe2c6e9406a4e53c724c.tar.gz xmlgraphics-fop-436971e03e6b9cbcb610fe2c6e9406a4e53c724c.zip |
Base classes for before/after, start/end Region
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194547 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/org/apache/fop/fo/pagination/RegionBA.java | 56 | ||||
-rw-r--r-- | src/org/apache/fop/fo/pagination/RegionBASE.java | 35 | ||||
-rw-r--r-- | src/org/apache/fop/fo/pagination/RegionSE.java | 45 |
3 files changed, 136 insertions, 0 deletions
diff --git a/src/org/apache/fop/fo/pagination/RegionBA.java b/src/org/apache/fop/fo/pagination/RegionBA.java new file mode 100644 index 000000000..db526e765 --- /dev/null +++ b/src/org/apache/fop/fo/pagination/RegionBA.java @@ -0,0 +1,56 @@ +/* + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.fo.pagination; + +// FOP +import org.apache.fop.fo.*; +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.Precedence; + +import java.awt.Rectangle; + +public abstract class RegionBA extends RegionBASE { + + private boolean bPrecedence; + + protected RegionBA(FONode parent) { + super(parent); + } + + boolean getPrecedence() { + return bPrecedence; + } + + public void end() { + bPrecedence = + (this.properties.get("precedence").getEnum()==Precedence.TRUE); + } + + /** + * Adjust the viewport reference rectangle for a region as a function + * of precedence. + * If precedence is false on a before or after region, its + * inline-progression-dimension is limited by the extent of the start + * and end regions if they are present. + */ + protected void adjustIPD(Rectangle vpRect) { + int xoff = 0; + Region start = getSiblingRegion(Region.START); + if (start != null) { + xoff = start.getExtent(); + vpRect.translate(xoff, 0); + } + Region end =getSiblingRegion(Region.END); + if (end != null) { + xoff += end.getExtent(); + } + if (xoff > 0) { + vpRect.grow(-xoff,0); + } + } +} diff --git a/src/org/apache/fop/fo/pagination/RegionBASE.java b/src/org/apache/fop/fo/pagination/RegionBASE.java new file mode 100644 index 000000000..8ca69e7f1 --- /dev/null +++ b/src/org/apache/fop/fo/pagination/RegionBASE.java @@ -0,0 +1,35 @@ +/* + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.fo.pagination; + +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.apps.FOPException; + +/** + * Base class for Before, After, Start and End regions (BASE). + */ +public abstract class RegionBASE extends Region { + + private int extent; + + protected RegionBASE(FONode parent) { + super(parent); + } + + public void end() { + // The problem with this is that it might not be known yet.... + // Supposing extent is calculated in terms of percentage + this.extent = this.properties.get("extent").getLength().mvalue(); + } + + int getExtent() { + return this.extent; + } +} diff --git a/src/org/apache/fop/fo/pagination/RegionSE.java b/src/org/apache/fop/fo/pagination/RegionSE.java new file mode 100644 index 000000000..92db1075d --- /dev/null +++ b/src/org/apache/fop/fo/pagination/RegionSE.java @@ -0,0 +1,45 @@ +/* + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.fo.pagination; + + +import org.apache.fop.fo.*; +import org.apache.fop.apps.FOPException; + +import java.awt.Rectangle; + +public abstract class RegionSE extends RegionBASE { + + protected RegionSE(FONode parent) { + super(parent); + } + + /** + * Adjust the viewport reference rectangle for a region as a function + * of precedence. + * If before and after have precedence = true, the start and end + * regions only go to the limits of their extents, otherwise + * they extend in the BPD to the page reference rectangle + * diminish by extend of start and end if present. + */ + protected void adjustIPD(Rectangle refRect) { + int yoff = 0; + Region before = getSiblingRegion(Region.BEFORE); + if (before != null && before.getPrecedence()) { + yoff = before.getExtent(); + refRect.translate(0, yoff); + } + Region after = getSiblingRegion(Region.AFTER); + if (after != null && after.getPrecedence()) { + yoff += after.getExtent(); + } + if (yoff > 0) { + refRect.grow(0,-yoff); + } + } +} |