]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
More stubs for area processing.
authorPeter Bernard West <pbwest@apache.org>
Tue, 24 Feb 2004 07:54:00 +0000 (07:54 +0000)
committerPeter Bernard West <pbwest@apache.org>
Tue, 24 Feb 2004 07:54:00 +0000 (07:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197363 13f79535-47bb-0310-9956-ffa450edef68

19 files changed:
src/java/org/apache/fop/area/AbstractReferenceArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/CoordTransformer.java [new file with mode: 0644]
src/java/org/apache/fop/area/MainReferenceArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/PageRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/PageViewport.java
src/java/org/apache/fop/area/RegionAfterRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionAfterVport.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionBeforeRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionBeforeVport.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionBodyRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionBodyVport.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionEndRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionEndVport.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionStartRefArea.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionStartVport.java [new file with mode: 0644]
src/java/org/apache/fop/area/RegionViewport.java
src/java/org/apache/fop/area/Span.java
src/java/org/apache/fop/area/Viewport.java [new file with mode: 0644]

diff --git a/src/java/org/apache/fop/area/AbstractReferenceArea.java b/src/java/org/apache/fop/area/AbstractReferenceArea.java
new file mode 100644 (file)
index 0000000..f20cdf4
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 21/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public abstract class AbstractReferenceArea
+    extends Area
+    implements ReferenceArea {
+
+    // Set up as identity matrix
+    protected CoordTransformer transformer = new CoordTransformer();
+
+    /**
+     * @param parent
+     * @param index
+     * @param areaSync
+     * @throws IndexOutOfBoundsException
+     */
+    public AbstractReferenceArea(Node parent, int index, Object areaSync)
+        throws IndexOutOfBoundsException {
+        super(parent, index, areaSync);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param parent
+     * @param areaSync
+     * @throws IndexOutOfBoundsException
+     */
+    public AbstractReferenceArea(Node parent, Object areaSync)
+        throws IndexOutOfBoundsException {
+        super(parent, areaSync);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * Set the Coordinate Transformation Matrix which transforms content
+     * coordinates in this reference area which are specified in
+     * terms of "start" and "before" into coordinates in a system which
+     * is positioned in "absolute" directions (with origin at lower left of
+     * the reference area.
+     *
+     * @param transformer to position this reference area
+     */
+    public void setCoordTransformer(CoordTransformer transformer) {
+        this.transformer = transformer;
+    }
+
+    /**
+     * Get the current transformer of this reference area.
+     *
+     * @return the current transformer to position this reference area
+     */
+    public CoordTransformer getCoordTransformer() {
+        return this.transformer;
+    }
+
+    /**
+     * Clone this reference area.
+     *
+     * @return a copy of this reference area
+     */
+    public Object clone() {
+        AbstractReferenceArea absRefArea;
+        try {
+            absRefArea = (RegionRefArea)(super.clone());
+        } catch (CloneNotSupportedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            throw new InternalError();
+        }
+        absRefArea.transformer = transformer;
+        return absRefArea;
+    }
+    
+}
diff --git a/src/java/org/apache/fop/area/CoordTransformer.java b/src/java/org/apache/fop/area/CoordTransformer.java
new file mode 100644 (file)
index 0000000..8a858e2
--- /dev/null
@@ -0,0 +1,333 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.fop.area;
+
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+
+import org.apache.fop.fo.properties.WritingMode;
+
+/**
+ * Describe a PDF or PostScript style coordinate transformation matrix.
+ * The matrix encodes translations, scaling and rotations of the coordinate
+ * system used to render pages.
+ */
+public class CoordTransformer implements Serializable {
+
+    private double a, b, c, d, e, f;
+
+    private static final CoordTransformer CT_LRTB =
+        new CoordTransformer(1, 0, 0, 1, 0, 0);
+    private static final CoordTransformer CT_RLTB =
+        new CoordTransformer(-1, 0, 0, 1, 0, 0);
+    private static final CoordTransformer CT_TBRL =
+        new CoordTransformer(0, 1, -1, 0, 0, 0);
+
+    /**
+     * Create the identity matrix
+     */
+    public CoordTransformer() {
+        a = 1;
+        b = 0;
+        c = 0;
+        d = 1;
+        e = 0;
+        f = 0;
+    }
+
+    /**
+     * Initialize a CoordTransformer from the passed arguments.
+     *
+     * @param a the x scale
+     * @param b the x shear
+     * @param c the y shear
+     * @param d the y scale
+     * @param e the x shift
+     * @param f the y shift
+     */
+    public CoordTransformer(
+            double a, double b, double c, double d, double e, double f) {
+        this.a = a;
+        this.b = b;
+        this.c = c;
+        this.d = d;
+        this.e = e;
+        this.f = f;
+    }
+
+    /**
+     * Initialize a CoordTransformer to the identity matrix with a translation
+     * specified by x and y
+     *
+     * @param x the x shift
+     * @param y the y shift.
+     */
+    public CoordTransformer(double x, double y) {
+        this.a = 1;
+        this.b = 0;
+        this.c = 0;
+        this.d = 1;
+        this.e = x;
+        this.f = y;
+    }
+
+    /**
+     * Initialize a CoordTransformer with the values of another CoordTransformer.
+     *
+     * @param ct another CoordTransformer
+     */
+    protected CoordTransformer(CoordTransformer ct) {
+        this.a = ct.a;
+        this.b = ct.b;
+        this.c = ct.c;
+        this.d = ct.d;
+        this.e = ct.e;
+        this.f = ct.f;
+    }
+
+    /**
+     * Return a CoordTransformer which will transform coordinates for a
+     * particular writing-mode into normalized first quandrant coordinates.
+     * @param wm A writing mode constant from fo.properties.WritingMode, ie.
+     * one of LR_TB, RL_TB, TB_RL.
+     * @param ipd The inline-progression dimension of the reference area whose
+     * CoordTransformer is being set..
+     * @param bpd The block-progression dimension of the reference area whose
+     * CoordTransformer is being set.
+     * @return a new CoordTransformer with the required transform
+     */
+    public static CoordTransformer getWMct(int wm, int ipd, int bpd) {
+        CoordTransformer wmct;
+        switch (wm) {
+            case WritingMode.LR_TB:
+                return new CoordTransformer(CT_LRTB);
+            case WritingMode.RL_TB: {
+                    wmct = new CoordTransformer(CT_RLTB);
+                    wmct.e = ipd;
+                    return wmct;
+                }
+                //return  CT_RLTB.translate(ipd, 0);
+            case WritingMode.TB_RL: { // CJK
+                    wmct = new CoordTransformer(CT_TBRL);
+                    wmct.e = bpd;
+                    return wmct;
+                }
+                //return CT_TBRL.translate(0, ipd);
+            default:
+                return null;
+        }
+    }
+
+    /**
+     * Multiply new passed CoordTransformer with this one and generate a new
+     * result CoordTransformer.
+     * @param premult The CoordTransformer to multiply with this one.
+     *  The new one will be the first multiplicand.
+     * @return CoordTransformer The result of multiplying premult * this.
+     */
+    public CoordTransformer multiply(CoordTransformer premult) {
+        CoordTransformer rslt = 
+            new CoordTransformer ((premult.a * a) + (premult.b * c),
+                            (premult.a * b) + (premult.b * d),
+                            (premult.c * a) + (premult.d * c),
+                            (premult.c * b) + (premult.d * d),
+                            (premult.e * a) + (premult.f * c) + e,
+                            (premult.e * b) + (premult.f * d) + f);
+        return rslt;
+    }
+
+    /**
+     * Rotate this CoordTransformer by "angle" radians and return a new result
+     * CoordTransformer.  This is used to account for reference-orientation.
+     * @param angle The angle in radians.
+     * Positive angles are measured counter-clockwise.
+     * @return CoordTransformer The result of rotating this CoordTransformer.
+     */
+    public CoordTransformer rotate(double angle) {
+        double cos, sin;
+        if (angle == 90.0) {
+            cos = 0.0;
+            sin = 1.0;
+        } else if (angle == 270.0) {
+            cos = 0.0;
+            sin = -1.0;
+        } else if (angle == 180.0) {
+            cos = -1.0;
+            sin = 0.0;
+        } else {
+            double rad = Math.toRadians(angle);
+            cos = Math.cos(rad);
+            sin = Math.sin(rad);
+        }
+        CoordTransformer rotate = new CoordTransformer(cos, -sin, sin, cos, 0, 0);
+        return multiply(rotate);
+    }
+
+    /**
+     * Translate this CoordTransformer by the passed x and y values and return
+     * a new result CoordTransformer.
+     * @param x The amount to translate along the x axis.
+     * @param y The amount to translate along the y axis.
+     * @return CoordTransformer The result of translating this CoordTransformer.
+     */
+    public CoordTransformer translate(double x, double y) {
+        CoordTransformer translate = new CoordTransformer(1, 0, 0, 1, x, y);
+        return multiply(translate);
+    }
+
+    /**
+     * Scale this CoordTransformer by the passed x and y values and return
+     * a new result CoordTransformer.
+     * @param x The amount to scale along the x axis.
+     * @param y The amount to scale along the y axis.
+     * @return CoordTransformer The result of scaling this CoordTransformer.
+     */
+    public CoordTransformer scale(double x, double y) {
+        CoordTransformer scale = new CoordTransformer(x, 0, 0, y, 0, 0);
+        return multiply(scale);
+    }
+
+    /**
+     * Transform a rectangle by the CoordTransformer to produce a rectangle in
+     * the transformed coordinate system.
+     * @param inRect The rectangle in the original coordinate system
+     * @return Rectangle2D The rectangle in the transformed coordinate system.
+     */
+    public Rectangle2D transform(Rectangle2D inRect) {
+        // Store as 2 sets of 2 points and transform those, then
+        // recalculate the width and height
+        int x1t = (int)(inRect.getX() * a + inRect.getY() * c + e);
+        int y1t = (int)(inRect.getX() * b + inRect.getY() * d + f);
+        int x2t = (int)((inRect.getX() + inRect.getWidth()) * a
+                        + (inRect.getY() + inRect.getHeight()) * c + e);
+        int y2t = (int)((inRect.getX() + inRect.getWidth()) * b
+                        + (inRect.getY() + inRect.getHeight()) * d + f);
+        // Normalize with x1 < x2
+        if (x1t > x2t) {
+            int tmp = x2t;
+            x2t = x1t;
+            x1t = tmp;
+        }
+        if (y1t > y2t) {
+            int tmp = y2t;
+            y2t = y1t;
+            y1t = tmp;
+        }
+        return new Rectangle(x1t, y1t, x2t - x1t, y2t - y1t);
+    }
+
+    /**
+     * Get string for this transform.
+     *
+     * @return a string with the transform values
+     */
+    public String toString() {
+        return "[" + a + " " + b + " " + c + " " + d + " " + e + " "
+               + f + "]";
+    }
+
+    /**
+     * Get an array containing the values of this transform.
+     * This creates and returns a new transform with the values in it.
+     *
+     * @return an array containing the transform values
+     */
+    public double[] toArray() {
+        return new double[]{a, b, c, d, e, f};
+    }
+
+    /**
+     * @param absRefOrient
+     * @param writingMode
+     * @param absVPrect
+     * @return
+     */
+    /**
+     * Construct a coordinate transformation matrix.
+     * @param absVPrect absolute viewpoint rectangle
+     * @param relBPDim the relative block progression dimension
+     * @param relIPDim the relative inline progression dimension
+     * @return CoordTransformer the coordinate transformation matrix
+     */
+    public static CoordTransformer getMatrixandRelDims(int absRefOrient,
+                                       int writingMode,
+                                       Rectangle2D absVPrect,
+                                       int relBPDim, int relIPDim) {
+        int width, height;
+        // We will use the absolute reference-orientation to set up the
+        // CoordTransformer.
+        // The value here is relative to its ancestor reference area.
+        if (absRefOrient % 180 == 0) {
+            width = (int) absVPrect.getWidth();
+            height = (int) absVPrect.getHeight();
+        } else {
+            // invert width and height since top left are rotated by 90
+            // (cl or ccl)
+            height = (int) absVPrect.getWidth();
+            width = (int) absVPrect.getHeight();
+        }
+        /* Set up the CoordTransformer for the content of this reference area.
+         * This will transform region content coordinates in
+         * writing-mode relative into absolute page-relative
+         * which will then be translated based on the position of
+         * the region viewport.
+         * (Note: scrolling between region vp and ref area when
+         * doing online content!)
+         */
+        CoordTransformer ct = 
+            new CoordTransformer(absVPrect.getX(), absVPrect.getY());
+
+        // First transform for rotation
+        if (absRefOrient != 0) {
+            // Rotation implies translation to keep the drawing area in the
+            // first quadrant. Note: rotation is counter-clockwise
+            switch (absRefOrient) {
+                case 90:
+                    ct = ct.translate(0, width); // width = absVPrect.height
+                    break;
+                case 180:
+                    ct = ct.translate(width, height);
+                    break;
+                case 270:
+                    ct = ct.translate(height, 0); // height = absVPrect.width
+                    break;
+            }
+            ct = ct.rotate(absRefOrient);
+        }
+        /* Since we've already put adjusted width and height values for the
+         * top and left positions implied by the reference-orientation, we
+         * can set ipd and bpd appropriately based on the writing mode.
+         */
+
+        if (writingMode == WritingMode.LR_TB
+                || writingMode == WritingMode.RL_TB) {
+            relIPDim = width;
+            relBPDim = height;
+        } else {
+            relIPDim = height;
+            relBPDim = width;
+        }
+        // Set a rectangle to be the writing-mode relative version???
+        // Now transform for writing mode
+        return ct.multiply(
+                CoordTransformer.getWMct(writingMode, relIPDim, relBPDim));
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/MainReferenceArea.java b/src/java/org/apache/fop/area/MainReferenceArea.java
new file mode 100644 (file)
index 0000000..99be0f1
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */ 
+package org.apache.fop.area;
+
+import java.util.List;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * The main body reference area.
+ * This is the primary child of the region-body-reference-area.
+ * The complementary children are the optional
+ * before-float-reference-area and footnote-reference-area.
+ * The children of this area are span-reference-areas.
+ */
+public class MainReferenceArea
+extends AbstractReferenceArea
+implements ReferenceArea {
+    private List spanAreas = new java.util.ArrayList();
+    private int columnGap;
+    private int width;
+
+    /**
+     * @param parent
+     * @param areaSync
+     * @throws IndexOutOfBoundsException
+     */
+    public MainReferenceArea(Node parent, Object areaSync)
+    throws IndexOutOfBoundsException {
+        super(parent, areaSync);
+        // TODO Auto-generated constructor stub
+    }
+    
+    /**
+     * Add a span area to this area.
+     *
+     * @param span the span area to add
+     */
+    public void addSpan(Span span) {
+        spanAreas.add(span);
+    }
+
+    /**
+     * Get the span areas from this area.
+     *
+     * @return the list of span areas
+     */
+    public List getSpans() {
+        return spanAreas;
+    }
+
+    /**
+     * Get the column gap in millipoints.
+     *
+     * @return the column gap in millioints
+     */
+    public int getColumnGap() {
+        return columnGap;
+    }
+
+    /**
+     * Get the width of this reference area.
+     *
+     * @return the width
+     */
+    public int getWidth() {
+        return width;
+    }
+
+}
+
diff --git a/src/java/org/apache/fop/area/PageRefArea.java b/src/java/org/apache/fop/area/PageRefArea.java
new file mode 100644 (file)
index 0000000..558ca29
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * $Id$
+ * ============================================================================
+ *                    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
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.area;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * The page.
+ * This holds the contents of the page. Each region is added.
+ * The unresolved references area added so that if the page is
+ * serialized then it will handle the resolving properly after
+ * being reloaded.
+ * This is serializable so it can be saved to cache to save
+ * memory if there are forward references.
+ * The page is cloneable so the page master can make copies of
+ * the top level page and regions.
+ */
+public class PageRefArea
+extends AbstractReferenceArea
+implements ReferenceArea, Serializable {
+    // contains before, start, body, end and after regions
+    private RegionBodyVport regionBody = null;
+    private RegionBeforeVport regionBefore = null;
+    private RegionAfterVport regionAfter = null;
+    private RegionStartVport regionStart = null;
+    private RegionEndVport regionEnd = null;
+
+    // temporary map of unresolved objects used when serializing the page
+    private Map unresolved = null;
+    
+    public PageRefArea(Node parent, Object sync) {
+        super(parent, sync);
+    }
+
+    /**
+     * Set the unresolved references on this page for serializing.
+     *
+     * @param unres the map of unresolved objects
+     */
+    public void setUnresolvedReferences(Map unres) {
+        unresolved = unres;
+    }
+
+    /**
+     * Get the map unresolved references from this page.
+     * This should be called after deserializing to retrieve
+     * the map of unresolved references that were serialized.
+     *
+     * @return the de-serialized map of unresolved objects
+     */
+    public Map getUnresolvedReferences() {
+        return unresolved;
+    }
+    
+    /**
+     * @return the regionAfter
+     */
+    public RegionAfterVport getRegionAfter() {
+        return regionAfter;
+    }
+
+    /**
+     * @param regionAfter to set
+     */
+    public void setRegionAfter(RegionAfterVport regionAfter) {
+        this.regionAfter = regionAfter;
+    }
+
+    /**
+     * @return the regionBefore
+     */
+    public RegionBeforeVport getRegionBefore() {
+        return regionBefore;
+    }
+
+    /**
+     * @param regionBefore to set
+     */
+    public void setRegionBefore(RegionBeforeVport regionBefore) {
+        this.regionBefore = regionBefore;
+    }
+
+    /**
+     * @return the regionBody
+     */
+    public RegionBodyVport getRegionBody() {
+        return regionBody;
+    }
+
+    /**
+     * @param regionBody to set
+     */
+    public void setRegionBody(RegionBodyVport regionBody) {
+        this.regionBody = regionBody;
+    }
+
+    /**
+     * @return the regionEnd
+     */
+    public RegionEndVport getRegionEnd() {
+        return regionEnd;
+    }
+
+    /**
+     * @param regionEnd to set
+     */
+    public void setRegionEnd(RegionEndVport regionEnd) {
+        this.regionEnd = regionEnd;
+    }
+
+    /**
+     * @return the regionStart
+     */
+    public RegionStartVport getRegionStart() {
+        return regionStart;
+    }
+
+    /**
+     * @param regionStart to set
+     */
+    public void setRegionStart(RegionStartVport regionStart) {
+        this.regionStart = regionStart;
+    }
+
+    /**
+     * Clone this page.
+     * This returns a new page with a clone of all the regions.
+     *
+     * @return a new clone of this page
+     */
+    public Object clone() {
+        PageRefArea p = (PageRefArea)(this.clone());
+        if (regionBody != null) {
+            p.regionBody = (RegionBodyVport)regionBody.clone();
+        }
+        if (regionBefore != null) {
+            p.regionBefore = (RegionBeforeVport)regionBefore.clone();
+        }
+        if (regionAfter != null) {
+            p.regionAfter = (RegionAfterVport)regionAfter.clone();
+        }
+        if (regionStart != null) {
+            p.regionStart = (RegionStartVport)regionStart.clone();
+        }
+        if (regionEnd != null) {
+            p.regionEnd = (RegionEndVport)regionEnd.clone();
+        }
+
+        return p;
+    }
+    
+}
+
index c06715fff891212cbd3b94e2f06f7aca7cf73f2b..b4b1dbd5bd23739430007f6a086c236cfa246ebe 100644 (file)
@@ -1,52 +1,19 @@
 /*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
  * $Id: PageViewport.java,v 1.16 2003/03/05 15:19:31 jeremias Exp $
- * ============================================================================
- *                    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
- * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 <jtauber@jtauber.com>. For more information on the Apache
- * Software Foundation, please see <http://www.apache.org/>.
  */ 
 package org.apache.fop.area;
 
@@ -59,19 +26,23 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.fop.fo.Constants;
+import org.apache.fop.datastructs.Node;
+import org.apache.fop.fo.properties.RetrievePosition;
 
 /**
- * Page viewport that specifies the viewport area and holds the page contents.
+ * Page viewport that specifies the viewport area.
  * This is the top level object for a page and remains valid for the life
  * of the document and the area tree.
  * This object may be used as a key to reference a page.
- * This is the level that creates the page.
- * The page (reference area) is then rendered inside the page object
+ * The immediate and only child of any viewport is a reference-area; in this
+ * cast the page-reference-area.
+ * The page reference area is then rendered inside the PageRefArea object
  */
-public class PageViewport implements Resolveable, Cloneable {
+public class PageViewport
+extends Area
+implements Viewport, Resolveable, Cloneable {
     
-    private Page page;
+    private PageRefArea pageRefArea;
     private Rectangle2D viewArea;
     private boolean clip = false;
     private String pageNumber = null;
@@ -99,11 +70,22 @@ public class PageViewport implements Resolveable, Cloneable {
      * @param p the page reference area that holds the contents
      * @param bounds the bounds of this viewport
      */
-    public PageViewport(Page p, Rectangle2D bounds) {
-        page = p;
+    public PageViewport(
+            Node parent, Object areaSync, PageRefArea p, Rectangle2D bounds) {
+        super(parent, areaSync);
+        pageRefArea = p;
         viewArea = bounds;
     }
 
+    /**
+     * Create a page viewport.
+     */
+    public PageViewport(Node parent, Object areaSync) {
+        super(parent, areaSync);
+        pageRefArea = null;
+        viewArea = null;
+    }
+    
     /**
      * Set if this viewport should clip.
      * @param c true if this viewport should clip
@@ -124,8 +106,8 @@ public class PageViewport implements Resolveable, Cloneable {
      * Get the page reference area with the contents.
      * @return the page reference area
      */
-    public Page getPage() {
-        return page;
+    public PageRefArea getPageRefArea() {
+        return pageRefArea;
     }
 
     /**
@@ -159,7 +141,7 @@ public class PageViewport implements Resolveable, Cloneable {
      * Add an unresolved id to this page.
      * All unresolved ids for the contents of this page are
      * added to this page. This is so that the resolvers can be
-     * serialized with the page to preserve the proper function.
+     * serialized with the pageRefArea to preserve the proper function.
      * @param id the id of the reference
      * @param res the resolver of the reference
      */
@@ -199,7 +181,7 @@ public class PageViewport implements Resolveable, Cloneable {
      *              may be null if not found
      */
     public void resolve(String id, List pages) {
-        if (page == null) {
+        if (pageRefArea == null) {
             if (pendingResolved == null) {
                 pendingResolved = new HashMap();
             }
@@ -236,7 +218,7 @@ public class PageViewport implements Resolveable, Cloneable {
      * For "last-ending-within-page" it adds all markers that
      * are ending, replacing earlier markers.
      * 
-     * Should this logic be placed in the Page layout manager.
+     * Should this logic be placed in the page layout manager.
      *
      * @param marks the map of markers to add
      * @param start if the area being added is starting or ending
@@ -307,7 +289,7 @@ public class PageViewport implements Resolveable, Cloneable {
     public Object getMarker(String name, int pos) {
         Object mark = null;
         switch (pos) {
-            case Constants.RetrievePosition.FSWP:
+            case RetrievePosition.FIRST_STARTING_WITHIN_PAGE:
                 if (markerFirstStart != null) {
                     mark = markerFirstStart.get(name);
                 }
@@ -315,12 +297,12 @@ public class PageViewport implements Resolveable, Cloneable {
                     mark = markerFirstAny.get(name);
                 }
             break;
-            case Constants.RetrievePosition.FIC:
+            case RetrievePosition.FIRST_INCLUDING_CARRYOVER:
                 if (markerFirstAny != null) {
                     mark = markerFirstAny.get(name);
                 }
             break;
-            case Constants.RetrievePosition.LSWP:
+            case RetrievePosition.LAST_STARTING_WITHIN_PAGE:
                 if (markerLastStart != null) {
                     mark = markerLastStart.get(name);
                 }
@@ -328,7 +310,7 @@ public class PageViewport implements Resolveable, Cloneable {
                     mark = markerLastAny.get(name);
                 }
             break;
-            case Constants.RetrievePosition.LEWP:
+            case RetrievePosition.LAST_ENDING_WITHIN_PAGE:
                 if (markerLastEnd != null) {
                     mark = markerLastEnd.get(name);
                 }
@@ -341,30 +323,30 @@ public class PageViewport implements Resolveable, Cloneable {
     }
 
     /**
-     * Save the page contents to an object stream.
-     * The map of unresolved references are set on the page so that
+     * Save the viewport pageRefArea to an object stream.
+     * The map of unresolved references are set on the pageRefArea so that
      * the resolvers can be properly serialized and reloaded.
      * @param out the object output stream to write the contents
-     * @throws Exception if there is a problem saving the page
+     * @throws Exception if there is a problem saving the pageRefArea
      */
     public void savePage(ObjectOutputStream out) throws Exception {
         // set the unresolved references so they are serialized
-        page.setUnresolvedReferences(unresolved);
-        out.writeObject(page);
-        page = null;
+        pageRefArea.setUnresolvedReferences(unresolved);
+        out.writeObject(pageRefArea);
+        pageRefArea = null;
     }
 
     /**
-     * Load the page contents from an object stream.
-     * This loads the page contents from the stream and
+     * Load the viewport pageRefArea from an object stream.
+     * This loads the pageRefArea from the stream and
      * if there are any unresolved references that were resolved
      * while saved they will be resolved on the page contents.
-     * @param in the object input stream to read the page from
-     * @throws Exception if there is an error loading the page
+     * @param in the object input stream to read the pageRefArea from
+     * @throws Exception if there is an error loading the pageRefArea
      */
     public void loadPage(ObjectInputStream in) throws Exception {
-        page = (Page) in.readObject();
-        unresolved = page.getUnresolvedReferences();
+        pageRefArea = (PageRefArea) in.readObject();
+        unresolved = pageRefArea.getUnresolvedReferences();
         if (unresolved != null && pendingResolved != null) {
             for (Iterator iter = pendingResolved.keySet().iterator();
                          iter.hasNext();) {
@@ -381,18 +363,18 @@ public class PageViewport implements Resolveable, Cloneable {
      * @return a copy of this page and associated viewports
      */
     public Object clone() {
-        Page p = (Page)page.clone();
-        PageViewport ret = new PageViewport(p, (Rectangle2D)viewArea.clone());
+        PageRefArea p = (PageRefArea)pageRefArea.clone();
+        PageViewport ret = new PageViewport(parent, sync, p, (Rectangle2D)viewArea.clone());
         return ret;
     }
 
     /**
-     * Clear the page contents to save memory.
+     * Clear the pageRefArea contents to save memory.
      * This object is kept for the life of the area tree since
      * it holds id and marker information and is used as a key.
      */
     public void clear() {
-        page = null;
+        pageRefArea = null;
     }
     
     /**
diff --git a/src/java/org/apache/fop/area/RegionAfterRefArea.java b/src/java/org/apache/fop/area/RegionAfterRefArea.java
new file mode 100644 (file)
index 0000000..e80f725
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 23/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionAfterRefArea
+    extends RegionRefArea
+    implements ReferenceArea {
+
+    /**
+     * @param parent
+     * @param sync
+     */
+    public RegionAfterRefArea(Node parent, Object sync) {
+        super(parent, sync);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionAfterVport.java b/src/java/org/apache/fop/area/RegionAfterVport.java
new file mode 100644 (file)
index 0000000..3b3cee0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 20/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionAfterVport extends RegionViewport {
+
+    /**
+     * @param parent
+     * @param sync
+     * @param viewArea
+     */
+    public RegionAfterVport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync, viewArea);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionBeforeRefArea.java b/src/java/org/apache/fop/area/RegionBeforeRefArea.java
new file mode 100644 (file)
index 0000000..b376419
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 23/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionBeforeRefArea
+    extends RegionRefArea
+    implements ReferenceArea {
+
+    /**
+     * @param parent
+     * @param sync
+     */
+    public RegionBeforeRefArea(Node parent, Object sync) {
+        super(parent, sync);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionBeforeVport.java b/src/java/org/apache/fop/area/RegionBeforeVport.java
new file mode 100644 (file)
index 0000000..0a1db3c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 20/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionBeforeVport extends RegionViewport {
+
+    /**
+     * @param parent
+     * @param sync
+     * @param viewArea
+     */
+    public RegionBeforeVport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync, viewArea);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionBodyRefArea.java b/src/java/org/apache/fop/area/RegionBodyRefArea.java
new file mode 100644 (file)
index 0000000..937d208
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * $Id$
+ * ============================================================================
+ *                    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
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * The body region area.
+ * This area contains a main reference area and optionally a
+ * before float and footnote area.
+ */
+public class RegionBodyRefArea
+extends RegionRefArea
+implements ReferenceArea {
+    //private BeforeFloat beforeFloat;
+    private MainReferenceArea mainReference;
+    //private Footnote footnote;
+    private int columnGap;
+    private int columnCount;
+
+    /**
+     * Create a new body region area.
+     * This sets the region reference area class to BODY.
+     */
+    public RegionBodyRefArea(Node parent, Object sync) {
+        super(parent, sync);
+    }
+
+    /**
+     * Set the number of columns for blocks when not spanning
+     *
+     * @param colCount the number of columns
+     */
+    public void setColumnCount(int colCount) {
+        this.columnCount = colCount;
+    }
+
+    /**
+     * Get the number of columns when not spanning
+     *
+     * @return the number of columns
+     */
+    public int getColumnCount() {
+        return this.columnCount;
+    }
+
+    /**
+     * Set the column gap between columns
+     * The length is in millipoints.
+     *
+     * @param colGap the column gap in millipoints
+     */
+    public void setColumnGap(int colGap) {
+        this.columnGap = colGap;
+    }
+
+    /**
+     * Set the before float area.
+     *
+     * @param bf the before float area
+     */
+//    public void setBeforeFloat(BeforeFloat bf) {
+//        beforeFloat = bf;
+//    }
+
+    /**
+     * Set the main reference area.
+     *
+     * @param mr the main reference area
+     */
+    public void setMainReference(MainReferenceArea mr) {
+        mainReference = mr;
+    }
+
+    /**
+     * Set the footnote area.
+     *
+     * @param foot the footnote area
+     */
+//    public void setFootnote(Footnote foot) {
+//        footnote = foot;
+//    }
+
+    /**
+     * Get the before float area.
+     *
+     * @return the before float area
+     */
+//    public BeforeFloat getBeforeFloat() {
+//        return beforeFloat;
+//    }
+
+    /**
+     * Get the main reference area.
+     *
+     * @return the main reference area
+     */
+    public MainReferenceArea getMainReference() {
+        return mainReference;
+    }
+
+    /**
+     * Get the footnote area.
+     *
+     * @return the footnote area
+     */
+//    public Footnote getFootnote() {
+//        return footnote;
+//    }
+
+    /**
+     * Clone this object.
+     *
+     * @return a shallow copy of this object
+     */
+    public Object clone() {
+        RegionBodyRefArea br = new RegionBodyRefArea(parent, sync);
+        br.setCoordTransformer(getCoordTransformer());
+        br.setIPDim(getIPDim());
+        br.columnGap = columnGap;
+        br.columnCount = columnCount;
+        //br.beforeFloat = beforeFloat;
+        br.mainReference = mainReference;
+        //br.footnote = footnote;
+        return br;
+    }
+}
diff --git a/src/java/org/apache/fop/area/RegionBodyVport.java b/src/java/org/apache/fop/area/RegionBodyVport.java
new file mode 100644 (file)
index 0000000..41c0dc4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 20/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionBodyVport extends RegionViewport {
+
+    /**
+     * @param parent
+     * @param sync
+     * @param viewArea
+     */
+    public RegionBodyVport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync, viewArea);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionEndRefArea.java b/src/java/org/apache/fop/area/RegionEndRefArea.java
new file mode 100644 (file)
index 0000000..74db15a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 23/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionEndRefArea extends RegionRefArea implements ReferenceArea {
+
+    /**
+     * @param parent
+     * @param sync
+     */
+    public RegionEndRefArea(Node parent, Object sync) {
+        super(parent, sync);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionEndVport.java b/src/java/org/apache/fop/area/RegionEndVport.java
new file mode 100644 (file)
index 0000000..dfc45c3
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 21/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionEndVport extends RegionViewport {
+
+    /**
+     * @param parent
+     * @param sync
+     * @param viewArea
+     */
+    public RegionEndVport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync, viewArea);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionRefArea.java b/src/java/org/apache/fop/area/RegionRefArea.java
new file mode 100644 (file)
index 0000000..c0615df
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * This is an abstract reference area for the page regions - currently
+ * region-body, region-before, region-after, region-start and region-end.
+ * It is cloneable through the ReferenceArea interface implementation.
+ */
+public abstract class RegionRefArea
+extends AbstractReferenceArea
+implements ReferenceArea {
+    
+    // the list of block areas from the static flow
+    private ArrayList blocks = new ArrayList();
+
+    /**
+     * Create a new region reference area.
+     */
+    public RegionRefArea(Node parent, Object sync) {
+        super(parent, sync);
+    }
+
+    /**
+     * Get the block in this region.
+     *
+     * @return the list of blocks in this region
+     */
+    public List getBlocks() {
+        return blocks;
+    }
+
+    /**
+     * Clone this region.
+     * This is used when cloning the page by the page master.
+     * The blocks are not copied since the master will have no blocks.
+     *
+     * @return a copy of this region reference area
+     */
+    public Object clone() {
+        RegionRefArea rr;
+        rr = (RegionRefArea)(super.clone());
+        rr.blocks = (ArrayList)(blocks.clone());
+        return rr;
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionStartRefArea.java b/src/java/org/apache/fop/area/RegionStartRefArea.java
new file mode 100644 (file)
index 0000000..059ae41
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 23/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionStartRefArea
+    extends RegionRefArea
+    implements ReferenceArea {
+
+    /**
+     * @param parent
+     * @param sync
+     */
+    public RegionStartRefArea(Node parent, Object sync) {
+        super(parent, sync);
+        // TODO Auto-generated constructor stub
+    }
+
+}
diff --git a/src/java/org/apache/fop/area/RegionStartVport.java b/src/java/org/apache/fop/area/RegionStartVport.java
new file mode 100644 (file)
index 0000000..8b02663
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 21/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+import java.awt.geom.Rectangle2D;
+
+import org.apache.fop.datastructs.Node;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public class RegionStartVport extends RegionViewport {
+
+    /**
+     * @param parent
+     * @param sync
+     * @param viewArea
+     */
+    public RegionStartVport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync, viewArea);
+        // TODO Auto-generated constructor stub
+    }
+
+}
index 1c83901e5f91c27112a76f4b30bd13e312dc7dc5..d7d9acf26d373ca7c9c20340ab8c9194a7a9235a 100644 (file)
@@ -52,17 +52,15 @@ package org.apache.fop.area;
 
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.fop.traits.BorderProps;
+import org.apache.fop.datastructs.Node;
 
 /**
  * Region Viewport reference area.
  * This area is the viewport for a region and contains a region area.
  */
-public class RegionViewport extends Area implements Cloneable {
+public class RegionViewport extends Area implements Viewport, Cloneable {
     // this rectangle is relative to the page
-    private RegionReference region;
+    private RegionRefArea region;
     private Rectangle2D viewArea;
     private boolean clip = false;
 
@@ -71,7 +69,8 @@ public class RegionViewport extends Area implements Cloneable {
      *
      * @param viewArea the view area of this viewport
      */
-    public RegionViewport(Rectangle2D viewArea) {
+    public RegionViewport(Node parent, Object sync, Rectangle2D viewArea) {
+        super(parent, sync);
         this.viewArea = viewArea;
     }
 
@@ -80,7 +79,7 @@ public class RegionViewport extends Area implements Cloneable {
      *
      * @param reg the child region inside this viewport
      */
-    public void setRegion(RegionReference reg) {
+    public void setRegion(RegionRefArea reg) {
         region = reg;
     }
 
@@ -89,7 +88,7 @@ public class RegionViewport extends Area implements Cloneable {
      *
      * @return the child region inside this viewport
      */
-    public RegionReference getRegion() {
+    public RegionRefArea getRegion() {
         return region;
     }
 
@@ -116,82 +115,86 @@ public class RegionViewport extends Area implements Cloneable {
      *
      * @return width in millipoints
      */
-    public int getBorderAndPaddingWidthBefore() {
-        int margin = 0;
-        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_BEFORE);
-        if (bps != null) {
-            margin = bps.width;
-        }
-        
-        Integer padWidth = (Integer) getTrait(Trait.PADDING_BEFORE);
-        if (padWidth != null) {
-            margin += padWidth.intValue();
-        }
-
-        return margin;
-    }
+//    public int getBorderAndPaddingWidthBefore() {
+//        int margin = 0;
+//        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_BEFORE);
+//        if (bps != null) {
+//            margin = bps.width;
+//        }
+//        
+//        Integer padWidth = (Integer) getTrait(Trait.PADDING_BEFORE);
+//        if (padWidth != null) {
+//            margin += padWidth.intValue();
+//        }
+//
+//        return margin;
+//    }
     
     /**
      * Return the sum of region border- and padding-after
      *
      * @return width in millipoints
      */
-    public int getBorderAndPaddingWidthAfter() {
-        int margin = 0;
-        
-        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_AFTER);
-        if (bps != null) {
-            margin = bps.width;
-        }
-        
-        Integer padWidth = (Integer) getTrait(Trait.PADDING_AFTER);
-        if (padWidth != null) {
-            margin += padWidth.intValue();
-        }
-
-        return margin;
-    }
+//    public int getBorderAndPaddingWidthAfter() {
+//        int margin = 0;
+//        
+//        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_AFTER);
+//        if (bps != null) {
+//            margin = bps.width;
+//        }
+//        
+//        Integer padWidth = (Integer) getTrait(Trait.PADDING_AFTER);
+//        if (padWidth != null) {
+//            margin += padWidth.intValue();
+//        }
+//
+//        return margin;
+//    }
 
     /**
      * Return the sum of region border- and padding-start
      *
      * @return width in millipoints
      */
-    public int getBorderAndPaddingWidthStart() {
-        int margin = 0;
-        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_START);
-        if (bps != null) {
-            margin = bps.width;
-        }
-        
-        Integer padWidth = (Integer) getTrait(Trait.PADDING_START);
-        if (padWidth != null) {
-            margin += padWidth.intValue();
-        }
-
-        return margin;
-    }
+//    public int getBorderAndPaddingWidthStart() {
+//        int margin = 0;
+//        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_START);
+//        if (bps != null) {
+//            margin = bps.width;
+//        }
+//        
+//        Integer padWidth = (Integer) getTrait(Trait.PADDING_START);
+//        if (padWidth != null) {
+//            margin += padWidth.intValue();
+//        }
+//
+//        return margin;
+//    }
 
     /**
      * Return the sum of region border- and padding-end
      *
      * @return width in millipoints
      */
-    public int getBorderAndPaddingWidthEnd() {
-        int margin = 0;
-        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_END);
-        if (bps != null) {
-            margin = bps.width;
-        }
-        
-        Integer padWidth = (Integer) getTrait(Trait.PADDING_END);
-        if (padWidth != null) {
-            margin += padWidth.intValue();
-        }
-
-        return margin;
-    }
+//    public int getBorderAndPaddingWidthEnd() {
+//        int margin = 0;
+//        BorderProps bps = (BorderProps) getTrait(Trait.BORDER_END);
+//        if (bps != null) {
+//            margin = bps.width;
+//        }
+//        
+//        Integer padWidth = (Integer) getTrait(Trait.PADDING_END);
+//        if (padWidth != null) {
+//            margin += padWidth.intValue();
+//        }
+//
+//        return margin;
+//    }
 
+    /**
+     * @param out
+     * @throws IOException
+     */
     private void writeObject(java.io.ObjectOutputStream out)
     throws IOException {
         out.writeFloat((float) viewArea.getX());
@@ -199,7 +202,7 @@ public class RegionViewport extends Area implements Cloneable {
         out.writeFloat((float) viewArea.getWidth());
         out.writeFloat((float) viewArea.getHeight());
         out.writeBoolean(clip);
-        out.writeObject(props);
+        //out.writeObject(props);
         out.writeObject(region);
     }
 
@@ -208,8 +211,8 @@ public class RegionViewport extends Area implements Cloneable {
         viewArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(),
                                          in.readFloat(), in.readFloat());
         clip = in.readBoolean();
-        props = (HashMap)in.readObject();
-        setRegion((RegionReference) in.readObject());
+        //props = (HashMap)in.readObject();
+        setRegion((RegionRefArea) in.readObject());
     }
 
     /**
@@ -219,11 +222,12 @@ public class RegionViewport extends Area implements Cloneable {
      * @return a new copy of this region viewport
      */
     public Object clone() {
-        RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone());
-        rv.region = (RegionReference)region.clone();
-        if (props != null) {
-            rv.props = (HashMap)props.clone();
-        }
+        RegionViewport rv =
+            new RegionViewport(parent, sync, (Rectangle2D)viewArea.clone());
+        rv.region = (RegionRefArea)region.clone();
+//        if (props != null) {
+//            rv.props = (HashMap)props.clone();
+//        }
         return rv;
     }
 }
index 04258bfb0eae1fe6902fe9828349601d4585f254..cd487c1bad0f066ed674725da6af2ee4e48fd4aa 100644 (file)
@@ -1,83 +1,48 @@
 /*
+   Copyright 1999-2004 The Apache Software Foundation.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
  * $Id: Span.java,v 1.8 2003/03/05 15:19:31 jeremias Exp $
- * ============================================================================
- *                    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
- * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 <jtauber@jtauber.com>. For more information on the Apache
- * Software Foundation, please see <http://www.apache.org/>.
  */ 
 package org.apache.fop.area;
 
+import java.io.Serializable;
 import java.util.List;
 
+import org.apache.fop.datastructs.Node;
+
 /**
- * The span reference area.
+ * The span reference areas are children of the main-reference-area
+ * of a region-body.
  * This is a reference area block area with 0 border and padding
- * The span reference areas are stacked inside the main reference area.
  */
-public class Span extends Area {
+public class Span
+extends AbstractReferenceArea
+implements ReferenceArea, Serializable {
     // the list of flow reference areas in this span area
     private List flowAreas;
-    private int height;
+    
+    private Integer cols;
 
     /**
      * Create a span area with the number of columns for this span area.
      *
      * @param cols the number of columns in the span
      */
-    public Span(int cols) {
-        flowAreas = new java.util.ArrayList(cols);
-    }
-
-    /**
-     * Add the flow area to this span area.
-     *
-     * @param flow the flow area to add
-     */
-    public void addFlow(Flow flow) {
-        flowAreas.add(flow);
+    public Span(Node parent, Object sync, Integer cols) {
+        super(parent, sync);
+        this.cols = cols;
     }
 
     /**
@@ -85,27 +50,8 @@ public class Span extends Area {
      *
      * @return the number of columns in this span area
      */
-    public int getColumnCount() {
-        return flowAreas.size();
-    }
-
-    /**
-     * Get the height of this span area.
-     *
-     * @return the height of this span area
-     */
-    public int getHeight() {
-        return height;
-    }
-
-    /**
-     * Get the flow area for a particular column.
-     *
-     * @param count the column number for the flow
-     * @return the flow area for the requested column
-     */
-    public Flow getFlow(int count) {
-        return (Flow) flowAreas.get(count);
+    public Integer getColumnCount() {
+        return cols;
     }
 
 }
diff --git a/src/java/org/apache/fop/area/Viewport.java b/src/java/org/apache/fop/area/Viewport.java
new file mode 100644 (file)
index 0000000..df25a70
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 19/02/2004
+ * $Id$
+ */
+package org.apache.fop.area;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public interface Viewport {
+
+}