import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
/**
}
/** {@inheritDoc} */
+ @Override
public void initialize() {
// create an InlineStackingLM handling the fo:inline child of fo:footnote
citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
}
/** {@inheritDoc} */
+ @Override
public List getNextKnuthElements(LayoutContext context,
int alignment) {
// for the moment, this LM is set as the citationLM's parent
return returnedList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
addAnchor(returnedList);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public void addAreas(PositionIterator posIter, LayoutContext context) {
// "Unwrap" the NonLeafPositions stored in posIter and put
// them in a new list, that will be given to the citationLM
- LinkedList positionList = new LinkedList();
- NonLeafPosition pos = null;
+ LinkedList<Position> positionList = new LinkedList<Position>();
+ Position pos;
while (posIter.hasNext()) {
- pos = (NonLeafPosition) posIter.next();
+ pos = posIter.next();
if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition());
}
// make the citationLM add its areas
LayoutContext childContext = new LayoutContext(context);
- StackingIter childPosIter = new StackingIter(positionList.listIterator());
+ PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
LayoutManager childLM;
while ((childLM = childPosIter.getNextChildLM()) != null) {
childLM.addAreas(childPosIter, childContext);
private boolean areaCreated = false;
private LayoutManager lastChildLM = null; // Set when return last breakposs;
- private Position auxiliaryPosition;
-
private Font font;
/** The alignment adjust property */
}
/** {@inheritDoc} */
+ @Override
public void initialize() {
InlineLevel fobj = (InlineLevel) this.fobj;
}
/** {@inheritDoc} */
+ @Override
protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
int borderAndPadding = 0;
if (borderProps != null) {
/** {@inheritDoc} */
+ @Override
protected boolean hasLeadingFence(boolean isNotFirst) {
return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
}
/** {@inheritDoc} */
+ @Override
protected boolean hasTrailingFence(boolean isNotLast) {
return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
}
/** {@inheritDoc} */
+ @Override
protected SpaceProperty getSpaceStart() {
return inlineProps != null ? inlineProps.spaceStart : null;
}
/** {@inheritDoc} */
+ @Override
protected SpaceProperty getSpaceEnd() {
return inlineProps != null ? inlineProps.spaceEnd : null;
}
}
/** {@inheritDoc} */
+ @Override
protected void setTraits(boolean isNotFirst, boolean isNotLast) {
if (borderProps != null) {
// Add border and padding to current area and set flags (FIRST, LAST ...)
}
/** {@inheritDoc} */
+ @Override
public List getNextKnuthElements // CSOK: MethodLength
(LayoutContext context, int alignment) {
LayoutManager curLM;
// the list returned by child LM
- List returnedList;
+ List<KnuthSequence> returnedList;
// the list which will be returned to the parent LM
- List returnList = new LinkedList();
+ List<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
KnuthSequence lastSequence = null;
if (fobj instanceof Title) {
sequence.wrapPositions(this);
}
int insertionStartIndex = 0;
- if (lastSequence != null && lastSequence.appendSequenceOrClose
- ((KnuthSequence) returnedList.get(0))) {
+ if (lastSequence != null
+ && lastSequence.appendSequenceOrClose(returnedList.get(0))) {
insertionStartIndex = 1;
}
// add border and padding to the first complete sequence of this LM
if (!borderAdded && !returnedList.isEmpty()) {
- addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
+ addKnuthElementsForBorderPaddingStart(returnedList.get(0));
borderAdded = true;
}
- for (Iterator iter = returnedList.listIterator(insertionStartIndex);
+ for (Iterator<KnuthSequence> iter = returnedList.listIterator(insertionStartIndex);
iter.hasNext();) {
returnList.add(iter.next());
}
context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
childLC.clearKeepsPending();
}
- lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
+ lastSequence = ListUtil.getLast(returnList);
lastChildLM = curLM;
}
* by this LayoutManager.
* @param context layout context.
*/
+ @Override
public void addAreas(PositionIterator parentIter,
LayoutContext context) {
// set in the layout context, it must be also set in the
// layout context given to lastLM, but must be cleared in the
// layout context given to the other LMs.
- List positionList = new LinkedList();
- NonLeafPosition pos;
+ List<Position> positionList = new LinkedList<Position>();
+ Position pos;
LayoutManager lastLM = null; // last child LM in this iterator
Position lastPos = null;
while (parentIter.hasNext()) {
- pos = (NonLeafPosition) parentIter.next();
+ pos = parentIter.next();
if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition());
lastLM = pos.getPosition().getLM();
lastPos = pos;
}
}
- /*if (pos != null) {
- lastLM = pos.getPosition().getLM();
- }*/
addMarkersToPage(
true,
}
setCurrentArea(parent);
- StackingIter childPosIter
- = new StackingIter(positionList.listIterator());
+ PositionIterator childPosIter
+ = new PositionIterator(positionList.listIterator());
LayoutManager prevLM = null;
LayoutManager childLM;
}
/** {@inheritDoc} */
+ @Override
public void addChildArea(Area childArea) {
Area parent = getCurrentArea();
if (getContext().resolveLeadingSpace()) {
}
/** {@inheritDoc} */
+ @Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = new LinkedList();
addKnuthElementsForBorderPaddingStart(returnedList);
*/
protected void addKnuthElementsForBorderPaddingStart(List returnList) {
//Border and Padding (start)
- /**
+ /*
* If the returnlist is a BlockKnuthSequence, the border and padding should be added
* to the first paragraph inside it, but it is too late to do that now.
* At least, avoid adding it to the bpd sequence.
*/
protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
//Border and Padding (after)
- /**
+ /*
* If the returnlist is a BlockKnuthSequence, the border and padding should be added
* to the last paragraph inside it, but it is too late to do that now.
* At least, avoid adding it to the bpd sequence.
}
}
- /** @return a cached auxiliary Position instance used for things like spaces. */
+ /** @return an auxiliary {@link Position} instance used for things like spaces. */
protected Position getAuxiliaryPosition() {
- //if (this.auxiliaryPosition == null) {
- //this.auxiliaryPosition = new NonLeafPosition(this, new LeafPosition(this, -1));
- this.auxiliaryPosition = new NonLeafPosition(this, null);
- //}
- return this.auxiliaryPosition;
+ return new NonLeafPosition(this, null);
}
-
}
package org.apache.fop.layoutmgr.inline;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import org.apache.fop.layoutmgr.AbstractLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.traits.MinOptMax;
/**
public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
implements InlineLevelLayoutManager {
-
- /**
- * A stacking iterator.
- */
- protected static class StackingIter extends PositionIterator {
-
- StackingIter(Iterator parentIter) {
- super(parentIter);
- }
-
- /**
- * @param nextObj the next object
- * @return layout manager of next object
- */
- protected LayoutManager getLM(Object nextObj) {
- return ((Position) nextObj).getLM();
- }
-
- /**
- * @param nextObj the next object
- * @return position of next object
- */
- protected Position getPos(Object nextObj) {
- return ((Position) nextObj);
- }
- }
-
/**
* Size of border and padding in BPD (ie, before and after).
*/
} else {
currLM = (InlineLevelLayoutManager) pos.getLM(depth);
}
+
// initialize prevLM
if (prevLM == null) {
prevLM = currLM;