}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
Position positionAtIPDChange, LayoutManager restartAtLM) {
throw new UnsupportedOperationException("Not implemented");
}
* @param alignment the desired text alignment
* @return the list of KnuthElements
*/
- protected abstract List<KnuthElement> getNextKnuthElements(LayoutContext context,
+ protected abstract List<ListElement> getNextKnuthElements(LayoutContext context,
int alignment);
/**
* change occurs between two LMs
* @return the list of KnuthElements
*/
- protected List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment,
+ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alignment,
Position positionAtIPDChange, LayoutManager restartAtLM) {
throw new UnsupportedOperationException("TODO: implement acceptable fallback");
}
*/
protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn,
Position positionAtIPDChange, LayoutManager restartAtLM,
- List<KnuthElement> firstElements) {
+ List<ListElement> firstElements) {
updateLayoutContext(childLC);
//Make sure the span change signal is reset
childLC.signalSpanChange(Constants.NOT_SET);
BlockSequence blockList;
- List<KnuthElement> returnedList;
+ List<ListElement> returnedList;
if (firstElements == null) {
returnedList = getNextKnuthElements(childLC, alignment);
} else if (positionAtIPDChange == null) {
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment) {
log.warn("null implementation of getChangeKnuthElement() called!");
return null;
}
boolean prevIsBox = false;
int colNumber = 1;
for (int i = startIndex; i < par.size(); i++) {
- KnuthElement element = (KnuthElement) par.get(i);
+ KnuthElement element = par.get(i);
if (isLegalBreak(i, prevIsBox)) {
int breakLength = totalLength
+ (element instanceof KnuthPenalty ? element.getWidth() : 0);
}
private boolean isLegalBreak(int index, boolean prevIsBox) {
- KnuthElement element = (KnuthElement) par.get(index);
+ KnuthElement element = par.get(index);
return element instanceof KnuthPenalty && element.getPenalty() < KnuthPenalty.INFINITE
|| prevIsBox && element instanceof KnuthGlue;
}
}
private int getPenaltyWidth(int index) {
- KnuthElement element = (KnuthElement) par.get(index);
+ KnuthElement element = par.get(index);
return element instanceof KnuthPenalty ? element.getWidth() : 0;
}
* Creates a new list from an existing list.
* @param list The list from which to create the new list.
*/
- public BlockKnuthSequence(List list) {
+ public BlockKnuthSequence(List<KnuthSequence> list) {
super(list);
}
/**
* The paragraph of KnuthElements.
*/
- protected KnuthSequence par;
+ protected KnuthSequence<KnuthElement> par;
/**
* The width of a line (or height of a column in page-breaking mode).
* @return the element at index idx in the paragraph.
*/
protected KnuthElement getElement(int idx) {
- return (KnuthElement) par.get(idx);
+ return par.get(idx);
}
/**
*/
public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
- private List<KnuthElement> knuthElements;
+ private List<ListElement> knuthElements;
/**
* Creates a new FootnoteBodyLayoutManager.
}
@Override
- public List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment) {
+ public List getNextKnuthElements(LayoutContext context, int alignment) {
if (knuthElements == null) {
knuthElements = super.getNextKnuthElements(context, alignment);
}
* Represents a list of inline Knuth elements.
* If closed, it represents all elements of a Knuth paragraph.
*/
-public class InlineKnuthSequence extends KnuthSequence {
+public class InlineKnuthSequence<T extends ListElement> extends KnuthSequence {
private static final long serialVersionUID = 1354774188859946549L;
* Creates a new list from an existing list.
* @param list The list from which to create the new list.
*/
- public InlineKnuthSequence(List list) {
+ public InlineKnuthSequence(List<T> list) {
super(list);
}
/**
* Represents a list of {@link KnuthElement Knuth elements}.
*/
-public abstract class KnuthSequence extends ArrayList {
+public abstract class KnuthSequence<T extends ListElement> extends ArrayList<T> {
//TODO: do not extend ArrayList
* Creates a new list from an existing list.
* @param list The list from which to create the new list.
*/
- public KnuthSequence(List list) {
+ public KnuthSequence(List<T> list) {
super(list);
}
public ListElement getElement(int index) {
return (index >= size() || index < 0)
? null
- : (ListElement) get(index);
+ : get(index);
}
/**
} else {
int boxIndex = startIndex;
@SuppressWarnings("unchecked")
- Iterator<ListElement> iter = listIterator(startIndex);
+ Iterator<T> iter = listIterator(startIndex);
while (iter.hasNext() && !iter.next().isBox()) {
boxIndex++;
}
* @param alignment the desired text alignment
* @return the updated list of KnuthElements
*/
- List getChangedKnuthElements(List oldList, int alignment);
+ List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment);
/**
* Whether the FO handled by this layout manager has a descendant (including itself)
* a paragraph
* @return an updated list of elements, taking the new IPD into account
*/
- List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ List<ListElement> getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
Position positionAtIPDChange, LayoutManager restartAtLM);
boolean isFromFootnote();
return lc;
}
- protected List getNextKnuthElements(LayoutContext context, int alignment) {
+ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
LayoutManager curLM; // currently active LM
- List returnList = new LinkedList();
+ List<ListElement> returnList = new LinkedList<>();
while ((curLM = lm.getChildLM()) != null) {
LayoutContext childLC = LayoutContext.newInstance();
return containsFootnotes;
}
- public static List<List<KnuthElement>> getFootnoteKnuthElements(FlowLayoutManager flowLM, LayoutContext context,
+ public static List<List<KnuthElement>> getFootnoteKnuthElements(FlowLayoutManager flowLM, LayoutContext context,
List<FootnoteBodyLayoutManager> footnoteBodyLMs) {
- List<List<KnuthElement>> footnotes = new ArrayList<List<KnuthElement>>();
+ List<List<KnuthElement>> footnotes = new ArrayList<>();
LayoutContext footnoteContext = LayoutContext.copyOf(context);
footnoteContext.setStackLimitBP(context.getStackLimitBP());
footnoteContext.setRefIPD(flowLM.getPSLM()
}
/** {@inheritDoc} */
- protected List getNextKnuthElements(LayoutContext context, int alignment) {
- List contentList = null;
+ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
+ List<ListElement> contentList = null;
while (!childFLM.isFinished() && contentList == null) {
contentList = childFLM.getNextKnuthElements(context, alignment);
}
/** {@inheritDoc} */
- protected List getNextKnuthElements(LayoutContext context, int alignment,
+ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alignment,
Position positionAtIPDChange, LayoutManager restartAtLM) {
- List contentList = null;
+ List<ListElement> contentList = null;
do {
contentList = childFLM.getNextKnuthElements(context, alignment, positionAtIPDChange,
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
setFinished(true);
FONode foNode = (FONode) getFObj();
foNode = getTableLayoutManager().resolveRetrieveTableMarker((RetrieveTableMarker) foNode);
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
throw new IllegalStateException();
}
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.AbstractGraphics;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.TraitSetter;
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context,
- int alignment) {
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context,
+ int alignment) {
InlineViewport areaCurrent = getInlineArea();
setCurrentArea(areaCurrent);
return super.getNextKnuthElements(context, alignment);
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
Character fobj = (Character) this.fobj;
// TODO: may need some special handling for fo:character
addKnuthElementsForBorderPaddingEnd(seq);
- LinkedList<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
+ LinkedList<KnuthSequence> returnList = new LinkedList<>();
returnList.add(seq);
setFinished(true);
return returnList;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
stackSize = 0;
- List contentList = getNextKnuthElements(childLC, Constants.EN_START);
- for (Object aContentList : contentList) {
+ List<ListElement> contentList = getNextKnuthElements(childLC, Constants.EN_START);
+ for (ListElement aContentList : contentList) {
KnuthElement element = (KnuthElement) aContentList;
if (element instanceof KnuthInlineBox) {
KnuthInlineBox box = (KnuthInlineBox) element;
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment) {
return null;
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth) {
return getChangedKnuthElements(oldList, alignment);
}
import org.apache.fop.fo.flow.Float;
import org.apache.fop.layoutmgr.FloatContentLayoutManager;
import org.apache.fop.layoutmgr.InlineKnuthSequence;
-import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.SpaceResolver;
private FloatContentLayoutManager floatContentLM;
private KnuthInlineBox anchor;
- private List<KnuthElement> floatContentKnuthElements;
+ private List<ListElement> floatContentKnuthElements;
private Float floatContent;
private boolean floatContentAreaAdded;
return null;
}
- public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+ public LinkedList<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
if (!floatContentAreaAdded && !floatContent.isDisabled()) {
floatContentLM = new FloatContentLayoutManager(floatContent);
}
// the only knuth element is a zero width and height knuth box
- LinkedList knuthElements = new LinkedList();
+ LinkedList<KnuthSequence> knuthElements = new LinkedList<>();
KnuthSequence seq = new InlineKnuthSequence();
anchor = new KnuthInlineBox(0, null, null, true);
if (!floatContentAreaAdded) {
bodyLM.initialize();
// get Knuth elements representing the footnote citation
- List returnedList = new LinkedList();
+ List<KnuthSequence> returnedList = new LinkedList<>();
while (!citationLM.isFinished()) {
List partialList = citationLM.getNextKnuthElements(context, alignment);
if (partialList != null) {
return false;
}
- public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth) {
return oldList;
}
/** {@inheritDoc} */
@Override
- public List getNextKnuthElements(
+ public List<KnuthSequence> getNextKnuthElements(
LayoutContext context, int alignment) {
LayoutManager curLM;
import java.util.List;
import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
/**
* @param depth the depth at which the Positions for this LM in oldList are found
* @return the updated list of KnuthElements
**/
- List getChangedKnuthElements(List oldList, int alignment, int depth);
+ List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth);
}
import org.apache.fop.layoutmgr.BreakOpportunityHelper;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.traits.MinOptMax;
/**
* {@inheritDoc}
*/
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment) {
return getChangedKnuthElements(oldList, alignment, 0);
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth) {
// "unwrap" the Positions stored in the elements
ListIterator oldListIterator = oldList.listIterator();
KnuthElement oldElement;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LeafPosition;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
MinOptMax ipd;
curArea = get(context);
KnuthSequence seq = new InlineKnuthSequence();
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment) {
if (isFinished()) {
return null;
}
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LeafPosition;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
/** {@inheritDoc} */
@Override
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
curArea = get(context);
alignmentContext = makeAlignmentContext(context);
* {@inheritDoc}
* No subclass has a meaningful implementation of this method
*/
- public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth) {
return getChangedKnuthElements(oldList, alignment);
}
/** {@inheritDoc} */
@Override
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment) {
if (isFinished()) {
return null;
}
- LinkedList returnList = new LinkedList();
+ LinkedList<ListElement> returnList = new LinkedList<>();
addKnuthElementsForBorderPaddingStart(returnList);
/** {@inheritDoc} */
@Override
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
if (alignmentContext == null) {
FontInfo fi = fobj.getFOEventHandler().getFontInfo();
FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
*/
private List<ListElement> postProcessLineBreaks(int alignment, LayoutContext context) {
- List<ListElement> returnList = new LinkedList<ListElement>();
+ List<ListElement> returnList = new LinkedList<>();
int endIndex = -1;
for (int p = 0; p < knuthParagraphs.size(); p++) {
processUpdates(currPar, updateList);
}
- private void processUpdates(Paragraph par, List updateList) {
+ private void processUpdates(Paragraph par, List<ListElement> updateList) {
// create iterator for the updateList
ListIterator updateListIterator = updateList.listIterator();
Update currUpdate;
.applyChanges(par.subList(fromIndex + elementsAdded,
toIndex + elementsAdded))) {
// insert the new KnuthElements
- List newElements = currUpdate.inlineLM.getChangedKnuthElements(
+ List<ListElement> newElements = currUpdate.inlineLM.getChangedKnuthElements(
par.subList(fromIndex + elementsAdded,
toIndex + elementsAdded),
/*flaggedPenalty,*/ effectiveAlignment);
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LeafPosition;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(final List oldList, final int alignment) {
+ public List<ListElement> getChangedKnuthElements(final List<ListElement> oldList, final int alignment) {
if (isFinished()) {
return null;
}
import org.apache.fop.fo.flow.Wrapper;
import org.apache.fop.layoutmgr.BlockLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
getPSLM().addIDToPage(fobj.getId());
}
- public List getNextKnuthElements(LayoutContext context, int alignment) {
- List list = super.getNextKnuthElements(context, alignment);
+ public List<KnuthSequence> getNextKnuthElements(LayoutContext context, int alignment) {
+ List<KnuthSequence> list = super.getNextKnuthElements(context, alignment);
if (parentLayoutManager instanceof LineLayoutManager && !fobj.hasId() && fobj.hasChildren()) {
return Collections.emptyList();
}
}
}
- List returnedList = body.getChangedKnuthElements(oldList, alignment);
+ List<ListElement> returnedList = body.getChangedKnuthElements(oldList, alignment);
// "wrap" the Position inside each element
- List tempList = returnedList;
+ List<ListElement> tempList = returnedList;
KnuthElement tempElement;
- returnedList = new LinkedList();
+ returnedList = new LinkedList<>();
for (Object aTempList : tempList) {
tempElement = (KnuthElement) aTempList;
tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition()));
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.util.BreakUtil;
this.tableStepper = tableStepper;
}
- public LinkedList getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
- LinkedList returnList = new LinkedList();
+ public LinkedList<ListElement> getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
+ LinkedList<ListElement> returnList = new LinkedList<>();
createElementsForRowGroup(context, alignment, bodyType, returnList);
context.updateKeepWithPreviousPending(rowGroup[0].getKeepWithPrevious());
import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.LocalBreaker;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
/**
* {@inheritDoc}
*/
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
MinOptMax stackLimit = context.getStackLimitBP();
referenceIPD = context.getRefIPD();
List returnedList;
List contentList = new LinkedList();
- List returnList = new LinkedList();
+ List<ListElement> returnList = new LinkedList<>();
LayoutManager curLM; // currently active LM
LayoutManager prevLM = null; // previously active LM
KnuthBox headerAsFirst = null;
KnuthBox headerAsSecondToLast = null;
KnuthBox footerAsLast = null;
- LinkedList returnList = new LinkedList();
+ LinkedList<ListElement> returnList = new LinkedList<>();
int headerFootnoteBPD = 0;
if (headerIter != null && headerList == null) {
this.headerList = getKnuthElementsForRowIterator(
bodyIter, context, alignment, TableRowIterator.BODY));
if (headerAsFirst != null) {
int insertionPoint = 0;
- if (returnList.size() > 0 && ((ListElement)returnList.getFirst()).isForcedBreak()) {
+ if (returnList.size() > 0 && returnList.getFirst().isForcedBreak()) {
insertionPoint++;
}
returnList.add(insertionPoint, headerAsFirst);
} else if (headerAsSecondToLast != null) {
int insertionPoint = returnList.size();
- if (returnList.size() > 0 && ((ListElement)returnList.getLast()).isForcedBreak()) {
+ if (returnList.size() > 0 && returnList.getLast().isForcedBreak()) {
insertionPoint--;
}
returnList.add(insertionPoint, headerAsSecondToLast);
}
if (footerAsLast != null) {
int insertionPoint = returnList.size();
- if (returnList.size() > 0 && ((ListElement)returnList.getLast()).isForcedBreak()) {
+ if (returnList.size() > 0 && returnList.getLast().isForcedBreak()) {
insertionPoint--;
}
returnList.add(insertionPoint, footerAsLast);
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
- List returnList = new LinkedList();
+ List<ListElement> returnList = new LinkedList<>();
/*
* Compute the IPD and adjust it if necessary (overconstrained)