package org.apache.fop.area;
-import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.pagination.RegionBody;
/**
* This class is a container for the areas that may be generated by
* Constructor which can read traits directly
* from an fo:region-body formatting object.
*/
- public BodyRegion(int columnCount, int columnGap, RegionViewport parent) {
- super(Constants.FO_REGION_BODY, parent);
- this.columnCount = columnCount;
- this.columnGap = columnGap;
+ public BodyRegion(RegionBody rb, RegionViewport parent) {
+ super(rb, parent);
+ this.columnCount = rb.getColumnCount();
+ this.columnGap = rb.getColumnGap();
mainReference = new MainReference(this);
}
- /**
- * 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 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;
- }
-
/** @return the column-gap value */
public int getColumnGap() {
return this.columnGap;
* @return a shallow copy of this object
*/
public Object clone() {
- BodyRegion br = new BodyRegion(columnCount, columnGap, regionViewport);
+ BodyRegion br = new BodyRegion((RegionBody) regionFO, regionViewport);
br.setCTM(getCTM());
br.setIPD(getIPD());
br.beforeFloat = beforeFloat;
r.setLayoutDimension(PercentBase.BLOCK_IPD, rvp.getIPD());
r.setLayoutDimension(PercentBase.BLOCK_BPD, rvp.getBPD());
if (r.getNameId() == Constants.FO_REGION_BODY) {
- RegionBody rb = (RegionBody) r;
- rr = new BodyRegion(rb.getColumnCount(), rb.getColumnGap(),
- rvp);
+ rr = new BodyRegion((RegionBody) r, rvp);
} else {
- rr = new RegionReference(r.getNameId(), rvp);
+ rr = new RegionReference(r, rvp);
}
setRegionReferencePosition(rr, r, rvp.getViewArea());
rvp.setRegionReference(rr);
import java.util.ArrayList;
import java.util.List;
-import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.pagination.Region;
/**
* This is a region reference area for a page regions.
* so the page master can make copies from the original page and regions.
*/
public class RegionReference extends Area implements Cloneable {
- private int regionClass = Constants.FO_REGION_BEFORE;
+ protected Region regionFO;
private CTM ctm;
+
// the list of block areas from the static flow
private List blocks = new ArrayList();
*
* @param type the region class type
*/
- public RegionReference(int type, RegionViewport parent) {
- regionClass = type;
+ public RegionReference(Region regionFO, RegionViewport parent) {
+ this.regionFO = regionFO;
addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
regionViewport = parent;
}
* @return the region class
*/
public int getRegionClass() {
- return regionClass;
+ return regionFO.getNameId();
+ }
+
+ /**
+ * Return the Region FO which provides the
+ * traits for this region.
+ *
+ * @return the region formatting object
+ */
+ public Region getRegionFO() {
+ return regionFO;
}
/**
* @return a copy of this region reference area
*/
public Object clone() {
- RegionReference rr = new RegionReference(regionClass, regionViewport);
+ RegionReference rr = new RegionReference(regionFO, regionViewport);
rr.ctm = ctm;
rr.setIPD(getIPD());
return rr;
areaTreeHandler.getLayoutManagerMaker().makeLayoutManager(sc);
lm.setTargetRegion(rv.getRegionReference());
lm.setParent(this);
- lm.doLayout(reg);
+ lm.doLayout();
lm.reset(null);
}
return targetRegion;
}
- public void doLayout(SideRegion region) {
- MinOptMax range = new MinOptMax(targetRegion.getIPD());
- StaticContentBreaker breaker = new StaticContentBreaker(region, this, range);
+ public void doLayout() {
+ Region region = targetRegion.getRegionFO();
+ StaticContentBreaker breaker = new StaticContentBreaker(
+ this, targetRegion.getIPD(), region.getDisplayAlign());
breaker.doLayout(targetRegion.getBPD());
if (breaker.isOverflow()) {
if (region.getOverflow() == EN_ERROR_IF_OVERFLOW) {
}
}
- private class StaticContentBreaker extends AbstractBreaker {
-
- private Region region;
+ private class StaticContentBreaker extends AbstractBreaker {
private StaticContentLayoutManager lm;
- private MinOptMax ipd;
+ private int displayAlign;
+ private int ipd;
boolean overflow = false;
- public StaticContentBreaker(Region region, StaticContentLayoutManager lm, MinOptMax ipd) {
- this.region = region;
+ public StaticContentBreaker(StaticContentLayoutManager lm, int ipd,
+ int displayAlign) {
this.lm = lm;
this.ipd = ipd;
+ this.displayAlign = displayAlign;
}
public boolean isOverflow() {
protected LayoutContext createLayoutContext() {
LayoutContext lc = super.createLayoutContext();
- lc.setRefIPD(ipd.opt);
+ lc.setRefIPD(ipd);
return lc;
}
}
protected int getCurrentDisplayAlign() {
- return region.getDisplayAlign();
+ return displayAlign;
}
protected boolean hasMoreContent() {
protected LayoutManager getCurrentChildLM() {
return null; //TODO NYI
}
-
}
}