klease 01/11/09 14:02:35
Modified: src/org/apache/fop/area Area.java BeforeFloat.java
Block.java BodyRegion.java Flow.java Footnote.java
MainReference.java Page.java RegionViewport.java
Span.java
Log:
Add some methods needed by the LayoutManager classes (subject to discussion)
Revision Changes Path
1.4 +85 -1 xml-fop/src/org/apache/fop/area/Area.java
Index: Area.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Area.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Area.java 2001/11/09 11:32:36 1.3
+++ Area.java 2001/11/09 22:02:34 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: Area.java,v 1.3 2001/11/09 11:32:36 keiron Exp $
+ * $Id: Area.java,v 1.4 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -8,6 +8,7 @@
package org.apache.fop.area;
import java.io.Serializable;
+import org.apache.fop.fo.FObj;
// If the area appears more than once in the output
// or if the area has external data it is cached
@@ -33,4 +34,87 @@
public static final int ORIENT_180 = 2;
public static final int ORIENT_270 = 3;
+ // area class values
+ public static final int CLASS_NORMAL = 0;
+ public static final int CLASS_FIXED = 1;
+ public static final int CLASS_ABSOLUTE = 2;
+ public static final int CLASS_BEFORE_FLOAT = 3;
+ public static final int CLASS_FOOTNOTE = 4;
+ public static final int CLASS_SIDE_FLOAT = 5;
+ // IMPORTANT: make sure this is the maximum + 1
+ public static final int CLASS_MAX = CLASS_SIDE_FLOAT+1;
+
+ private int areaClass=CLASS_NORMAL;
+ private FObj genFObj;
+
+ protected Area parent =null; // Doesn't need to be saved in serialization
+
+ public int getAreaClass() {
+ return areaClass;
+ }
+
+ public void setAreaClass(int areaClass) {
+ this.areaClass = areaClass;
+ }
+
+ /**
+ * Return a length range describing the minimum, optimum and maximum
+ * lengths available for content in the block-progression-direction.
+ * This is calculated from the theoretical maximum size of the area
+ * and its current content.
+ */
+ public MinOptMax getAvailBPD() {
+ return MinOptMax.subtract(getMaxBPD(), getContentBPD());
+ }
+
+ /**
+ * Return a length range describing the theoretical maximum size of an
+ * area in the block-progression-direction.
+ * For areas holding normal flowing or floating content in paged media,
+ * this depends on the size of the body. In general the answer is the
+ * gotten from the parent. At the body level, the calculation accounts
+ * for the sizes of the conditional areas.
+ */
+ public MinOptMax getMaxBPD() {
+ if (parent != null) {
+ return parent.getMaxBPD();
+ }
+ else return new MinOptMax();
+ }
+
+ /**
+ * Return a length range describing the minimum, optimum and maximum
+ * lengths of all area content in the block-progression-direction.
+ * This is based on the allocation rectangles of all content in
+ * the area.
+ */
+ public MinOptMax getContentBPD() {
+ return new MinOptMax();
+ }
+
+ /**
+ * Return a length range describing the minimum, optimum and maximum
+ * lengths of the area's allocation rectangle
+ * in the block-progression-direction.
+ * This is based on the allocation rectangles of all content in
+ * the area.
+ * The default implementation simply returns the same as the content BPD.
+ * If an Area has before or after border and padding, these contribute
+ * to the allocation BPD, depending on conditionality.
+ */
+ public MinOptMax getAllocationBPD() {
+ return getContentBPD();
+ }
+
+ public void setParent(Area parent) {
+ this.parent = parent;
+ }
+
+ public void setGeneratingFObj(FObj fobj) {
+ this.genFObj = fobj;
+ }
+
+ public FObj getGeneratingFObj() {
+ return this.genFObj;
+ }
}
1.3 +16 -2 xml-fop/src/org/apache/fop/area/BeforeFloat.java
Index: BeforeFloat.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/BeforeFloat.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BeforeFloat.java 2001/10/26 09:26:59 1.2
+++ BeforeFloat.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: BeforeFloat.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: BeforeFloat.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -10,7 +10,7 @@
import java.util.List;
import java.util.ArrayList;
-public class BeforeFloat extends Area {
+public class BeforeFloat extends BlockParent {
// this is an optional block area that will be rendered
// as the separator only if there are float areas
Block separator = null;
@@ -47,4 +47,18 @@
int h = 0;
return h;
}
+
+ public MinOptMax getMaxBPD() {
+ MinOptMax maxbpd = parent.getMaxBPD();
+ BodyRegion body = (BodyRegion)parent;
+ Area a = body.getMainReference();
+ if (a != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ if ((a=body.getFootnote()) != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ return maxbpd;
+ }
+
}
1.3 +2 -14 xml-fop/src/org/apache/fop/area/Block.java
Index: Block.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Block.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Block.java 2001/10/26 09:26:59 1.2
+++ Block.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: Block.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: Block.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -18,7 +18,7 @@
// or by relative to the parent for floats, tables and lists
// cacheable object
// has id information
-public class Block extends Area implements Serializable {
+public class Block extends BlockParent implements Serializable {
// normally stacked with other blocks
public static final int STACK = 0;
// placed relative to the parent area
@@ -26,11 +26,6 @@
// placed relative to the page or viewport
public static final int ABSOLUTE = 2;
- // this position is used for absolute position
- // or as an indent
- // this has the size in the block progression dimension
- Rectangle2D bounds = null;
-
int stacking = TB;
// list of marker fo objects that are associated with this area
@@ -38,7 +33,6 @@
// available markers, markers are discarded once page complete
private ArrayList markers = null;
- ArrayList children = null;
boolean blocks = false;
// a block with may contain the dominant styling info in
// terms of most lines or blocks with info
@@ -46,8 +40,6 @@
int positioning = STACK;
- // orientation if reference area
- int orientation = ORIENT_0;
public void addBlock(Block block) {
if (children == null) {
@@ -71,10 +63,6 @@
public boolean isChildrenBlocks() {
return blocks;
- }
-
- public List getChildAreas() {
- return children;
}
public int getPositioning() {
1.3 +25 -2 xml-fop/src/org/apache/fop/area/BodyRegion.java
Index: BodyRegion.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/BodyRegion.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BodyRegion.java 2001/10/26 09:26:59 1.2
+++ BodyRegion.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: BodyRegion.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: BodyRegion.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -7,25 +7,44 @@
package org.apache.fop.area;
-public class BodyRegion extends Region {
+import java.awt.geom.Rectangle2D;
+
+public class BodyRegion extends RegionReference {
BeforeFloat beforeFloat;
MainReference mainReference;
Footnote footnote;
+ /** Maximum block progression dimension. Note: min=opt=max */
+ private MinOptMax maxBPD;
+
+ /** Referenc inline progression dimension for the body. */
+ private int refIPD;
+
public BodyRegion() {
super(BODY);
}
+ public void setParent(Area area) {
+ super.setParent(area);
+ // Only if not scrolling or overflow !!!
+ Rectangle2D refRect = ((RegionViewport)area).getViewArea();
+ maxBPD = new MinOptMax((int)refRect.getHeight());
+ refIPD = (int)refRect.getWidth();
+ }
+
public void setBeforeFloat(BeforeFloat bf) {
beforeFloat = bf;
+ beforeFloat.setParent(this);
}
public void setMainReference(MainReference mr) {
mainReference = mr;
+ mainReference.setParent(this);
}
public void setFootnote(Footnote foot) {
footnote = foot;
+ footnote.setParent(this);
}
@@ -39,5 +58,9 @@
public Footnote getFootnote() {
return footnote;
+ }
+
+ public MinOptMax getMaxBPD() {
+ return maxBPD;
}
}
1.3 +11 -2 xml-fop/src/org/apache/fop/area/Flow.java
Index: Flow.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Flow.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Flow.java 2001/10/26 09:26:59 1.2
+++ Flow.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: Flow.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: Flow.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -12,7 +12,7 @@
// this is a normal flow reference area
// it containts a list of block areas from the flow
-public class Flow extends Area {
+public class Flow extends BlockParent {
// the list of blocks created from the flow
ArrayList blocks = new ArrayList();
int stacking = TB;
@@ -25,5 +25,14 @@
public List getBlocks() {
return blocks;
}
+
+ /**
+ * Maximum block progression dimension for a Flow is
+ * the same as that of its parent Span.
+ */
+ public MinOptMax getMaxBPD() {
+ return parent.getMaxBPD();
+ }
+
}
1.4 +15 -2 xml-fop/src/org/apache/fop/area/Footnote.java
Index: Footnote.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Footnote.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Footnote.java 2001/11/02 07:45:17 1.3
+++ Footnote.java 2001/11/09 22:02:34 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: Footnote.java,v 1.3 2001/11/02 07:45:17 keiron Exp $
+ * $Id: Footnote.java,v 1.4 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -12,7 +12,7 @@
import java.util.ArrayList;
// may combine with before float into a conditional area
-public class Footnote implements Serializable {
+public class Footnote extends BlockParent {
Block separator = null;
// footnote has an optional separator
@@ -41,5 +41,18 @@
public List getBlocks() {
return blocks;
+ }
+
+ public MinOptMax getMaxBPD() {
+ MinOptMax maxbpd = parent.getMaxBPD();
+ BodyRegion body = (BodyRegion)parent;
+ Area a = body.getMainReference();
+ if (a != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ if ((a=body.getBeforeFloat()) != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ return maxbpd;
}
}
1.3 +15 -2 xml-fop/src/org/apache/fop/area/MainReference.java
Index: MainReference.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/MainReference.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MainReference.java 2001/10/26 09:26:59 1.2
+++ MainReference.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: MainReference.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: MainReference.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -12,7 +12,7 @@
import java.util.List;
// the area that contains the flow via the span areas
-public class MainReference implements Serializable {
+public class MainReference extends Area implements Serializable {
List spanAreas = new ArrayList();
int columnGap;
int width;
@@ -31,5 +31,18 @@
public int getWidth() {
return width;
+ }
+
+ public MinOptMax getMaxBPD() {
+ MinOptMax maxbpd = parent.getMaxBPD();
+ BodyRegion body = (BodyRegion)parent;
+ Area a = body.getBeforeFloat();
+ if (a != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ if ((a=body.getFootnote()) != null) {
+ maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD());
+ }
+ return maxbpd;
}
}
1.3 +11 -11 xml-fop/src/org/apache/fop/area/Page.java
Index: Page.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Page.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Page.java 2001/10/26 09:26:59 1.2
+++ Page.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: Page.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: Page.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -18,29 +18,29 @@
RegionViewport regionAfter = null;
public void setRegion(int areaclass, RegionViewport port) {
- if (areaclass == Region.BEFORE) {
+ if (areaclass == RegionReference.BEFORE) {
regionBefore = port;
- } else if (areaclass == Region.START) {
+ } else if (areaclass == RegionReference.START) {
regionStart = port;
- } else if (areaclass == Region.BODY) {
+ } else if (areaclass == RegionReference.BODY) {
regionBody = port;
- } else if (areaclass == Region.END) {
+ } else if (areaclass == RegionReference.END) {
regionEnd = port;
- } else if (areaclass == Region.AFTER) {
+ } else if (areaclass == RegionReference.AFTER) {
regionAfter = port;
}
}
public RegionViewport getRegion(int areaclass) {
- if (areaclass == Region.BEFORE) {
+ if (areaclass == RegionReference.BEFORE) {
return regionBefore;
- } else if (areaclass == Region.START) {
+ } else if (areaclass == RegionReference.START) {
return regionStart;
- } else if (areaclass == Region.BODY) {
+ } else if (areaclass == RegionReference.BODY) {
return regionBody;
- } else if (areaclass == Region.END) {
+ } else if (areaclass == RegionReference.END) {
return regionEnd;
- } else if (areaclass == Region.AFTER) {
+ } else if (areaclass == RegionReference.AFTER) {
return regionAfter;
}
return null;
1.3 +23 -18 xml-fop/src/org/apache/fop/area/RegionViewport.java
Index: RegionViewport.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/RegionViewport.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RegionViewport.java 2001/10/26 09:26:59 1.2
+++ RegionViewport.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: RegionViewport.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: RegionViewport.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -11,45 +11,50 @@
import java.io.Serializable;
import java.io.IOException;
-public class RegionViewport implements Serializable {
+public class RegionViewport extends Area implements Serializable {
// this rectangle is relative to the page
- Rectangle2D regionArea;
+ RegionReference region;
+ Rectangle2D viewArea;
boolean clip = false;
- Region region;
- public RegionViewport(Rectangle2D area) {
- regionArea = area;
+ public RegionViewport(Rectangle2D viewArea) {
+ this.viewArea =viewArea;
}
- public void setRegion(Region reg) {
+ public void setRegion(RegionReference reg) {
region = reg;
+ region.setParent(this);
}
- public Rectangle2D getViewArea() {
- return regionArea;
+ public RegionReference getRegion() {
+ return region;
}
- public Region getRegion() {
- return region;
+ public void setClip(boolean c) {
+ clip = c;
+ }
+
+ public Rectangle2D getViewArea() {
+ return viewArea;
}
private void writeObject(java.io.ObjectOutputStream out)
throws IOException {
- out.writeFloat((float) regionArea.getX());
- out.writeFloat((float) regionArea.getY());
- out.writeFloat((float) regionArea.getWidth());
- out.writeFloat((float) regionArea.getHeight());
+ out.writeFloat((float) viewArea.getX());
+ out.writeFloat((float) viewArea.getY());
+ out.writeFloat((float) viewArea.getWidth());
+ out.writeFloat((float) viewArea.getHeight());
out.writeBoolean(clip);
out.writeObject(region);
}
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException {
- regionArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(),
- in.readFloat(), in.readFloat());
+ viewArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(),
+ in.readFloat(), in.readFloat());
clip = in.readBoolean();
- region = (Region) in.readObject();
+ setRegion( (RegionReference) in.readObject());
}
}
1.3 +19 -1 xml-fop/src/org/apache/fop/area/Span.java
Index: Span.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/Span.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Span.java 2001/10/26 09:26:59 1.2
+++ Span.java 2001/11/09 22:02:34 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: Span.java,v 1.2 2001/10/26 09:26:59 keiron Exp $
+ * $Id: Span.java,v 1.3 2001/11/09 22:02:34 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -8,6 +8,7 @@
package org.apache.fop.area;
import java.util.ArrayList;
+import java.util.Iterator;
// this is a reference area block area with 0 border and padding
public class Span extends Area {
@@ -34,4 +35,21 @@
public Flow getFlow(int count) {
return (Flow) flowAreas.get(count);
}
+
+ /**
+ * Maximum available BPD for a Span is the maxBPD for its containing
+ * MainReference less the content BPD of any previous spans
+ */
+ public MinOptMax getMaxBPD() {
+ MinOptMax maxbpd = parent.getMaxBPD();
+ MainReference mainref = (MainReference)parent;
+ Iterator spanIter = mainref.getSpans().iterator();
+ while (spanIter.hasNext()) {
+ Span s = (Span)spanIter.next();
+ if (s == this) break;
+ maxbpd = MinOptMax.subtract(maxbpd, s.getContentBPD());
+ }
+ return maxbpd;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]