From ac2c1eac8dc8cc3ed3347d63bc97c974a705b4fe Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sat, 28 Feb 2004 02:06:44 +0000 Subject: [PATCH] Added page-sequence and generated-by args to Area constructor. Modified Viewport and ReferenceArea classes to handle appropriate functions. Constructor modifications to match superclasses. Some synchronization of unsynchronized methods. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197396 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/area/AbstractReferenceArea.java | 38 +- .../org/apache/fop/area/AbstractViewport.java | 139 +++++++ src/java/org/apache/fop/area/Area.java | 109 ++++-- .../apache/fop/area/BeforeFloatRefArea.java | 25 +- src/java/org/apache/fop/area/BlockArea.java | 23 +- .../org/apache/fop/area/BlockContainer.java | 23 +- .../org/apache/fop/area/FootnoteRefArea.java | 23 +- .../apache/fop/area/MainReferenceArea.java | 32 +- .../apache/fop/area/NormalFlowRefArea.java | 44 +++ src/java/org/apache/fop/area/PageRefArea.java | 69 ++-- .../org/apache/fop/area/PageViewport.java | 340 ++++++++++-------- .../org/apache/fop/area/ReferenceArea.java | 2 + .../apache/fop/area/RegionAfterRefArea.java | 10 +- .../org/apache/fop/area/RegionAfterVport.java | 12 +- .../apache/fop/area/RegionBeforeRefArea.java | 11 +- .../apache/fop/area/RegionBeforeVport.java | 11 +- .../apache/fop/area/RegionBodyRefArea.java | 70 +++- .../org/apache/fop/area/RegionBodyVport.java | 12 +- .../org/apache/fop/area/RegionEndRefArea.java | 15 +- .../org/apache/fop/area/RegionEndVport.java | 12 +- .../org/apache/fop/area/RegionRefArea.java | 10 +- .../apache/fop/area/RegionStartRefArea.java | 10 +- .../org/apache/fop/area/RegionStartVport.java | 12 +- .../org/apache/fop/area/RegionViewport.java | 129 +++---- src/java/org/apache/fop/area/Span.java | 69 +++- src/java/org/apache/fop/area/Viewport.java | 34 +- src/java/org/apache/fop/area/ViewportI.java | 48 +++ 27 files changed, 876 insertions(+), 456 deletions(-) create mode 100644 src/java/org/apache/fop/area/AbstractViewport.java create mode 100644 src/java/org/apache/fop/area/NormalFlowRefArea.java create mode 100644 src/java/org/apache/fop/area/ViewportI.java diff --git a/src/java/org/apache/fop/area/AbstractReferenceArea.java b/src/java/org/apache/fop/area/AbstractReferenceArea.java index f20cdf403..fa3c995cc 100644 --- a/src/java/org/apache/fop/area/AbstractReferenceArea.java +++ b/src/java/org/apache/fop/area/AbstractReferenceArea.java @@ -19,6 +19,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -32,25 +34,17 @@ public abstract class AbstractReferenceArea protected CoordTransformer transformer = new CoordTransformer(); /** - * @param parent - * @param index - * @param areaSync - * @throws IndexOutOfBoundsException + * @param pageSeq through which this area was generated + * @param generatedBy the given FONode generated this + * @param parent area of this + * @param sync object on which operations in this are synchronized */ - 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); + public AbstractReferenceArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); // TODO Auto-generated constructor stub } @@ -64,7 +58,9 @@ public abstract class AbstractReferenceArea * @param transformer to position this reference area */ public void setCoordTransformer(CoordTransformer transformer) { - this.transformer = transformer; + synchronized (sync) { + this.transformer = transformer; + } } /** @@ -73,7 +69,9 @@ public abstract class AbstractReferenceArea * @return the current transformer to position this reference area */ public CoordTransformer getCoordTransformer() { - return this.transformer; + synchronized (sync) { + return this.transformer; + } } /** diff --git a/src/java/org/apache/fop/area/AbstractViewport.java b/src/java/org/apache/fop/area/AbstractViewport.java new file mode 100644 index 000000000..4bfc194de --- /dev/null +++ b/src/java/org/apache/fop/area/AbstractViewport.java @@ -0,0 +1,139 @@ +/* + * + * 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 27/02/2004 + * $Id$ + */ +package org.apache.fop.area; + +import java.awt.geom.Rectangle2D; + +import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; + +/** + * @author pbw + * @version $Revision$ $Name$ + */ +public class AbstractViewport +extends Area +implements Viewport { + + /** The viewport rectange */ + protected Rectangle2D viewArea = null; + + /** Does the viewport rectange clip the reference-area? */ + protected boolean clip = true; + + /** The reference-area of the viewport/reference pair */ + protected ReferenceArea refArea; + + /** + * @param pageSeq + * @param generatedBy + * @param parent + * @param sync + */ + public AbstractViewport(FoPageSequence pageSeq, FONode generatedBy, + Node parent, Object sync) { + super(pageSeq, generatedBy, parent, sync); + } + /** + * @param pageSeq + * @param generatedBy + */ + public AbstractViewport(FoPageSequence pageSeq, FONode generatedBy) { + super(pageSeq, generatedBy); + } + /** + * @param pageSeq + * @param generatedBy + * @param viewArea the viewport rectangle + * @param parent + * @param sync + */ + public AbstractViewport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); + this.viewArea = viewArea; + } + /** + * @param pageSeq + * @param generatedBy + * @param viewArea the viewport rectangle + */ + public AbstractViewport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy) { + super(pageSeq, generatedBy); + this.viewArea = viewArea; + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#getViewArea() + */ + public Rectangle2D getViewArea() { + synchronized (sync) { + return viewArea; + } + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#setViewArea(java.awt.geom.Rectangle2D) + */ + public void setViewArea(Rectangle2D viewArea) { + synchronized (sync) { + this.viewArea = viewArea; + } + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#setReferenceArea(org.apache.fop.area.ReferenceArea) + */ + public void setReferenceArea(ReferenceArea ref) { + synchronized (sync) { + refArea = ref; + } + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#getReferenceArea() + */ + public ReferenceArea getReferenceArea() { + synchronized (sync) { + return refArea; + } + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#setClip(boolean) + */ + public void setClip(boolean clip) { + synchronized (sync) { + this.clip = clip; + } + } + /* (non-Javadoc) + * @see org.apache.fop.area.Viewport#getClip() + */ + public boolean getClip() { + synchronized (sync) { + return clip; + } + } + +} diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index 4595f2d11..53db56544 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; import org.apache.fop.datastructs.SyncedNode; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -37,6 +39,10 @@ import org.apache.fop.datastructs.SyncedNode; */ public class Area extends SyncedNode implements Cloneable { + /** The page-sequence which generated this area. */ + protected FoPageSequence pageSeq = null; + /** The FO node that generated this node. */ + protected FONode generatedBy = null; /** Current inline progression dimension. May be unknown. */ protected Integer iPDim = null; /** Maximum required inline progression dimension. May be unknown. */ @@ -51,115 +57,178 @@ public class Area extends SyncedNode implements Cloneable { protected Integer bPDimMin = null; /** + * @param pageSeq through which this area was generated + * @param generatedBy the given FONode generated this * @param parent Node of this * @param index of this in children of parent + * @param sync the object on which this area is synchronized * @throws IndexOutOfBoundsException */ - public Area(Node parent, int index, Object areaSync) + public Area( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + int index, + Object sync) throws IndexOutOfBoundsException { - super(parent, index, areaSync); - // TODO Auto-generated constructor stub + super(parent, index, sync); + this.pageSeq = pageSeq; + this.generatedBy = generatedBy; } /** + * @param pageSeq through which this area was generated + * @param generatedBy the given FONode generated this * @param parent Node of this + * @param sync the object on which this area is synchronized * @throws IndexOutOfBoundsException */ - public Area(Node parent, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, areaSync); - // TODO Auto-generated constructor stub + public Area( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(parent, sync); + this.pageSeq = pageSeq; + this.generatedBy = generatedBy; } /** * Construct an Area which is the root of a tree, and is * synchronized on itself + * @param pageSeq through which this area was generated + * @param generatedBy the given FONode generated this */ - public Area() { + public Area( + FoPageSequence pageSeq, + FONode generatedBy) { super(); + this.pageSeq = pageSeq; + this.generatedBy = generatedBy; + } + + /** + * @return the generatedBy + */ + public FONode getGeneratedBy() { + synchronized (sync) { + return generatedBy; + } + } + /** + * @param generatedBy to set + */ + public void setGeneratedBy(FONode generatedBy) { + synchronized (sync) { + this.generatedBy = generatedBy; + } } /** * @return the bPDim */ public Integer getBPDim() { - return bPDim; + synchronized (sync) { + return bPDim; + } } /** * @param dim to set */ public void setBPDim(Integer dim) { - bPDim = dim; + synchronized (sync) { + bPDim = dim; + } } /** * @return the bPDimMax */ public Integer getBPDimMax() { - return bPDimMax; + synchronized (sync) { + return bPDimMax; + } } /** * @param dimMax to set */ public void setBPDimMax(Integer dimMax) { - bPDimMax = dimMax; + synchronized (sync) { + bPDimMax = dimMax; + } } /** * @return the bPDimMin */ public Integer getBPDimMin() { - return bPDimMin; + synchronized (sync) { + return bPDimMin; + } } /** * @param dimMin to set */ public void setBPDimMin(Integer dimMin) { - bPDimMin = dimMin; + synchronized (sync) { + bPDimMin = dimMin; + } } /** * @return the iPDim */ public Integer getIPDim() { - return iPDim; + synchronized (sync) { + return iPDim; + } } /** * @param dim to set */ public void setIPDim(Integer dim) { - iPDim = dim; + synchronized (sync) { + iPDim = dim; + } } /** * @return the iPDimMax */ public Integer getIPDimMax() { - return iPDimMax; + synchronized(sync) { + return iPDimMax; + } } /** * @param dimMax to set */ public void setIPDimMax(Integer dimMax) { - iPDimMax = dimMax; + synchronized (sync) { + iPDimMax = dimMax; + } } /** * @return the iPDimMin */ public Integer getIPDimMin() { - return iPDimMin; + synchronized (sync) { + return iPDimMin; + } } /** * @param dimMin to set */ public void setIPDimMin(Integer dimMin) { - iPDimMin = dimMin; + synchronized (sync) { + iPDimMin = dimMin; + } } } diff --git a/src/java/org/apache/fop/area/BeforeFloatRefArea.java b/src/java/org/apache/fop/area/BeforeFloatRefArea.java index 46d2920b9..b4ce4b09e 100644 --- a/src/java/org/apache/fop/area/BeforeFloatRefArea.java +++ b/src/java/org/apache/fop/area/BeforeFloatRefArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -30,26 +32,17 @@ public class BeforeFloatRefArea implements ReferenceArea { /** + * @param pageSeq through which this area was generated * @param parent - * @param index * @param areaSync * @throws IndexOutOfBoundsException */ - public BeforeFloatRefArea(Node parent, int index, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, index, areaSync); - // TODO Auto-generated constructor stub - } - - /** - * @param parent - * @param areaSync - * @throws IndexOutOfBoundsException - */ - public BeforeFloatRefArea(Node parent, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, areaSync); - // TODO Auto-generated constructor stub + public BeforeFloatRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object areaSync) { + super(pageSeq, generatedBy, parent, areaSync); } } diff --git a/src/java/org/apache/fop/area/BlockArea.java b/src/java/org/apache/fop/area/BlockArea.java index 507d3c8af..5d3c73b07 100644 --- a/src/java/org/apache/fop/area/BlockArea.java +++ b/src/java/org/apache/fop/area/BlockArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -29,22 +31,13 @@ public class BlockArea extends Area { /** * @param parent of this node - * @param index of this in children of parent - * @throws IndexOutOfBoundsException */ - public BlockArea(Node parent, int index, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, index, areaSync); - // TODO Auto-generated constructor stub - } - - /** - * @param parent of this node - * @throws IndexOutOfBoundsException - */ - public BlockArea(Node parent, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, areaSync); + public BlockArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); // TODO Auto-generated constructor stub } diff --git a/src/java/org/apache/fop/area/BlockContainer.java b/src/java/org/apache/fop/area/BlockContainer.java index 5bb6a1350..c63d51219 100644 --- a/src/java/org/apache/fop/area/BlockContainer.java +++ b/src/java/org/apache/fop/area/BlockContainer.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -31,22 +33,13 @@ implements ReferenceArea { /** * @param parent - * @param index - * @throws IndexOutOfBoundsException */ - public BlockContainer(Node parent, int index, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, index, areaSync); - // TODO Auto-generated constructor stub - } - - /** - * @param parent - * @throws IndexOutOfBoundsException - */ - public BlockContainer(Node parent, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, areaSync); + public BlockContainer( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object areaSync) { + super(pageSeq, generatedBy, parent, areaSync); // TODO Auto-generated constructor stub } diff --git a/src/java/org/apache/fop/area/FootnoteRefArea.java b/src/java/org/apache/fop/area/FootnoteRefArea.java index f7c1b91a9..2d8e7db1f 100644 --- a/src/java/org/apache/fop/area/FootnoteRefArea.java +++ b/src/java/org/apache/fop/area/FootnoteRefArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -31,25 +33,16 @@ public class FootnoteRefArea /** * @param parent - * @param index * @param areaSync * @throws IndexOutOfBoundsException */ - public FootnoteRefArea(Node parent, int index, Object areaSync) + public FootnoteRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object areaSync) throws IndexOutOfBoundsException { - super(parent, index, areaSync); - // TODO Auto-generated constructor stub - } - - /** - * @param parent - * @param areaSync - * @throws IndexOutOfBoundsException - */ - public FootnoteRefArea(Node parent, Object areaSync) - throws IndexOutOfBoundsException { - super(parent, areaSync); - // TODO Auto-generated constructor stub + super(pageSeq, generatedBy, parent, areaSync); } } diff --git a/src/java/org/apache/fop/area/MainReferenceArea.java b/src/java/org/apache/fop/area/MainReferenceArea.java index 99be0f170..3fc741c1a 100644 --- a/src/java/org/apache/fop/area/MainReferenceArea.java +++ b/src/java/org/apache/fop/area/MainReferenceArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import java.util.List; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * The main body reference area. @@ -32,18 +34,18 @@ 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 + public MainReferenceArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object areaSync) { + super(pageSeq, generatedBy, parent, areaSync); } /** @@ -64,23 +66,5 @@ implements ReferenceArea { 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/NormalFlowRefArea.java b/src/java/org/apache/fop/area/NormalFlowRefArea.java new file mode 100644 index 000000000..8963982e7 --- /dev/null +++ b/src/java/org/apache/fop/area/NormalFlowRefArea.java @@ -0,0 +1,44 @@ +/* + * + * 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 28/02/2004 + * $Id$ + */ +package org.apache.fop.area; + +import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; + +/** + * @author pbw + * @version $Revision$ $Name$ + */ +public class NormalFlowRefArea extends AbstractReferenceArea + implements + ReferenceArea { + /** + * @param pageSeq + * @param generatedBy + * @param parent + * @param sync + */ + public NormalFlowRefArea(FoPageSequence pageSeq, FONode generatedBy, + Node parent, Object sync) { + super(pageSeq, generatedBy, parent, sync); + // TODO Auto-generated constructor stub + } +} diff --git a/src/java/org/apache/fop/area/PageRefArea.java b/src/java/org/apache/fop/area/PageRefArea.java index 558ca29e2..9f5be318e 100644 --- a/src/java/org/apache/fop/area/PageRefArea.java +++ b/src/java/org/apache/fop/area/PageRefArea.java @@ -1,52 +1,19 @@ /* - * $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. + * Copyright 1999-2004 The Apache Software Foundation. * - * 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. + * 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 * - * 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. + * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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. * - * 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 . For more information on the Apache - * Software Foundation, please see . + * $Id$ */ package org.apache.fop.area; @@ -54,6 +21,8 @@ import java.io.Serializable; import java.util.Map; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * The page. @@ -65,6 +34,10 @@ import org.apache.fop.datastructs.Node; * memory if there are forward references. * The page is cloneable so the page master can make copies of * the top level page and regions. + * + * @author The Apache XML-FOP sub-project + * @author pbw + * @version $Revision$ $Name$ */ public class PageRefArea extends AbstractReferenceArea @@ -79,8 +52,12 @@ implements ReferenceArea, Serializable { // temporary map of unresolved objects used when serializing the page private Map unresolved = null; - public PageRefArea(Node parent, Object sync) { - super(parent, sync); + public PageRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); } /** diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index c2574fb7c..5b1f61de2 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -18,6 +18,7 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; +import java.io.IOException; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.util.ArrayList; @@ -27,6 +28,8 @@ import java.util.HashMap; import java.util.Iterator; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; import org.apache.fop.fo.properties.RetrievePosition; /** @@ -39,13 +42,12 @@ import org.apache.fop.fo.properties.RetrievePosition; * The page reference area is then rendered inside the PageRefArea object */ public class PageViewport -extends Area -implements Viewport, Resolveable, Cloneable { +extends AbstractViewport +implements Viewport, Resolveable { + /** Unique ID for this page. 0 is an invalid ID. */ private long pageId = 0; - private PageRefArea pageRefArea; - private Rectangle2D viewArea; - private boolean clip = false; + /** The formatted page number */ private String pageNumber = null; // list of id references and the rectangle on the page @@ -73,11 +75,15 @@ implements Viewport, Resolveable, Cloneable { * @param p the page reference area for the contents of this page * @param bounds the dimensions of the viewport */ - public PageViewport(long pageId, PageRefArea p, Rectangle2D bounds) { - super(); + public PageViewport( + FoPageSequence pageSeq, + FONode generatedBy, + long pageId, + Rectangle2D bounds, + PageRefArea p) { + super(bounds, pageSeq, generatedBy); this.pageId = pageId; - pageRefArea = p; - viewArea = bounds; + refArea = p; } /** @@ -89,12 +95,16 @@ implements Viewport, Resolveable, Cloneable { * @param bounds the dimensions of the viewport */ public PageViewport( - Node parent, Object sync, long pageId, - PageRefArea p, Rectangle2D bounds) { - super(parent, sync); + FoPageSequence pageSeq, + FONode generatedBy, + long pageId, + Rectangle2D bounds, + PageRefArea p, + Node parent, + Object sync) { + super(bounds, pageSeq, generatedBy, parent, sync); this.pageId = pageId; - pageRefArea = p; - viewArea = bounds; + refArea = p; } /** @@ -103,35 +113,44 @@ implements Viewport, Resolveable, Cloneable { * @param sync * @param pageId */ - public PageViewport(Node parent, Object sync, long pageId) { - super(parent, sync); + public PageViewport( + FoPageSequence pageSeq, + FONode generatedBy, + long pageId, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); this.pageId = pageId; - pageRefArea = null; + refArea = null; viewArea = null; } - + /** - * Set if this viewport should clip. - * @param c true if this viewport should clip + * @return the pageId */ - public void setClip(boolean c) { - clip = c; + public long getPageId() { + synchronized (sync) { + return pageId; + } } /** - * Get the view area rectangle of this viewport. - * @return the rectangle for this viewport + * @param pageId to set */ - public Rectangle2D getViewArea() { - return viewArea; + public void setPageId(long pageId) { + synchronized (sync) { + this.pageId = pageId; + } } - + /** * Get the page reference area with the contents. * @return the page reference area */ public PageRefArea getPageRefArea() { - return pageRefArea; + synchronized (sync) { + return (PageRefArea)getReferenceArea(); + } } /** @@ -139,7 +158,9 @@ implements Viewport, Resolveable, Cloneable { * @param num the string representing the page number */ public void setPageNumber(String num) { - pageNumber = num; + synchronized (sync) { + pageNumber = num; + } } /** @@ -147,7 +168,9 @@ implements Viewport, Resolveable, Cloneable { * @return the string that represents this page */ public String getPageNumber() { - return pageNumber; + synchronized (sync) { + return pageNumber; + } } /** @@ -159,15 +182,17 @@ implements Viewport, Resolveable, Cloneable { * @param res the resolver of the reference */ public void addUnresolvedID(String id, Resolveable res) { - if (unresolved == null) { - unresolved = new HashMap(); - } - List list = (List)unresolved.get(id); - if (list == null) { - list = new ArrayList(); - unresolved.put(id, list); + synchronized (sync) { + if (unresolved == null) { + unresolved = new HashMap(); + } + List list = (List)unresolved.get(id); + if (list == null) { + list = new ArrayList(); + unresolved.put(id, list); + } + list.add(res); } - list.add(res); } /** @@ -175,7 +200,9 @@ implements Viewport, Resolveable, Cloneable { * @return true if the page is resolved and can be rendered */ public boolean isResolved() { - return unresolved == null; + synchronized (sync) { + return unresolved == null; + } } /** @@ -194,26 +221,28 @@ implements Viewport, Resolveable, Cloneable { * may be null if not found */ public void resolve(String id, List pages) { - if (pageRefArea == null) { - if (pendingResolved == null) { - pendingResolved = new HashMap(); - } - pendingResolved.put(id, pages); - } else { - if (unresolved != null) { - List todo = (List)unresolved.get(id); - if (todo != null) { - for (int count = 0; count < todo.size(); count++) { - Resolveable res = (Resolveable)todo.get(count); - res.resolve(id, pages); + synchronized (sync) { + if (refArea == null) { + if (pendingResolved == null) { + pendingResolved = new HashMap(); + } + pendingResolved.put(id, pages); + } else { + if (unresolved != null) { + List todo = (List)unresolved.get(id); + if (todo != null) { + for (int count = 0; count < todo.size(); count++) { + Resolveable res = (Resolveable)todo.get(count); + res.resolve(id, pages); + } } } } - } - if (unresolved != null) { - unresolved.remove(id); - if (unresolved.isEmpty()) { - unresolved = null; + if (unresolved != null) { + unresolved.remove(id); + if (unresolved.isEmpty()) { + unresolved = null; + } } } } @@ -238,55 +267,60 @@ implements Viewport, Resolveable, Cloneable { * @param isfirst isfirst or islast flag */ public void addMarkers(Map marks, boolean start, boolean isfirst) { - if (start) { - if (isfirst) { - if (markerFirstStart == null) { - markerFirstStart = new HashMap(); - } - if (markerFirstAny == null) { - markerFirstAny = new HashMap(); - } - // only put in new values, leave current - for (Iterator iter = marks.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - if (!markerFirstStart.containsKey(key)) { - markerFirstStart.put(key, marks.get(key)); + synchronized (sync) { + if (start) { + if (isfirst) { + if (markerFirstStart == null) { + markerFirstStart = new HashMap(); } - if (!markerFirstAny.containsKey(key)) { - markerFirstAny.put(key, marks.get(key)); + if (markerFirstAny == null) { + markerFirstAny = new HashMap(); + } + // only put in new values, leave current + for ( + Iterator iter = marks.keySet().iterator(); + iter.hasNext(); + ) { + Object key = iter.next(); + if (!markerFirstStart.containsKey(key)) { + markerFirstStart.put(key, marks.get(key)); + } + if (!markerFirstAny.containsKey(key)) { + markerFirstAny.put(key, marks.get(key)); + } + } + if (markerLastStart == null) { + markerLastStart = new HashMap(); + } + // replace all + markerLastStart.putAll(marks); + + } else { + if (markerFirstAny == null) { + markerFirstAny = new HashMap(); + } + // only put in new values, leave current + for (Iterator iter = marks.keySet().iterator(); iter.hasNext();) { + Object key = iter.next(); + if (!markerFirstAny.containsKey(key)) { + markerFirstAny.put(key, marks.get(key)); + } } } - if (markerLastStart == null) { - markerLastStart = new HashMap(); - } - // replace all - markerLastStart.putAll(marks); - } else { - if (markerFirstAny == null) { - markerFirstAny = new HashMap(); - } - // only put in new values, leave current - for (Iterator iter = marks.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - if (!markerFirstAny.containsKey(key)) { - markerFirstAny.put(key, marks.get(key)); + if (!isfirst) { + if (markerLastEnd == null) { + markerLastEnd = new HashMap(); } + // replace all + markerLastEnd.putAll(marks); } - } - } else { - if (!isfirst) { - if (markerLastEnd == null) { - markerLastEnd = new HashMap(); + if (markerLastAny == null) { + markerLastAny = new HashMap(); } // replace all - markerLastEnd.putAll(marks); - } - if (markerLastAny == null) { - markerLastAny = new HashMap(); + markerLastAny.putAll(marks); } - // replace all - markerLastAny.putAll(marks); } } @@ -300,39 +334,41 @@ implements Viewport, Resolveable, Cloneable { * @return Object the marker found or null */ public Object getMarker(String name, int pos) { - Object mark = null; - switch (pos) { - case RetrievePosition.FIRST_STARTING_WITHIN_PAGE: - if (markerFirstStart != null) { - mark = markerFirstStart.get(name); - } + synchronized (sync) { + Object mark = null; + switch (pos) { + case RetrievePosition.FIRST_STARTING_WITHIN_PAGE: + if (markerFirstStart != null) { + mark = markerFirstStart.get(name); + } if (mark == null && markerFirstAny != null) { mark = markerFirstAny.get(name); } - break; - case RetrievePosition.FIRST_INCLUDING_CARRYOVER: - if (markerFirstAny != null) { - mark = markerFirstAny.get(name); - } - break; - case RetrievePosition.LAST_STARTING_WITHIN_PAGE: - if (markerLastStart != null) { - mark = markerLastStart.get(name); - } + break; + case RetrievePosition.FIRST_INCLUDING_CARRYOVER: + if (markerFirstAny != null) { + mark = markerFirstAny.get(name); + } + break; + case RetrievePosition.LAST_STARTING_WITHIN_PAGE: + if (markerLastStart != null) { + mark = markerLastStart.get(name); + } if (mark == null && markerLastAny != null) { mark = markerLastAny.get(name); } - break; - case RetrievePosition.LAST_ENDING_WITHIN_PAGE: - if (markerLastEnd != null) { - mark = markerLastEnd.get(name); - } + break; + case RetrievePosition.LAST_ENDING_WITHIN_PAGE: + if (markerLastEnd != null) { + mark = markerLastEnd.get(name); + } if (mark == null && markerLastAny != null) { mark = markerLastAny.get(name); } - break; + break; + } + return mark; } - return mark; } /** @@ -340,13 +376,18 @@ implements Viewport, Resolveable, Cloneable { * 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 pageRefArea */ - public void savePage(ObjectOutputStream out) throws Exception { + public void savePage(ObjectOutputStream out) { // set the unresolved references so they are serialized - pageRefArea.setUnresolvedReferences(unresolved); - out.writeObject(pageRefArea); - pageRefArea = null; + synchronized (sync) { + ((PageRefArea)refArea).setUnresolvedReferences(unresolved); + try { + out.writeObject(refArea); + } catch (IOException e) { + throw new RuntimeException(e); + } + refArea = null; + } } /** @@ -358,15 +399,18 @@ implements Viewport, Resolveable, Cloneable { * @throws Exception if there is an error loading the pageRefArea */ public void loadPage(ObjectInputStream in) throws Exception { - pageRefArea = (PageRefArea) in.readObject(); - unresolved = pageRefArea.getUnresolvedReferences(); - if (unresolved != null && pendingResolved != null) { - for (Iterator iter = pendingResolved.keySet().iterator(); - iter.hasNext();) { - String id = (String) iter.next(); - resolve(id, (List)pendingResolved.get(id)); + synchronized (sync) { + PageRefArea pageRefArea = (PageRefArea) in.readObject(); + refArea = pageRefArea; + unresolved = pageRefArea.getUnresolvedReferences(); + if (unresolved != null && pendingResolved != null) { + for (Iterator iter = pendingResolved.keySet().iterator(); + iter.hasNext();) { + String id = (String) iter.next(); + resolve(id, (List)pendingResolved.get(id)); + } + pendingResolved = null; } - pendingResolved = null; } } @@ -376,15 +420,17 @@ implements Viewport, Resolveable, Cloneable { * @return a copy of this page and associated viewports */ public Object clone() { - PageViewport pv; - try { - pv = (PageViewport)(super.clone()); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); + synchronized (sync) { + PageViewport pv; + try { + pv = (PageViewport)(super.clone()); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + pageId = 0; // N.B. This invalidates the page id + pv.refArea = (PageRefArea)(refArea.clone()); + return pv; } - pageId = 0; // N.B. This invalidates the page id - pv.pageRefArea = (PageRefArea)pageRefArea.clone(); - return pv; } /** @@ -393,16 +439,20 @@ implements Viewport, Resolveable, Cloneable { * it holds id and marker information and is used as a key. */ public void clear() { - pageRefArea = null; + synchronized (sync) { + refArea = null; + } } /** * @see java.lang.Object#toString() */ public String toString() { - StringBuffer sb = new StringBuffer(64); - sb.append("PageViewport: page="); - sb.append(getPageNumber()); - return sb.toString(); + synchronized (sync) { + StringBuffer sb = new StringBuffer(64); + sb.append("PageViewport: page="); + sb.append(getPageNumber()); + return sb.toString(); + } } } diff --git a/src/java/org/apache/fop/area/ReferenceArea.java b/src/java/org/apache/fop/area/ReferenceArea.java index 7e4f3a4e5..6068dfa22 100644 --- a/src/java/org/apache/fop/area/ReferenceArea.java +++ b/src/java/org/apache/fop/area/ReferenceArea.java @@ -42,5 +42,7 @@ public interface ReferenceArea extends Cloneable { * @return the current transformer to position this reference area. */ public CoordTransformer getCoordTransformer(); + + public Object clone(); } diff --git a/src/java/org/apache/fop/area/RegionAfterRefArea.java b/src/java/org/apache/fop/area/RegionAfterRefArea.java index e80f725d0..ba0b9b20e 100644 --- a/src/java/org/apache/fop/area/RegionAfterRefArea.java +++ b/src/java/org/apache/fop/area/RegionAfterRefArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -33,8 +35,12 @@ public class RegionAfterRefArea * @param parent * @param sync */ - public RegionAfterRefArea(Node parent, Object sync) { - super(parent, sync); + public RegionAfterRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, 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 index 3b3cee0be..666ceee48 100644 --- a/src/java/org/apache/fop/area/RegionAfterVport.java +++ b/src/java/org/apache/fop/area/RegionAfterVport.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -34,9 +36,13 @@ public class RegionAfterVport extends RegionViewport { * @param sync * @param viewArea */ - public RegionAfterVport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync, viewArea); - // TODO Auto-generated constructor stub + public RegionAfterVport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionBeforeRefArea.java b/src/java/org/apache/fop/area/RegionBeforeRefArea.java index b37641945..3cb64d35e 100644 --- a/src/java/org/apache/fop/area/RegionBeforeRefArea.java +++ b/src/java/org/apache/fop/area/RegionBeforeRefArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -33,9 +35,12 @@ public class RegionBeforeRefArea * @param parent * @param sync */ - public RegionBeforeRefArea(Node parent, Object sync) { - super(parent, sync); - // TODO Auto-generated constructor stub + public RegionBeforeRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionBeforeVport.java b/src/java/org/apache/fop/area/RegionBeforeVport.java index 0a1db3ca4..49b9727b5 100644 --- a/src/java/org/apache/fop/area/RegionBeforeVport.java +++ b/src/java/org/apache/fop/area/RegionBeforeVport.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -34,8 +36,13 @@ public class RegionBeforeVport extends RegionViewport { * @param sync * @param viewArea */ - public RegionBeforeVport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync, viewArea); + public RegionBeforeVport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); // 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 index bab9fafbe..dd076e6c8 100644 --- a/src/java/org/apache/fop/area/RegionBodyRefArea.java +++ b/src/java/org/apache/fop/area/RegionBodyRefArea.java @@ -18,6 +18,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * The body region area. @@ -37,8 +39,28 @@ implements ReferenceArea { * Create a new body region area. * This sets the region reference area class to BODY. */ - public RegionBodyRefArea(Node parent, Object sync) { - super(parent, sync); + public RegionBodyRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); + } + + /** + * Create a new body region area. + * This sets the region reference area class to BODY. + */ + public RegionBodyRefArea( + int columnCount, + int columnGap, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); + this.columnCount = columnCount; + this.columnGap = columnGap; } /** @@ -47,7 +69,9 @@ implements ReferenceArea { * @param colCount the number of columns */ public void setColumnCount(int colCount) { - this.columnCount = colCount; + synchronized (sync) { + this.columnCount = colCount; + } } /** @@ -56,7 +80,9 @@ implements ReferenceArea { * @return the number of columns */ public int getColumnCount() { - return this.columnCount; + synchronized (sync) { + return this.columnCount; + } } /** @@ -66,9 +92,19 @@ implements ReferenceArea { * @param colGap the column gap in millipoints */ public void setColumnGap(int colGap) { - this.columnGap = colGap; + synchronized (sync) { + this.columnGap = colGap; + } } + /** + * @return the columnGap + */ + public int getColumnGap() { + synchronized (sync) { + return columnGap; + } + } /** * Set the before float area. * @@ -84,7 +120,9 @@ implements ReferenceArea { * @param mr the main reference area */ public void setMainReference(MainReferenceArea mr) { - mainReference = mr; + synchronized (sync) { + mainReference = mr; + } } /** @@ -111,7 +149,9 @@ implements ReferenceArea { * @return the main reference area */ public MainReferenceArea getMainReference() { - return mainReference; + synchronized (sync) { + return mainReference; + } } /** @@ -129,12 +169,14 @@ implements ReferenceArea { * @return a shallow copy of this object */ public Object clone() { - RegionBodyRefArea br = (RegionBodyRefArea)(super.clone()); - br.columnGap = columnGap; - br.columnCount = columnCount; - //br.beforeFloat = beforeFloat; - br.mainReference = mainReference; - //br.footnote = footnote; - return br; + synchronized (sync) { + RegionBodyRefArea br = (RegionBodyRefArea)(super.clone()); + 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 index 41c0dc4ad..e480e6bf1 100644 --- a/src/java/org/apache/fop/area/RegionBodyVport.java +++ b/src/java/org/apache/fop/area/RegionBodyVport.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -34,9 +36,13 @@ public class RegionBodyVport extends RegionViewport { * @param sync * @param viewArea */ - public RegionBodyVport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync, viewArea); - // TODO Auto-generated constructor stub + public RegionBodyVport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionEndRefArea.java b/src/java/org/apache/fop/area/RegionEndRefArea.java index 74db15a14..c1c9a9269 100644 --- a/src/java/org/apache/fop/area/RegionEndRefArea.java +++ b/src/java/org/apache/fop/area/RegionEndRefArea.java @@ -20,20 +20,27 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw * @version $Revision$ $Name$ */ -public class RegionEndRefArea extends RegionRefArea implements ReferenceArea { +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 + public RegionEndRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionEndVport.java b/src/java/org/apache/fop/area/RegionEndVport.java index dfc45c301..201f2db3b 100644 --- a/src/java/org/apache/fop/area/RegionEndVport.java +++ b/src/java/org/apache/fop/area/RegionEndVport.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -34,9 +36,13 @@ public class RegionEndVport extends RegionViewport { * @param sync * @param viewArea */ - public RegionEndVport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync, viewArea); - // TODO Auto-generated constructor stub + public RegionEndVport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionRefArea.java b/src/java/org/apache/fop/area/RegionRefArea.java index c0615dfab..9de304d32 100644 --- a/src/java/org/apache/fop/area/RegionRefArea.java +++ b/src/java/org/apache/fop/area/RegionRefArea.java @@ -21,6 +21,8 @@ import java.util.ArrayList; import java.util.List; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * This is an abstract reference area for the page regions - currently @@ -37,8 +39,12 @@ implements ReferenceArea { /** * Create a new region reference area. */ - public RegionRefArea(Node parent, Object sync) { - super(parent, sync); + public RegionRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); } /** diff --git a/src/java/org/apache/fop/area/RegionStartRefArea.java b/src/java/org/apache/fop/area/RegionStartRefArea.java index 059ae4109..26d06acc6 100644 --- a/src/java/org/apache/fop/area/RegionStartRefArea.java +++ b/src/java/org/apache/fop/area/RegionStartRefArea.java @@ -20,6 +20,8 @@ package org.apache.fop.area; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -33,8 +35,12 @@ public class RegionStartRefArea * @param parent * @param sync */ - public RegionStartRefArea(Node parent, Object sync) { - super(parent, sync); + public RegionStartRefArea( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, 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 index 8b0266322..1abe7f0fc 100644 --- a/src/java/org/apache/fop/area/RegionStartVport.java +++ b/src/java/org/apache/fop/area/RegionStartVport.java @@ -22,6 +22,8 @@ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * @author pbw @@ -34,9 +36,13 @@ public class RegionStartVport extends RegionViewport { * @param sync * @param viewArea */ - public RegionStartVport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync, viewArea); - // TODO Auto-generated constructor stub + public RegionStartVport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); } } diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index d7d9acf26..861d1c6a4 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -1,86 +1,58 @@ /* + * 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: RegionViewport.java,v 1.9 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 . For more information on the Apache - * Software Foundation, please see . */ package org.apache.fop.area; import java.awt.geom.Rectangle2D; import java.io.IOException; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * Region Viewport reference area. * This area is the viewport for a region and contains a region area. */ -public class RegionViewport extends Area implements Viewport, Cloneable { +public class RegionViewport +extends AbstractViewport +implements Viewport, Cloneable { // this rectangle is relative to the page - private RegionRefArea region; - private Rectangle2D viewArea; - private boolean clip = false; /** * Create a new region viewport. * * @param viewArea the view area of this viewport */ - public RegionViewport(Node parent, Object sync, Rectangle2D viewArea) { - super(parent, sync); - this.viewArea = viewArea; + public RegionViewport( + Rectangle2D viewArea, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(viewArea, pageSeq, generatedBy, parent, sync); } /** - * Set the region for this region viewport. + * Set the region-regerence-area for this region viewport. * - * @param reg the child region inside this viewport + * @param regRef the child region inside this viewport */ - public void setRegion(RegionRefArea reg) { - region = reg; + public void setRegion(RegionRefArea regRef) { + setReferenceArea(regRef); } /** @@ -89,25 +61,7 @@ public class RegionViewport extends Area implements Viewport, Cloneable { * @return the child region inside this viewport */ public RegionRefArea getRegion() { - return region; - } - - /** - * Set the clipping for this region viewport. - * - * @param c the clipping value - */ - public void setClip(boolean c) { - clip = c; - } - - /** - * Get the view area of this viewport. - * - * @return the viewport rectangle area - */ - public Rectangle2D getViewArea() { - return viewArea; + return (RegionRefArea)(getReferenceArea()); } /** @@ -203,7 +157,7 @@ public class RegionViewport extends Area implements Viewport, Cloneable { out.writeFloat((float) viewArea.getHeight()); out.writeBoolean(clip); //out.writeObject(props); - out.writeObject(region); + out.writeObject(refArea); } private void readObject(java.io.ObjectInputStream in) @@ -222,13 +176,18 @@ public class RegionViewport extends Area implements Viewport, Cloneable { * @return a new copy of this region viewport */ public Object 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; + synchronized (sync) { + RegionViewport rv; + try { + rv = (RegionViewport)(super.clone()); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + rv.viewArea = (Rectangle2D)(viewArea.clone()); + rv.refArea = (PageRefArea)(refArea.clone()); + return rv; + } } + } diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index cd487c1ba..b321d4ac1 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.java @@ -20,7 +20,10 @@ package org.apache.fop.area; import java.io.Serializable; import java.util.List; +import org.apache.fop.apps.FOPException; import org.apache.fop.datastructs.Node; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.FoPageSequence; /** * The span reference areas are children of the main-reference-area @@ -30,29 +33,69 @@ import org.apache.fop.datastructs.Node; public class Span extends AbstractReferenceArea implements ReferenceArea, Serializable { - // the list of flow reference areas in this span area + // the list of normal-flow-reference-areas in this span area private List flowAreas; - private Integer cols; + private NormalFlowRefArea currentFlowArea = null; + + /** + * Number of columns in this span. Derived from the span + * property on the fo:flow and the column-count prooperty on the + * region-body-reference-area. Defaults to 1. + */ + private int columnCount = 1; /** - * Create a span area with the number of columns for this span area. - * - * @param cols the number of columns in the span + * Create a span area with the number of columns for . + * Span-reference-areas are children of main-reference-areas. */ - public Span(Node parent, Object sync, Integer cols) { - super(parent, sync); - this.cols = cols; + public Span( + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); } /** - * Get the column count for this span area. - * - * @return the number of columns in this span area + * Create a span area with the number of columns for . + * Span-reference-areas are children of main-reference-areas. */ - public Integer getColumnCount() { - return cols; + public Span( + int columnCount, + FoPageSequence pageSeq, + FONode generatedBy, + Node parent, + Object sync) { + super(pageSeq, generatedBy, parent, sync); + this.columnCount = columnCount; } + /** + * @return the column count + */ + public int getColumnCount() { + synchronized (sync) { + return columnCount; + } + } + /** + * Set spanning condition, only if no main-reference-area exists + */ + public void setColumnCount(int columnCount) throws FOPException { + if (flowAreas == null) { + this.columnCount = columnCount; + } + else { + throw new FOPException("normal-flow-reference-areas exist"); + } + } + + public boolean activeFlowRefAreas() { + if (flowAreas == null && currentFlowArea == null) { + return false; + } + return true; + } } diff --git a/src/java/org/apache/fop/area/Viewport.java b/src/java/org/apache/fop/area/Viewport.java index df25a7048..e62ab3c4b 100644 --- a/src/java/org/apache/fop/area/Viewport.java +++ b/src/java/org/apache/fop/area/Viewport.java @@ -19,10 +19,42 @@ */ package org.apache.fop.area; +import java.awt.geom.Rectangle2D; + /** * @author pbw * @version $Revision$ $Name$ */ -public interface Viewport { +public interface Viewport extends Cloneable { + + /** + * @return the view area rectangle for this viewport + */ + public abstract Rectangle2D getViewArea(); + + /** + * @param viewArea to set + */ + public abstract void setViewArea(Rectangle2D viewArea); + + /** + * Sets the reference-area of this viewport/reference pair + * @param ref + */ + public abstract void setReferenceArea(ReferenceArea ref); + + /** + * @return the reference-area of this viewport/reference pair + */ + public abstract ReferenceArea getReferenceArea(); + /** + * @param clip does this viewport clip its reference area? + */ + public abstract void setClip(boolean clip); + + /** + * @return whether this viewport clips its reference area + */ + public abstract boolean getClip(); } diff --git a/src/java/org/apache/fop/area/ViewportI.java b/src/java/org/apache/fop/area/ViewportI.java new file mode 100644 index 000000000..b96ff4dfe --- /dev/null +++ b/src/java/org/apache/fop/area/ViewportI.java @@ -0,0 +1,48 @@ +/* + * + * 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 27/02/2004 + * $Id$ + */ +package org.apache.fop.area; +import java.awt.geom.Rectangle2D; +/** + * @author pbw + * @version $Revision$ $Name$ + */ +public interface ViewportI { + /** + * Set if this viewport should clip. + * @param c true if this viewport should clip + */ + public abstract void setClip(boolean c); + /** + * Get the view area rectangle of this viewport. + * @return the rectangle for this viewport + * TODO Thread safety + */ + public abstract Rectangle2D getViewArea(); + /** + * @param viewArea to set + */ + public abstract void setViewArea(Rectangle2D viewArea); + /** + * Get the page reference area with the contents. + * @return the page reference area + * TODO Thread safety + */ + public abstract PageRefArea getPageRefArea(); +} \ No newline at end of file -- 2.39.5