From 107b37f14824f1ed4f378651fd4188dd5808585f Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Wed, 27 Aug 2003 18:14:46 +0000 Subject: [PATCH] remove region code from /area/RegionReference in favor of those in fo/pagination/Region git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196864 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/BodyRegion.java | 26 +++++----- src/java/org/apache/fop/area/Page.java | 42 ++++++++-------- .../org/apache/fop/area/RegionReference.java | 49 +++++-------------- .../fop/layoutmgr/PageLayoutManager.java | 14 +++--- .../apache/fop/render/AbstractRenderer.java | 13 ++--- .../apache/fop/render/xml/XMLRenderer.java | 11 +++-- .../org/apache/fop/tools/AreaTreeBuilder.java | 23 ++++----- 7 files changed, 81 insertions(+), 97 deletions(-) diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 1db0ed114..e6116bf79 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,14 +42,16 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber . For more information on the Apache * Software Foundation, please see . - */ + */ package org.apache.fop.area; +import org.apache.fop.fo.pagination.Region; + /** * The body region area. * This area contains a main reference area and optionally a @@ -70,7 +72,7 @@ public class BodyRegion extends RegionReference { * This sets the region reference area class to BODY. */ public BodyRegion() { - super(BODY); + super(Region.BODY_CODE); } /** @@ -161,7 +163,7 @@ public class BodyRegion extends RegionReference { * are assumed to be null and are not cloned. * * @return a shallow copy of this object - */ + */ public Object clone() { BodyRegion br = new BodyRegion(); br.setCTM(getCTM()); diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 857a2578e..f5cda397f 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,17 +42,19 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber . For more information on the Apache * Software Foundation, please see . - */ + */ package org.apache.fop.area; import java.io.Serializable; import java.util.Map; +import org.apache.fop.fo.pagination.Region; + /** * The page. * This holds the contents of the page. Each region is added. @@ -82,15 +84,15 @@ public class Page implements Serializable, Cloneable { * @param port the region viewport to set */ public void setRegion(int areaclass, RegionViewport port) { - if (areaclass == RegionReference.BEFORE) { + if (areaclass == Region.BEFORE_CODE) { regionBefore = port; - } else if (areaclass == RegionReference.START) { + } else if (areaclass == Region.START_CODE) { regionStart = port; - } else if (areaclass == RegionReference.BODY) { + } else if (areaclass == Region.BODY_CODE) { regionBody = port; - } else if (areaclass == RegionReference.END) { + } else if (areaclass == Region.END_CODE) { regionEnd = port; - } else if (areaclass == RegionReference.AFTER) { + } else if (areaclass == Region.AFTER_CODE) { regionAfter = port; } } @@ -102,15 +104,15 @@ public class Page implements Serializable, Cloneable { * @return the region viewport or null if none */ public RegionViewport getRegion(int areaclass) { - if (areaclass == RegionReference.BEFORE) { + if (areaclass == Region.BEFORE_CODE) { return regionBefore; - } else if (areaclass == RegionReference.START) { + } else if (areaclass == Region.START_CODE) { return regionStart; - } else if (areaclass == RegionReference.BODY) { + } else if (areaclass == Region.BODY_CODE) { return regionBody; - } else if (areaclass == RegionReference.END) { + } else if (areaclass == Region.END_CODE) { return regionEnd; - } else if (areaclass == RegionReference.AFTER) { + } else if (areaclass == Region.AFTER_CODE) { 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 f83e8ded0..cadf27846 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,49 +42,26 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber . For more information on the Apache * Software Foundation, please see . - */ + */ package org.apache.fop.area; import java.util.ArrayList; import java.util.List; +import org.apache.fop.fo.pagination.Region; + /** * This is a region reference area for the page regions. * This area represents a region on the page. It is cloneable * so the page master can make copies from the original page and regions. */ public class RegionReference extends Area implements Cloneable { - /** - * The before region. - */ - public static final int BEFORE = 0; - - /** - * The start region. - */ - public static final int START = 1; - - /** - * The body region. - */ - public static final int BODY = 2; - - /** - * The end region. - */ - public static final int END = 3; - - /** - * The after region. - */ - public static final int AFTER = 4; - - private int regionClass = BEFORE; + private int regionClass = Region.BEFORE_CODE; 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/layoutmgr/PageLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java index b7cc1cd52..4c9514116 100644 --- a/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -460,7 +460,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable curPage.setPageNumber(getCurrentPageNumber()); RegionViewport reg = curPage.getPage().getRegion( - RegionReference.BODY); + Region.BODY_CODE); curBody = (BodyRegion) reg.getRegion(); flowBPD = (int)reg.getViewArea().getHeight(); return curPage; @@ -508,13 +508,13 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable // Layout static content into the regions // Need help from pageseq for this layoutStaticContent(currentSimplePageMaster.getRegion(Region.BEFORE), - RegionReference.BEFORE); + Region.BEFORE_CODE); layoutStaticContent(currentSimplePageMaster.getRegion(Region.AFTER), - RegionReference.AFTER); + Region.AFTER_CODE); layoutStaticContent(currentSimplePageMaster.getRegion(Region.START), - RegionReference.START); + Region.START_CODE); layoutStaticContent(currentSimplePageMaster.getRegion(Region.END), - RegionReference.END); + Region.END_CODE); // Queue for ID resolution and rendering areaTree.addPage(curPage); curPage = null; @@ -699,7 +699,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable curSpan = new Span(numCols); // get Width or Height as IPD for span curSpan.setIPD((int) curPage.getPage().getRegion( - RegionReference.BODY).getViewArea().getWidth()); + Region.BODY_CODE).getViewArea().getWidth()); //curSpan.setPosition(BPD, newpos); curBody.getMainReference().addSpan(curSpan); @@ -792,7 +792,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable rvp.setRegion(makeRegionReferenceArea(r, rvp.getViewArea())); } page.setRegion(r.getRegionClassCode(), rvp); - if (r.getRegionClassCode() == RegionReference.BODY) { + if (r.getRegionClassCode() == Region.BODY_CODE) { bHasBody = true; } } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 38f0844bd..c9d756923 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -89,6 +89,7 @@ import org.apache.fop.area.inline.Word; import org.apache.fop.area.inline.Character; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FOTreeControl; +import org.apache.fop.fo.pagination.Region; // Avalon import org.apache.avalon.framework.logger.AbstractLogEnabled; @@ -272,15 +273,15 @@ public abstract class AbstractRenderer extends AbstractLogEnabled */ protected void renderPageAreas(Page page) { RegionViewport viewport; - viewport = page.getRegion(RegionReference.BEFORE); + viewport = page.getRegion(Region.BEFORE_CODE); renderRegionViewport(viewport); - viewport = page.getRegion(RegionReference.START); + viewport = page.getRegion(Region.START_CODE); renderRegionViewport(viewport); - viewport = page.getRegion(RegionReference.BODY); + viewport = page.getRegion(Region.BODY_CODE); renderRegionViewport(viewport); - viewport = page.getRegion(RegionReference.END); + viewport = page.getRegion(Region.END_CODE); renderRegionViewport(viewport); - viewport = page.getRegion(RegionReference.AFTER); + viewport = page.getRegion(Region.AFTER_CODE); renderRegionViewport(viewport); } @@ -308,7 +309,7 @@ public abstract class AbstractRenderer extends AbstractLogEnabled // do after starting viewport area handleViewportTraits(port); - if (region.getRegionClass() == RegionReference.BODY) { + if (region.getRegionClass() == Region.BODY_CODE) { renderBodyRegion((BodyRegion) region); } else { renderRegion(region); diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index af896b9a4..2637bc406 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -94,6 +94,7 @@ import org.apache.fop.area.inline.Viewport; import org.apache.fop.area.inline.Word; import org.apache.fop.fo.properties.RuleStyle; import org.apache.fop.fo.FOTreeControl; +import org.apache.fop.fo.pagination.Region; /** * Renderer that renders areas to XML for debugging purposes. @@ -288,23 +289,23 @@ public class XMLRenderer extends AbstractRenderer { writeStartTag(""); RegionReference region = port.getRegion(); - if (region.getRegionClass() == RegionReference.BEFORE) { + if (region.getRegionClass() == Region.BEFORE_CODE) { writeStartTag(""); renderRegion(region); writeEndTag(""); - } else if (region.getRegionClass() == RegionReference.START) { + } else if (region.getRegionClass() == Region.START_CODE) { writeStartTag(""); renderRegion(region); writeEndTag(""); - } else if (region.getRegionClass() == RegionReference.BODY) { + } else if (region.getRegionClass() == Region.BODY_CODE) { writeStartTag(""); renderBodyRegion((BodyRegion) region); writeEndTag(""); - } else if (region.getRegionClass() == RegionReference.END) { + } else if (region.getRegionClass() == Region.END_CODE) { writeStartTag(""); renderRegion(region); writeEndTag(""); - } else if (region.getRegionClass() == RegionReference.AFTER) { + } else if (region.getRegionClass() == Region.AFTER_CODE) { writeStartTag(""); renderRegion(region); writeEndTag(""); diff --git a/src/java/org/apache/fop/tools/AreaTreeBuilder.java b/src/java/org/apache/fop/tools/AreaTreeBuilder.java index 0131e61a8..2f4eafc39 100644 --- a/src/java/org/apache/fop/tools/AreaTreeBuilder.java +++ b/src/java/org/apache/fop/tools/AreaTreeBuilder.java @@ -107,6 +107,7 @@ import org.apache.fop.render.pdf.PDFRenderer; import org.apache.fop.render.svg.SVGRenderer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.properties.RuleStyle; import org.apache.fop.fonts.FontMetrics; @@ -381,20 +382,20 @@ class TreeLoader extends AbstractLogEnabled { for (int i = 0; i < childs.getLength(); i++) { Node obj = childs.item(i); if (obj.getNodeName().equals("regionBefore")) { - reg.setRegion(readRegion((Element) obj, RegionReference.BEFORE)); - page.setRegion(RegionReference.BEFORE, reg); + reg.setRegion(readRegion((Element) obj, Region.BEFORE_CODE)); + page.setRegion(Region.BEFORE_CODE, reg); } else if (obj.getNodeName().equals("regionStart")) { - reg.setRegion(readRegion((Element) obj, RegionReference.START)); - page.setRegion(RegionReference.START, reg); + reg.setRegion(readRegion((Element) obj, Region.START_CODE)); + page.setRegion(Region.START_CODE, reg); } else if (obj.getNodeName().equals("regionBody")) { - reg.setRegion(readRegion((Element) obj, RegionReference.BODY)); - page.setRegion(RegionReference.BODY, reg); + reg.setRegion(readRegion((Element) obj, Region.BODY_CODE)); + page.setRegion(Region.BODY_CODE, reg); } else if (obj.getNodeName().equals("regionEnd")) { - reg.setRegion(readRegion((Element) obj, RegionReference.END)); - page.setRegion(RegionReference.END, reg); + reg.setRegion(readRegion((Element) obj, Region.END_CODE)); + page.setRegion(Region.END_CODE, reg); } else if (obj.getNodeName().equals("regionAfter")) { - reg.setRegion(readRegion((Element) obj, RegionReference.AFTER)); - page.setRegion(RegionReference.AFTER, reg); + reg.setRegion(readRegion((Element) obj, Region.AFTER_CODE)); + page.setRegion(Region.AFTER_CODE, reg); } } @@ -403,7 +404,7 @@ class TreeLoader extends AbstractLogEnabled { public RegionReference readRegion(Element root, int type) { RegionReference reg; - if (type == RegionReference.BODY) { + if (type == Region.BODY_CODE) { BodyRegion br = new BodyRegion(); NodeList childs = root.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { -- 2.39.5