Browse Source

Decommission AreaAdditionUtil.StackingIter + minor fixups

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1067360 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Andreas L. Delmelle 13 years ago
parent
commit
8addb610e1
1 changed files with 11 additions and 21 deletions
  1. 11
    21
      src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java

+ 11
- 21
src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java View File



package org.apache.fop.layoutmgr; package org.apache.fop.layoutmgr;


import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;


import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition; import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
private AreaAdditionUtil() { private AreaAdditionUtil() {
} }


private static class StackingIter extends PositionIterator {
StackingIter(Iterator parentIter) {
super(parentIter);
}

protected LayoutManager getLM(Object nextObj) {
return ((Position) nextObj).getLM();
}

protected Position getPos(Object nextObj) {
return ((Position) nextObj);
}
}

/** /**
* Creates the child areas for the given layout manager. * Creates the child areas for the given layout manager.
* @param bslm the BlockStackingLayoutManager instance for which "addAreas" is performed. * @param bslm the BlockStackingLayoutManager instance for which "addAreas" is performed.
*/ */
public static void addAreas(BlockStackingLayoutManager bslm, public static void addAreas(BlockStackingLayoutManager bslm,
PositionIterator parentIter, LayoutContext layoutContext) { PositionIterator parentIter, LayoutContext layoutContext) {
LayoutManager childLM = null;
LayoutManager childLM;
LayoutContext lc = new LayoutContext(0); LayoutContext lc = new LayoutContext(0);
LayoutManager firstLM = null; LayoutManager firstLM = null;
LayoutManager lastLM = null; LayoutManager lastLM = null;
Position firstPos = null; Position firstPos = null;
Position lastPos = null; Position lastPos = null;


if (bslm != null) {
bslm.addId();
}
// "unwrap" the NonLeafPositions stored in parentIter // "unwrap" the NonLeafPositions stored in parentIter
// and put them in a new list; // and put them in a new list;
LinkedList positionList = new LinkedList();
LinkedList<Position> positionList = new LinkedList<Position>();
Position pos; Position pos;
while (parentIter.hasNext()) { while (parentIter.hasNext()) {
pos = (Position)parentIter.next();
pos = parentIter.next();
if (pos == null) { if (pos == null) {
continue; continue;
} }
} }
if (pos instanceof NonLeafPosition) { if (pos instanceof NonLeafPosition) {
// pos was created by a child of this FlowLM // pos was created by a child of this FlowLM
positionList.add(((NonLeafPosition) pos).getPosition());
lastLM = ((NonLeafPosition) pos).getPosition().getLM();
positionList.add(pos.getPosition());
lastLM = (pos.getPosition().getLM());
if (firstLM == null) { if (firstLM == null) {
firstLM = lastLM; firstLM = lastLM;
} }
bslm.isLast(lastPos)); bslm.isLast(lastPos));
} }


StackingIter childPosIter = new StackingIter(positionList.listIterator());
PositionIterator childPosIter = new PositionIterator(positionList.listIterator());


while ((childLM = childPosIter.getNextChildLM()) != null) { while ((childLM = childPosIter.getNextChildLM()) != null) {
// TODO vh: the test above might be problematic in some cases. See comment in // TODO vh: the test above might be problematic in some cases. See comment in
false, false,
bslm.isFirst(firstPos), bslm.isFirst(firstPos),
bslm.isLast(lastPos)); bslm.isLast(lastPos));
bslm.checkEndOfLayout(lastPos);
} }





Loading…
Cancel
Save