diff options
author | Glen Mazza <gmazza@apache.org> | 2004-08-29 20:58:20 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-08-29 20:58:20 +0000 |
commit | 4107ab60306b456319faaafdff72048816d9154c (patch) | |
tree | a2380066fb2720c42cf9291ba4e63e8da8bcbdc3 /src/java/org/apache/fop | |
parent | b459b277210c10e3f58428dea12a07ccc7e4747d (diff) | |
download | xmlgraphics-fop-4107ab60306b456319faaafdff72048816d9154c.tar.gz xmlgraphics-fop-4107ab60306b456319faaafdff72048816d9154c.zip |
Removed the redundant Region Class Codes in favor of the FO constant
identifiers.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197896 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
18 files changed, 66 insertions, 102 deletions
diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 5b0970689..c1c812aa5 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -18,7 +18,7 @@ package org.apache.fop.area; -import org.apache.fop.fo.pagination.Region; +import org.apache.fop.fo.Constants; /** * The body region area. @@ -40,7 +40,7 @@ public class BodyRegion extends RegionReference { * This sets the region reference area class to BODY. */ public BodyRegion() { - super(Region.BODY_CODE); + super(Constants.FO_REGION_BODY); } /** diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index f83a5f0eb..609925552 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -21,7 +21,7 @@ package org.apache.fop.area; import java.io.Serializable; import java.util.Map; -import org.apache.fop.fo.pagination.Region; +import org.apache.fop.fo.Constants; /** * The page. @@ -52,15 +52,15 @@ public class Page implements Serializable, Cloneable { * @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; } } @@ -72,15 +72,15 @@ public class Page implements Serializable, Cloneable { * @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; diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index 016ae79f3..3d9f5def8 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -21,7 +21,7 @@ package org.apache.fop.area; 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. @@ -29,7 +29,7 @@ import org.apache.fop.fo.pagination.Region; * 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(); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 73fe34176..04738468a 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -555,7 +555,7 @@ public class PageSequence extends FObj { // 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()); @@ -741,6 +741,9 @@ public class PageSequence extends FObj { return root; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:page-sequence"; } diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index 20837c65d..c392aa7b6 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -35,18 +35,6 @@ import org.apache.fop.fo.FObj; */ 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; @@ -121,12 +109,6 @@ public abstract class Region extends FObj { 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 */ diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index b5e4ea5de..4629115a3 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -34,7 +34,7 @@ public class RegionAfter extends RegionBA { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionAfter(FONode parent) { - super(parent, Region.AFTER_CODE); + super(parent, FO_REGION_AFTER); } /** @@ -62,12 +62,8 @@ public class RegionAfter extends RegionBA { } /** - * @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"; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index 80705b429..3e6e0d867 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -69,12 +69,12 @@ public abstract class RegionBA extends Region { */ 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(); } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index d70f2c0d2..26f1ba75a 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -34,7 +34,7 @@ public class RegionBefore extends RegionBA { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionBefore(FONode parent) { - super(parent, Region.BEFORE_CODE); + super(parent, FO_REGION_BEFORE); } /** @@ -45,13 +45,6 @@ public class RegionBefore extends RegionBA { } /** - * @see org.apache.fop.fo.pagination.Region#getRegionClassCode() - */ - public int getRegionClassCode() { - return Region.BEFORE_CODE; - } - - /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ public Rectangle getViewportRectangle (FODimension reldims) { @@ -73,6 +66,9 @@ public class RegionBefore extends RegionBA { return vpRect; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:region-before"; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 52a491b74..c39dd3d39 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -45,7 +45,7 @@ public class RegionBody extends Region { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionBody(FONode parent) { - super(parent, Region.BODY_CODE); + super(parent, FO_REGION_BODY); } /** @@ -100,12 +100,8 @@ public class RegionBody extends Region { } /** - * @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"; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index 8e07eaccc..3c3b8daad 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -35,7 +35,7 @@ public class RegionEnd extends RegionSE { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionEnd(FONode parent) { - super(parent, Region.END_CODE); + super(parent, FO_REGION_END); } /** @@ -63,12 +63,8 @@ public class RegionEnd extends RegionSE { } /** - * @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"; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java index 1f97acdaf..5a0a50a3b 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java @@ -58,12 +58,12 @@ public abstract class RegionSE extends Region { */ 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(); } diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index b02626ea6..e44697367 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -34,7 +34,7 @@ public class RegionStart extends RegionSE { * @see org.apache.fop.fo.FONode#FONode(FONode) */ public RegionStart(FONode parent) { - super(parent, Region.START_CODE); + super(parent, FO_REGION_START); } /** @@ -62,12 +62,8 @@ public class RegionStart extends RegionSE { } /** - * @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"; } diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index 7a4debebf..6dc3e113f 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -176,7 +176,7 @@ public class SimplePageMaster extends FObj { * @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); } diff --git a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java index 82dd3077f..6952b508f 100644 --- a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -442,7 +442,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 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(); @@ -490,14 +490,14 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable } // 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; @@ -682,7 +682,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 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(); @@ -708,7 +708,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 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 '" @@ -777,13 +777,13 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 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; } } @@ -857,7 +857,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable */ 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; } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 7f47a6d14..555ba9fa6 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -238,15 +238,15 @@ public abstract class AbstractRenderer 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); } @@ -274,7 +274,7 @@ public abstract class AbstractRenderer // 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); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 73cfe9685..b2a92158a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -517,8 +517,7 @@ public class PDFRenderer extends PrintRenderer { 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(); } diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java index 24eaa3b38..dc4ef486d 100644 --- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java @@ -53,9 +53,9 @@ class PageAttributesConverter { 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); diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index a3d38897d..6a3be0847 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -253,23 +253,23 @@ public class XMLRenderer extends AbstractRenderer { 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>"); |