package org.apache.fop.area;
-import org.apache.fop.fo.pagination.Region;
+import org.apache.fop.fo.Constants;
/**
* The body region area.
* This sets the region reference area class to BODY.
*/
public BodyRegion() {
- super(Region.BODY_CODE);
+ super(Constants.FO_REGION_BODY);
}
/**
import java.io.Serializable;
import java.util.Map;
-import org.apache.fop.fo.pagination.Region;
+import org.apache.fop.fo.Constants;
/**
* The page.
* @param port the region viewport to set
*/
public void setRegionViewport(int areaclass, RegionViewport port) {
- if (areaclass == Region.BEFORE_CODE) {
+ if (areaclass == Constants.FO_REGION_BEFORE) {
regionBefore = port;
- } else if (areaclass == Region.START_CODE) {
+ } else if (areaclass == Constants.FO_REGION_START) {
regionStart = port;
- } else if (areaclass == Region.BODY_CODE) {
+ } else if (areaclass == Constants.FO_REGION_BODY) {
regionBody = port;
- } else if (areaclass == Region.END_CODE) {
+ } else if (areaclass == Constants.FO_REGION_END) {
regionEnd = port;
- } else if (areaclass == Region.AFTER_CODE) {
+ } else if (areaclass == Constants.FO_REGION_AFTER) {
regionAfter = port;
}
}
* @return the region viewport or null if none
*/
public RegionViewport getRegionViewport(int areaclass) {
- if (areaclass == Region.BEFORE_CODE) {
+ if (areaclass == Constants.FO_REGION_BEFORE) {
return regionBefore;
- } else if (areaclass == Region.START_CODE) {
+ } else if (areaclass == Constants.FO_REGION_START) {
return regionStart;
- } else if (areaclass == Region.BODY_CODE) {
+ } else if (areaclass == Constants.FO_REGION_BODY) {
return regionBody;
- } else if (areaclass == Region.END_CODE) {
+ } else if (areaclass == Constants.FO_REGION_END) {
return regionEnd;
- } else if (areaclass == Region.AFTER_CODE) {
+ } else if (areaclass == Constants.FO_REGION_AFTER) {
return regionAfter;
}
return null;
import java.util.ArrayList;
import java.util.List;
-import org.apache.fop.fo.pagination.Region;
+import org.apache.fop.fo.Constants;
/**
* This is a region reference area for the page regions.
* so the page master can make copies from the original page and regions.
*/
public class RegionReference extends Area implements Cloneable {
- private int regionClass = Region.BEFORE_CODE;
+ private int regionClass = Constants.FO_REGION_BEFORE;
private CTM ctm;
// the list of block areas from the static flow
private List blocks = new ArrayList();
// SimplePageMaster spm =
// this.layoutMasterSet.getSimplePageMaster(masterName);
-// Region region = spm.getRegion(Region.BODY);
+// Region region = spm.getRegion(FO_REGION_BODY);
// Flow flow = (Flow)flowMap.get(region.getRegionName());
return root;
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:page-sequence";
}
*/
public abstract class Region extends FObj {
- /* The following codes correspond to those found in area/RegionReference */
- /** Integer Code for before regions */
- public static final int BEFORE_CODE = 0;
- /** Integer Code for start regions */
- public static final int START_CODE = 1;
- /** Integer Code for body regions */
- public static final int BODY_CODE = 2;
- /** Integer Code for end regions */
- public static final int END_CODE = 3;
- /** Integer Code for after regions */
- public static final int AFTER_CODE = 4;
-
private SimplePageMaster layoutMaster;
private int regionId = -1;
private String regionName;
*/
protected abstract String getDefaultRegionName();
- /**
- * Returns the region class code.
- * @return the region class code
- */
- public abstract int getRegionClassCode();
-
/**
* Returns the name of this region.
* @return the region name
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionAfter(FONode parent) {
- super(parent, Region.AFTER_CODE);
+ super(parent, FO_REGION_AFTER);
}
/**
}
/**
- * @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
+ * @see org.apache.fop.fo.FObj#getName()
*/
- public int getRegionClassCode() {
- return Region.AFTER_CODE;
- }
-
public String getName() {
return "fo:region-after";
}
*/
protected void adjustIPD(Rectangle vpRefRect, int wm) {
int offset = 0;
- Region start = getSiblingRegion(Region.START);
+ Region start = getSiblingRegion(FO_REGION_START);
if (start != null) {
offset = start.getExtent();
vpRefRect.translate(offset, 0);
}
- Region end = getSiblingRegion(Region.END);
+ Region end = getSiblingRegion(FO_REGION_END);
if (end != null) {
offset += end.getExtent();
}
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBefore(FONode parent) {
- super(parent, Region.BEFORE_CODE);
+ super(parent, FO_REGION_BEFORE);
}
/**
return "xsl-region-before";
}
- /**
- * @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
- */
- public int getRegionClassCode() {
- return Region.BEFORE_CODE;
- }
-
/**
* @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
*/
return vpRect;
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:region-before";
}
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionBody(FONode parent) {
- super(parent, Region.BODY_CODE);
+ super(parent, FO_REGION_BODY);
}
/**
}
/**
- * @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
+ * @see org.apache.fop.fo.FObj#getName()
*/
- public int getRegionClassCode() {
- return Region.BODY_CODE;
- }
-
public String getName() {
return "fo:region-body";
}
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionEnd(FONode parent) {
- super(parent, Region.END_CODE);
+ super(parent, FO_REGION_END);
}
/**
}
/**
- * @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
+ * @see org.apache.fop.fo.FObj#getName()
*/
- public int getRegionClassCode() {
- return Region.END_CODE;
- }
-
public String getName() {
return "fo:region-end";
}
*/
protected void adjustIPD(Rectangle vpRefRect, int wm) {
int offset = 0;
- Region before = getSiblingRegion(Region.BEFORE);
+ Region before = getSiblingRegion(FO_REGION_BEFORE);
if (before != null && before.getPrecedence()) {
offset = before.getExtent();
vpRefRect.translate(0, offset);
}
- Region after = getSiblingRegion(Region.AFTER);
+ Region after = getSiblingRegion(FO_REGION_AFTER);
if (after != null && after.getPrecedence()) {
offset += after.getExtent();
}
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public RegionStart(FONode parent) {
- super(parent, Region.START_CODE);
+ super(parent, FO_REGION_START);
}
/**
}
/**
- * @see org.apache.fop.fo.pagination.Region#getRegionClassCode()
+ * @see org.apache.fop.fo.FObj#getName()
*/
- public int getRegionClassCode() {
- return Region.START_CODE;
- }
-
public String getName() {
return "fo:region-start";
}
* @param region region to add
*/
protected void addRegion(Region region) {
- String key = String.valueOf(region.getRegionClassCode());
+ String key = String.valueOf(region.getNameId());
regions.put(key, region);
}
curPage.setPageNumber(getCurrentPageNumber());
RegionViewport rv = curPage.getPage().getRegionViewport(
- Region.BODY_CODE);
+ FO_REGION_BODY);
curBody = (BodyRegion) rv.getRegion();
flowBPD = (int) curBody.getBPD() -
rv.getBorderAndPaddingWidthBefore() - rv.getBorderAndPaddingWidthAfter();
}
// Layout static content into the regions
// Need help from pageseq for this
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.BEFORE_CODE),
- Region.BEFORE_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.AFTER_CODE),
- Region.AFTER_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.START_CODE),
- Region.START_CODE);
- layoutStaticContent(currentSimplePageMaster.getRegion(Region.END_CODE),
- Region.END_CODE);
+ layoutStaticContent(currentSimplePageMaster.getRegion(FO_REGION_BEFORE),
+ FO_REGION_BEFORE);
+ layoutStaticContent(currentSimplePageMaster.getRegion(FO_REGION_AFTER),
+ FO_REGION_AFTER);
+ layoutStaticContent(currentSimplePageMaster.getRegion(FO_REGION_START),
+ FO_REGION_START);
+ layoutStaticContent(currentSimplePageMaster.getRegion(FO_REGION_END),
+ FO_REGION_END);
// Queue for ID resolution and rendering
areaTreeHandler.addPage(curPage);
curPage = null;
curSpan = new Span(numCols);
// get Width or Height as IPD for span
- RegionViewport rv = curPage.getPage().getRegionViewport(Region.BODY_CODE);
+ RegionViewport rv = curPage.getPage().getRegionViewport(FO_REGION_BODY);
int ipdWidth = (int) rv.getRegion().getIPD() -
rv.getBorderAndPaddingWidthStart() - rv.getBorderAndPaddingWidthEnd();
private PageViewport createPage(boolean bIsBlank, boolean bIsLast)
throws FOPException {
currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank);
- Region body = currentSimplePageMaster.getRegion(Region.BODY_CODE);
+ Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY);
if (!pageSequence.getMainFlow().getFlowName().equals(body.getRegionName())) {
throw new FOPException("Flow '" + pageSequence.getMainFlow().getFlowName()
+ "' does not map to the region-body in page-master '"
r.setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
r.setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM);
- if (r.getRegionClassCode() == Region.BODY_CODE) {
+ if (r.getNameId() == FO_REGION_BODY) {
rvp.setRegion(makeRegionBodyReferenceArea(r, rvp.getViewArea()));
} else {
rvp.setRegion(makeRegionReferenceArea(r, rvp.getViewArea()));
}
- page.setRegionViewport(r.getRegionClassCode(), rvp);
- if (r.getRegionClassCode() == Region.BODY_CODE) {
+ page.setRegionViewport(r.getNameId(), rvp);
+ if (r.getNameId() == FO_REGION_BODY) {
bHasBody = true;
}
}
*/
private RegionReference makeRegionReferenceArea(Region r,
Rectangle2D absRegVPRect) {
- RegionReference rr = new RegionReference(r.getRegionClassCode());
+ RegionReference rr = new RegionReference(r.getNameId());
setRegionPosition(r, rr, absRegVPRect);
return rr;
}
decision is to have fo:region-body on top, hence it is rendered
last here. */
RegionViewport viewport;
- viewport = page.getRegionViewport(Region.BEFORE_CODE);
+ viewport = page.getRegionViewport(FO_REGION_BEFORE);
renderRegionViewport(viewport);
- viewport = page.getRegionViewport(Region.START_CODE);
+ viewport = page.getRegionViewport(FO_REGION_START);
renderRegionViewport(viewport);
- viewport = page.getRegionViewport(Region.END_CODE);
+ viewport = page.getRegionViewport(FO_REGION_END);
renderRegionViewport(viewport);
- viewport = page.getRegionViewport(Region.AFTER_CODE);
+ viewport = page.getRegionViewport(FO_REGION_AFTER);
renderRegionViewport(viewport);
- viewport = page.getRegionViewport(Region.BODY_CODE);
+ viewport = page.getRegionViewport(FO_REGION_BODY);
renderRegionViewport(viewport);
}
// shouldn't the viewport have the CTM
startVParea(region.getCTM());
// do after starting viewport area
- if (region.getRegionClass() == Region.BODY_CODE) {
+ if (region.getRegionClass() == FO_REGION_BODY) {
renderBodyRegion((BodyRegion) region);
} else {
renderRegion(region);
float width = (float)(viewArea.getWidth() / 1000f);
float height = (float)(viewArea.getHeight() / 1000f);
- if (region.getRegion().getRegionClass()
- == org.apache.fop.fo.pagination.Region.BODY_CODE) {
+ if (region.getRegion().getRegionClass() == FO_REGION_BODY) {
bpMarginOffset = region.getBorderAndPaddingWidthBefore();
ipMarginOffset = region.getBorderAndPaddingWidthStart();
}
Property p = null;
Float f = null;
- Region before = pagemaster.getRegion(Region.BEFORE_CODE);
- Region body = pagemaster.getRegion(Region.BODY_CODE);
- Region after = pagemaster.getRegion(Region.AFTER_CODE);
+ Region before = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
+ Region body = pagemaster.getRegion(Constants.FO_REGION_BODY);
+ Region after = pagemaster.getRegion(Constants.FO_REGION_AFTER);
if ((p = pagemaster.getProperty(Constants.PR_PAGE_WIDTH)) != null) {
f = new Float(p.getLength().getValue() / 1000f);
writeStartTag("<regionViewport rect=\""
+ createString(port.getViewArea()) + "\">");
RegionReference region = port.getRegion();
- if (region.getRegionClass() == Region.BEFORE_CODE) {
+ if (region.getRegionClass() == FO_REGION_BEFORE) {
writeStartTag("<regionBefore>");
renderRegion(region);
writeEndTag("</regionBefore>");
- } else if (region.getRegionClass() == Region.START_CODE) {
+ } else if (region.getRegionClass() == FO_REGION_START) {
writeStartTag("<regionStart>");
renderRegion(region);
writeEndTag("</regionStart>");
- } else if (region.getRegionClass() == Region.BODY_CODE) {
+ } else if (region.getRegionClass() == FO_REGION_BODY) {
writeStartTag("<regionBody>");
renderBodyRegion((BodyRegion) region);
writeEndTag("</regionBody>");
- } else if (region.getRegionClass() == Region.END_CODE) {
+ } else if (region.getRegionClass() == FO_REGION_END) {
writeStartTag("<regionEnd>");
renderRegion(region);
writeEndTag("</regionEnd>");
- } else if (region.getRegionClass() == Region.AFTER_CODE) {
+ } else if (region.getRegionClass() == FO_REGION_AFTER) {
writeStartTag("<regionAfter>");
renderRegion(region);
writeEndTag("</regionAfter>");