klease 01/11/09 14:31:51 Modified: src/org/apache/fop/fo/pagination SimplePageMaster.java RegionStart.java RegionEnd.java RegionBefore.java RegionAfter.java RegionBody.java Region.java Log: Rework the page creation process and prepare to use layout managers Revision Changes Path 1.18 +64 -80 xml-fop/src/org/apache/fop/fo/pagination/SimplePageMaster.java Index: SimplePageMaster.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/SimplePageMaster.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- SimplePageMaster.java 2001/11/09 11:32:40 1.17 +++ SimplePageMaster.java 2001/11/09 22:31:50 1.18 @@ -1,5 +1,5 @@ /* - * $Id: SimplePageMaster.java,v 1.17 2001/11/09 11:32:40 keiron Exp $ + * $Id: SimplePageMaster.java,v 1.18 2001/11/09 22:31:50 klease Exp $ * 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. @@ -10,16 +10,20 @@ // FOP import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.PageMaster; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BodyRegionArea; +import org.apache.fop.area.PageViewport; +import org.apache.fop.area.Page; +import org.apache.fop.area.RegionViewport; +import org.apache.fop.area.RegionReference; import org.apache.fop.layout.MarginProps; +import org.apache.fop.layout.PageMaster; import org.apache.fop.apps.FOPException; - -import java.util.*; +import java.awt.Rectangle; +import java.util.Hashtable; +import java.util.Enumeration; import org.xml.sax.Attributes; + public class SimplePageMaster extends FObj { /** @@ -31,12 +35,6 @@ PageMaster pageMaster; String masterName; - // before and after data as required by start and end - boolean beforePrecedence; - int beforeHeight; - boolean afterPrecedence; - int afterHeight; - public SimplePageMaster(FONode parent) { super(parent); } @@ -73,69 +71,41 @@ // Common Margin Properties-Block MarginProps mProps = propMgr.getMarginProps(); - int contentRectangleXPosition = mProps.marginLeft; - int contentRectangleYPosition = pageHeight - mProps.marginTop; - int contentRectangleWidth = pageWidth - mProps.marginLeft - - mProps.marginRight; - int contentRectangleHeight = pageHeight - mProps.marginTop - - mProps.marginBottom; - - this.pageMaster = new PageMaster(pageWidth, pageHeight); - if (getRegion(RegionBody.REGION_CLASS) != null) { - BodyRegionArea body = - (BodyRegionArea)getRegion(RegionBody.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, - contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addBody(body); - } else { - log.error("simple-page-master must have a region of class " - + RegionBody.REGION_CLASS); - } - - if (getRegion(RegionBefore.REGION_CLASS) != null) { - RegionArea before = - getRegion(RegionBefore.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addBefore(before); - beforePrecedence = - ((RegionBefore)getRegion(RegionBefore.REGION_CLASS)).getPrecedence(); - beforeHeight = before.getHeight(); - } else { - beforePrecedence = false; - } - - if (getRegion(RegionAfter.REGION_CLASS) != null) { - RegionArea after = - getRegion(RegionAfter.REGION_CLASS).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight); - this.pageMaster.addAfter(after); - afterPrecedence = - ((RegionAfter)getRegion(RegionAfter.REGION_CLASS)).getPrecedence(); - afterHeight = after.getHeight(); - } else { - afterPrecedence = false; - } - - if (getRegion(RegionStart.REGION_CLASS) != null) { - RegionArea start = - ((RegionStart)getRegion(RegionStart.REGION_CLASS)).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight, beforePrecedence, - afterPrecedence, beforeHeight, afterHeight); - this.pageMaster.addStart(start); - } - - if (getRegion(RegionEnd.REGION_CLASS) != null) { - RegionArea end = - ((RegionEnd)getRegion(RegionEnd.REGION_CLASS)).makeRegionArea(contentRectangleXPosition, - contentRectangleYPosition, contentRectangleWidth, - contentRectangleHeight, beforePrecedence, - afterPrecedence, beforeHeight, afterHeight); - this.pageMaster.addEnd(end); - } + /* Create the page reference area rectangle in first quadrant coordinates + * (ie, 0,0 is at bottom,left of the "page meida" and y increases + * when moving towards the top of the page. + * The media rectangle itself is (0,0,pageWidth,pageHeight). + */ + Rectangle pageRefRect = + new Rectangle(mProps.marginLeft, pageHeight - mProps.marginTop, + pageWidth - mProps.marginLeft - mProps.marginRight, + pageHeight - mProps.marginTop - mProps.marginBottom); + + // ??? KL shouldn't this take the viewport too??? + Page page = new Page(); // page reference area + + // Create a RegionViewport/ reference area pair for each page region + + boolean bHasBody=false; + + for (Enumeration regenum = _regions.elements(); + regenum.hasMoreElements(); ) { + Region r = (Region)regenum.nextElement(); + RegionViewport rvp = r.makeRegionViewport(pageRefRect); + rvp.setRegion(r.makeRegionReferenceArea()); + page.setRegion(r.getRegionAreaClass(), rvp); + if (r.getRegionAreaClass() == RegionReference.BODY) { + bHasBody = true; + } + } + + if (!bHasBody) { + log.error("simple-page-master has no region-body"); + } + + this.pageMaster = new PageMaster(new PageViewport(page, + new Rectangle(0,0, + pageWidth,pageHeight))); } public PageMaster getPageMaster() { @@ -150,14 +120,28 @@ return masterName; } + + protected void addChild(FONode child) { + if (child instanceof Region) { + addRegion((Region)child); + } + else { + log.error("SimplePageMaster cannot have child of type " + + child.getName()); + } + } - protected void addRegion(Region region) throws FOPException { - if (_regions.containsKey(region.getRegionClass())) { - throw new FOPException("Only one region of class " - + region.getRegionClass() + protected void addRegion(Region region) { + String key = region.getRegionClass(); + if (_regions.containsKey(key)) { + log.error("Only one region of class " + + key + " allowed within a simple-page-master."); + // throw new FOPException("Only one region of class " +// + key +// + " allowed within a simple-page-master."); } else { - _regions.put(region.getRegionClass(), region); + _regions.put(key, region); } } 1.6 +18 -52 xml-fop/src/org/apache/fop/fo/pagination/RegionStart.java Index: RegionStart.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionStart.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RegionStart.java 2001/11/09 11:32:40 1.5 +++ RegionStart.java 2001/11/09 22:31:50 1.6 @@ -1,5 +1,5 @@ /* - * $Id: RegionStart.java,v 1.5 2001/11/09 11:32:40 keiron Exp $ + * $Id: RegionStart.java,v 1.6 2001/11/09 22:31:50 klease Exp $ * 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." @@ -7,77 +7,43 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + + // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; -public class RegionStart extends Region { +public class RegionStart extends RegionSE { - public static final String REGION_CLASS = "start"; public RegionStart(FONode parent) { super(parent); } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight, - boolean beforePrecedence, - boolean afterPrecedence, int beforeHeight, - int afterHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); - - int startY = allocationRectangleYPosition; - int startH = allocationRectangleHeight; - if (beforePrecedence) { - startY -= beforeHeight; - startH -= beforeHeight; - } - if (afterPrecedence) - startH -= afterHeight; - return new RegionArea(allocationRectangleXPosition, startY, extent, - startH); - } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return makeRegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent, false, false, - 0, 0); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX(), + (int)pageRefRect.getY(), + getExtent(), (int)pageRefRect.getHeight()); + adjustIPD(vpRect); + return vpRect; } protected String getDefaultRegionName() { return "xsl-region-start"; } - protected String getElementName() { - return "fo:region-start"; + public String getRegionClass() { + return Region.START; } - public String getRegionClass() { - return REGION_CLASS; + public int getRegionAreaClass() { + return RegionReference.START; } } 1.6 +21 -53 xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java Index: RegionEnd.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionEnd.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RegionEnd.java 2001/11/09 11:32:40 1.5 +++ RegionEnd.java 2001/11/09 22:31:50 1.6 @@ -1,5 +1,5 @@ /* - * $Id: RegionEnd.java,v 1.5 2001/11/09 11:32:40 keiron Exp $ + * $Id: RegionEnd.java,v 1.6 2001/11/09 22:31:50 klease Exp $ * 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. @@ -7,78 +7,46 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; + -public class RegionEnd extends Region { +public class RegionEnd extends RegionSE { - public static final String REGION_CLASS = "end"; public RegionEnd(FONode parent) { super(parent); } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight, - boolean beforePrecedence, - boolean afterPrecedence, int beforeHeight, - int afterHeight) { - int extent = this.properties.get("extent").getLength().mvalue(); - - int startY = allocationRectangleYPosition; - int startH = allocationRectangleHeight; - if (beforePrecedence) { - startY -= beforeHeight; - startH -= beforeHeight; - } - if (afterPrecedence) - startH -= afterHeight; - return new RegionArea(allocationRectangleXPosition - + allocationRectangleWidth - extent, startY, - extent, startH); - } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return makeRegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent, false, false, - 0, 0); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX() + (int)pageRefRect.getWidth() - + getExtent(), + (int)pageRefRect.getY(), + getExtent(), (int)pageRefRect.getHeight()); + adjustIPD(vpRect); + return vpRect; } + protected String getDefaultRegionName() { return "xsl-region-end"; } - protected String getElementName() { - return "fo:region-end"; - } public String getRegionClass() { - return REGION_CLASS; + return Region.END; + } + + public int getRegionAreaClass() { + return RegionReference.END; } } 1.12 +17 -39 xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java Index: RegionBefore.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionBefore.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- RegionBefore.java 2001/11/09 11:32:40 1.11 +++ RegionBefore.java 2001/11/09 22:31:50 1.12 @@ -1,5 +1,5 @@ /* - * $Id: RegionBefore.java,v 1.11 2001/11/09 11:32:40 keiron Exp $ + * $Id: RegionBefore.java,v 1.12 2001/11/09 22:31:50 klease Exp $ * 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. @@ -9,50 +9,21 @@ // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.area.RegionReference; +import java.awt.Rectangle; import org.xml.sax.Attributes; -public class RegionBefore extends Region { +public class RegionBefore extends RegionBA { - public static final String REGION_CLASS = "before"; - private int precedence; - public RegionBefore(FONode parent) { super(parent); } public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); - precedence = this.properties.get("precedence").getEnum(); - } - - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("precedence"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return new RegionArea(allocationRectangleXPosition, - allocationRectangleYPosition, - allocationRectangleWidth, extent); } @@ -60,16 +31,23 @@ return "xsl-region-before"; } - protected String getElementName() { - return "fo:region-before"; + public String getRegionClass() { + return Region.BEFORE; } - public String getRegionClass() { - return REGION_CLASS; + public int getRegionAreaClass() { + return RegionReference.BEFORE; } + - public boolean getPrecedence() { - return (precedence == Precedence.TRUE ? true : false); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = new Rectangle(pageRefRect); + vpRect.height = getExtent(); + if (getPrecedence() == false) { + adjustIPD(vpRect); + } + return vpRect; } } 1.12 +18 -41 xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java Index: RegionAfter.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionAfter.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- RegionAfter.java 2001/11/09 11:32:40 1.11 +++ RegionAfter.java 2001/11/09 22:31:50 1.12 @@ -1,5 +1,5 @@ /* - * $Id: RegionAfter.java,v 1.11 2001/11/09 11:32:40 keiron Exp $ + * $Id: RegionAfter.java,v 1.12 2001/11/09 22:31:50 klease Exp $ * 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. @@ -9,51 +9,31 @@ // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; +import org.apache.fop.area.RegionReference; +import java.awt.Rectangle; import org.xml.sax.Attributes; -public class RegionAfter extends Region { +public class RegionAfter extends RegionBA { - public static final String REGION_CLASS = "after"; - private int precedence; - public RegionAfter(FONode parent) { super(parent); } - public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); - precedence = this.properties.get("precedence").getEnum(); - } - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("clip"); - // this.properties.get("display-align"); - int extent = this.properties.get("extent").getLength().mvalue(); - // this.properties.get("overflow"); - // this.properties.get("precedence"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - return new RegionArea(allocationRectangleXPosition, - allocationRectangleYPosition - - allocationRectangleHeight + extent, - allocationRectangleWidth, extent); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) { + // Depends on extent and precedence + Rectangle vpRect = + new Rectangle((int)pageRefRect.getX(), + (int)pageRefRect.getY() - (int)pageRefRect.getHeight() + + getExtent(), + (int)pageRefRect.getWidth(), getExtent()); + if (getPrecedence() == false) { + adjustIPD(vpRect); + } + return vpRect; } @@ -61,16 +41,13 @@ return "xsl-region-after"; } - protected String getElementName() { - return "fo:region-after"; + public int getRegionAreaClass() { + return RegionReference.AFTER; } public String getRegionClass() { - return REGION_CLASS; + return Region.AFTER; } - public boolean getPrecedence() { - return (precedence == Precedence.TRUE ? true : false); - } } 1.14 +35 -48 xml-fop/src/org/apache/fop/fo/pagination/RegionBody.java Index: RegionBody.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/RegionBody.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- RegionBody.java 2001/11/09 11:32:40 1.13 +++ RegionBody.java 2001/11/09 22:31:50 1.14 @@ -1,5 +1,5 @@ /* - * $Id: RegionBody.java,v 1.13 2001/11/09 11:32:40 keiron Exp $ + * $Id: RegionBody.java,v 1.14 2001/11/09 22:31:50 klease Exp $ * 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. @@ -7,62 +7,42 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP -import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.Overflow; import org.apache.fop.datatypes.ColorType; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; -import org.apache.fop.layout.BodyRegionArea; -import org.apache.fop.layout.BorderAndPadding; -import org.apache.fop.layout.BackgroundProps; +import org.apache.fop.area.RegionReference; +import org.apache.fop.area.BodyRegion; import org.apache.fop.layout.MarginProps; public class RegionBody extends Region { - public static final String REGION_CLASS = "body"; - ColorType backgroundColor; public RegionBody(FONode parent) { super(parent); } - - RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight) { - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); + protected Rectangle getViewportRectangle (Rectangle pageRefRect) + { // Common Margin Properties-Block MarginProps mProps = propMgr.getMarginProps(); + return + new Rectangle((int)pageRefRect.getX() + mProps.marginLeft, + (int)pageRefRect.getY() - mProps.marginTop, + (int)pageRefRect.getWidth() - mProps.marginLeft - + mProps.marginRight, + (int)pageRefRect.getHeight() - mProps.marginTop - + mProps.marginBottom); + } - // this.properties.get("clip"); - // this.properties.get("display-align"); - // this.properties.get("region-name"); - // this.properties.get("reference-orientation"); - // this.properties.get("writing-mode"); - - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - BodyRegionArea body = new BodyRegionArea(allocationRectangleXPosition - + mProps.marginLeft, - allocationRectangleYPosition - - mProps.marginTop, - allocationRectangleWidth - - mProps.marginLeft - - mProps.marginRight, - allocationRectangleHeight - - mProps.marginTop - - mProps.marginBottom); + protected void setRegionTraits(RegionReference r) { + super.setRegionTraits(r); - int overflow = this.properties.get("overflow").getEnum(); String columnCountAsString = this.properties.get("column-count").getString(); int columnCount = 1; @@ -79,27 +59,34 @@ + "'overflow' is set to 'scroll'"); columnCount = 1; } - body.setColumnCount(columnCount); - - int columnGap = - this.properties.get("column-gap").getLength().mvalue(); - body.setColumnGap(columnGap); +// r.setColumnCount(columnCount); - body.setBackgroundColor(backgroundColor); +// int columnGap = +// this.properties.get("column-gap").getLength().mvalue(); +// r.setColumnGap(columnGap); - return body; +// r.setBackgroundColor(backgroundColor); } protected String getDefaultRegionName() { return "xsl-region-body"; } - protected String getElementName() { - return "fo:region-body"; - } public String getRegionClass() { - return REGION_CLASS; + return Region.BODY; + } + + public int getRegionAreaClass() { + return RegionReference.BODY; + } + + /** + * Override the inherited method. + */ + public RegionReference makeRegionReferenceArea() { + // Should set some column stuff here I think, or put it elsewhere + return new BodyRegion(); } } 1.8 +75 -18 xml-fop/src/org/apache/fop/fo/pagination/Region.java Index: Region.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Region.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Region.java 2001/11/09 11:32:40 1.7 +++ Region.java 2001/11/09 22:31:50 1.8 @@ -1,5 +1,5 @@ /* - * $Id: Region.java,v 1.7 2001/11/09 11:32:40 keiron Exp $ + * $Id: Region.java,v 1.8 2001/11/09 22:31:50 klease Exp $ * 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. @@ -7,12 +7,18 @@ package org.apache.fop.fo.pagination; +import java.awt.Rectangle; + // FOP import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; +import org.apache.fop.layout.BorderAndPadding; +import org.apache.fop.layout.BackgroundProps; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.RegionArea; +import org.apache.fop.area.RegionViewport; +import org.apache.fop.area.RegionReference; + import org.xml.sax.Attributes; @@ -22,12 +28,20 @@ public abstract class Region extends FObj { public static final String PROP_REGION_NAME = "region-name"; + final static String BEFORE = "before"; + final static String START = "start"; + final static String END = "end"; + final static String AFTER = "after"; + final static String BODY = "body"; + private SimplePageMaster _layoutMaster; private String _regionName; + protected int overflow; + + protected Region(FONode parent) { super(parent); - this.name = getElementName(); } public void handleAttrs(Attributes attlist) throws FOPException { @@ -49,36 +63,66 @@ } } - if (parent.getName().equals("fo:simple-page-master")) { - _layoutMaster = (SimplePageMaster)parent; - getPageMaster().addRegion(this); - } else { - throw new FOPException(getElementName() + " must be child " + if (parent instanceof SimplePageMaster) { + _layoutMaster = (SimplePageMaster)parent; + } + else { + throw new FOPException(this.name + " must be child " + "of simple-page-master, not " + parent.getName()); } + } + /** - * Creates a Region layout object for this pagination Region. + * Creates a RegionViewport Area object for this pagination Region. */ - abstract RegionArea makeRegionArea(int allocationRectangleXPosition, - int allocationRectangleYPosition, - int allocationRectangleWidth, - int allocationRectangleHeight); + public RegionViewport makeRegionViewport(Rectangle pageRefRect) { + return new RegionViewport(getViewportRectangle(pageRefRect)); + } + + + abstract protected Rectangle getViewportRectangle(Rectangle pageRefRect); + + + public RegionReference makeRegionReferenceArea() { + RegionReference r = new RegionReference(getRegionAreaClass()); + setRegionTraits(r); + return r; + } + + protected void setRegionTraits(RegionReference r) { + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + /* this.backgroundColor = + this.properties.get("background-color").getColorType();*/ + // this.properties.get("clip"); + // this.properties.get("display-align"); + // this.properties.get("overflow"); + this.overflow = this.properties.get("overflow").getEnum(); + // this.properties.get("region-name"); + // this.properties.get("reference-orientation"); + // this.properties.get("writing-mode"); + + //r.setBackground(bProps); + } + /** - * Returns the default region name (xsl-region-before, xsl-region-start, - * etc.) + * Return the enumerated value designating this type of region in the + * Area tree. */ - protected abstract String getDefaultRegionName(); + abstract protected int getRegionAreaClass(); /** - * Returns the element name ("fo:region-body", "fo:region-start", + * Returns the default region name (xsl-region-before, xsl-region-start, * etc.) */ - protected abstract String getElementName(); + protected abstract String getDefaultRegionName(); + public abstract String getRegionClass(); @@ -114,6 +158,19 @@ public boolean generatesReferenceAreas() { return true; + } + + protected Region getSiblingRegion(String regionClass) { + // Ask parent for region + return _layoutMaster.getRegion(regionClass); + } + + boolean getPrecedence() { + return false; + } + + int getExtent() { + return 0; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]