Skip to content

Commit

Permalink
Add generics to layout
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsteiner1984 committed Jul 2, 2024
1 parent c245e37 commit 8b25c09
Show file tree
Hide file tree
Showing 37 changed files with 106 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
private Length orphanContentLimit;

/** collection of columns in this table */
private List columns = new ArrayList();
private List<FONode> columns = new ArrayList<FONode>();

private ColumnNumberManager columnNumberManager = new ColumnNumberManager();

Expand Down Expand Up @@ -405,7 +405,7 @@ public boolean isAutoLayout() {
*
* @return a list of {@link TableColumn} elements, may contain null elements
*/
public List getColumns() {
public List<FONode> getColumns() {
return columns;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public void reset() {
}

public void recreateChildrenLMs() {
childLMs = new ArrayList();
childLMs = new ArrayList<>();
isFinished = false;
if (fobj == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public void initialize() {
* @return the first PageViewport that contains the ID trait
*/
public PageViewport getFirstPVWithID(String idref) {
List list = idTracker.getPageViewportsContainingID(idref);
List<PageViewport> list = idTracker.getPageViewportsContainingID(idref);
if (list != null && list.size() > 0) {
return (PageViewport) list.get(0);
return list.get(0);
}
return null;
}
Expand All @@ -137,9 +137,9 @@ public PageViewport getFirstPVWithID(String idref) {
* @return the last PageViewport that contains the ID trait
*/
public PageViewport getLastPVWithID(String idref) {
List list = idTracker.getPageViewportsContainingID(idref);
List<PageViewport> list = idTracker.getPageViewportsContainingID(idref);
if (list != null && list.size() > 0) {
return (PageViewport) list.get(list.size() - 1);
return list.get(list.size() - 1);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alig
while ((curLM = getChildLM()) != null) {
LayoutContext childLC = makeChildLayoutContext(context);

List returnedList = null;
List<ListElement> returnedList = null;
if (!curLM.isFinished()) {
returnedList = curLM.getNextKnuthElements(childLC, alignment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ public int getLastIndex() {
* @param sourceList source list
* @param targetList target list receiving the wrapped position elements
*/
protected void wrapPositionElements(List sourceList, List targetList) {
protected void wrapPositionElements(List sourceList, List<ListElement> targetList) {
wrapPositionElements(sourceList, targetList, false);
}

Expand All @@ -1175,7 +1175,7 @@ protected void wrapPositionElements(List sourceList, List targetList) {
* @param targetList target list receiving the wrapped position elements
* @param force if true, every Position is wrapped regardless of its LM of origin
*/
protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
protected void wrapPositionElements(List sourceList, List<ListElement> targetList, boolean force) {

ListIterator listIter = sourceList.listIterator();
Object tempElement;
Expand All @@ -1201,7 +1201,7 @@ protected void wrapPositionElements(List sourceList, List targetList, boolean fo
* @param targetList target list receiving the wrapped position elements
* @param force if true, every Position is wrapped regardless of its LM of origin
*/
protected void wrapPositionElement(ListElement el, List targetList, boolean force) {
protected void wrapPositionElement(ListElement el, List<ListElement> targetList, boolean force) {
if (force || el.getLayoutManager() != this) {
el.setPosition(notifyPos(new NonLeafPosition(this, el.getPosition())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class BreakElement extends UnresolvedListElement {
private int penaltyWidth;
private int penaltyValue;
private int breakClass;
private List pendingBeforeMarks;
private List pendingAfterMarks;
private List<ListElement> pendingBeforeMarks;
private List<ListElement> pendingAfterMarks;

/**
* Main constructor
Expand Down Expand Up @@ -165,12 +165,12 @@ public void setBreakClass(int breakClass) {
}

/** @return the pending border and padding elements at the before edge */
public List getPendingBeforeMarks() {
public List<ListElement> getPendingBeforeMarks() {
return this.pendingBeforeMarks;
}

/** @return the pending border and padding elements at the after edge */
public List getPendingAfterMarks() {
public List<ListElement> getPendingAfterMarks() {
return this.pendingAfterMarks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public final class ElementListObserver {
private ElementListObserver() {
}

private static List activeObservers;
private static List<Observer> activeObservers;

/**
* Adds a new Observer to the list.
* @param observer the observer implementation
*/
public static void addObserver(Observer observer) {
if (!isObservationActive()) {
activeObservers = new java.util.ArrayList();
activeObservers = new java.util.ArrayList<>();
}
activeObservers.add(observer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class KnuthBlockBox extends KnuthBox {
private List<FootnoteBodyLayoutManager> footnoteList;
private List<FloatContentLayoutManager> floatContentLMs;
/** List of Knuth elements. This is a list of LinkedList elements. */
private List elementLists;
private List<List<KnuthElement>> elementLists;

/**
* Creates a new box.
Expand Down Expand Up @@ -104,7 +104,7 @@ public boolean hasAnchors() {
*/
public void addElementList(List list) {
if (elementLists == null) {
elementLists = new LinkedList();
elementLists = new LinkedList<>();
}
elementLists.add(list);
}
Expand All @@ -114,7 +114,7 @@ public void addElementList(List list) {
*
* @return a list of KnuthElement sequences corresponding to footnotes cited in this box
*/
public List getElementLists() {
public List<List<KnuthElement>> getElementLists() {
return elementLists;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public final class LayoutContext {
* A list of pending marks (border and padding) on the after edge when a page break occurs.
* May be null.
*/
private List pendingAfterMarks;
private List<ListElement> pendingAfterMarks;

/**
* A list of pending marks (border and padding) on the before edge when a page break occurs.
* May be null.
*/
private List pendingBeforeMarks;
private List<ListElement> pendingBeforeMarks;

/** Current hyphenation context. May be null. */
private HyphContext hyphContext;
Expand Down Expand Up @@ -177,10 +177,10 @@ private LayoutContext(int flags) {
/** @param source from which pending marks are copied */
public void copyPendingMarksFrom(LayoutContext source) {
if (source.pendingAfterMarks != null) {
this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks);
this.pendingAfterMarks = new java.util.ArrayList<>(source.pendingAfterMarks);
}
if (source.pendingBeforeMarks != null) {
this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks);
this.pendingBeforeMarks = new java.util.ArrayList<>(source.pendingBeforeMarks);
}
}

Expand Down Expand Up @@ -334,7 +334,7 @@ public SpaceSpecifier getTrailingSpace() {
*/
public void addPendingAfterMark(UnresolvedListElementWithLength element) {
if (this.pendingAfterMarks == null) {
this.pendingAfterMarks = new java.util.ArrayList();
this.pendingAfterMarks = new java.util.ArrayList<>();
}
this.pendingAfterMarks.add(element);
}
Expand All @@ -343,7 +343,7 @@ public void addPendingAfterMark(UnresolvedListElementWithLength element) {
* @return the pending border and padding elements at the after edge
* @see #addPendingAfterMark(UnresolvedListElementWithLength)
*/
public List getPendingAfterMarks() {
public List<ListElement> getPendingAfterMarks() {
if (this.pendingAfterMarks != null) {
return Collections.unmodifiableList(this.pendingAfterMarks);
} else {
Expand All @@ -367,7 +367,7 @@ public void clearPendingMarks() {
*/
public void addPendingBeforeMark(UnresolvedListElementWithLength element) {
if (this.pendingBeforeMarks == null) {
this.pendingBeforeMarks = new java.util.ArrayList();
this.pendingBeforeMarks = new java.util.ArrayList<>();
}
this.pendingBeforeMarks.add(element);
}
Expand All @@ -376,7 +376,7 @@ public void addPendingBeforeMark(UnresolvedListElementWithLength element) {
* @return the pending border and padding elements at the before edge
* @see #addPendingBeforeMark(UnresolvedListElementWithLength)
*/
public List getPendingBeforeMarks() {
public List<ListElement> getPendingBeforeMarks() {
if (this.pendingBeforeMarks != null) {
return Collections.unmodifiableList(this.pendingBeforeMarks);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface LayoutManagerMaker {
* @param node the FO node for which the LayoutManagers are made
* @param lms the list to which the LayoutManagers are added
*/
void makeLayoutManagers(FONode node, List lms);
void makeLayoutManagers(FONode node, List<LayoutManager> lms);

/**
* Make a specific LayoutManager for the node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void makeLayoutManagers(FONode node, List lms) {

/** {@inheritDoc} */
public LayoutManager makeLayoutManager(FONode node) {
List lms = new ArrayList();
List<LayoutManager> lms = new ArrayList<>();
makeLayoutManagers(node, lms);
if (lms.size() == 0) {
throw new IllegalStateException("LayoutManager for class "
Expand All @@ -197,7 +197,7 @@ public LayoutManager makeLayoutManager(FONode node) {
+ node.getClass()
+ " found, only one may be declared.");
}
return (LayoutManager) lms.get(0);
return lms.get(0);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected List<ListElement> getNextKnuthElements(LayoutContext context, int alig
childLC.setRefIPD(context.getRefIPD());
childLC.setWritingMode(context.getWritingMode());

List returnedList = null;
List<ListElement> returnedList = null;
// The following is a HACK! Ignore leading and trailing white space
boolean ignore = curLM instanceof TextLayoutManager;
if (!curLM.isFinished()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class PageBreaker extends AbstractBreaker {
private int floatHeight;
private int floatYOffset;

private List relayedFootnotesList;
private List relayedLengthList;
private List<ListElement> relayedFootnotesList;
private List<Integer> relayedLengthList;
private int relayedTotalFootnotesLength;
private int relayedInsertedFootnotesLength;
private boolean relayedFootnotesPending;
Expand Down Expand Up @@ -926,8 +926,8 @@ protected void addAreasForFloats(PageBreakingAlgorithm alg, int startPart, int p
pageBreakHandled = true;
}

public void holdFootnotes(List fl, List ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
int fei, MinOptMax fsl, int pfli, int pfei) {
public void holdFootnotes(List fl, List<Integer> ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
int fei, MinOptMax fsl, int pfli, int pfei) {
relayedFootnotesList = fl;
relayedLengthList = ll;
relayedTotalFootnotesLength = tfl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ protected void disableFloatHandling() {
handlingStartOfFloat = false;
}

public void loadFootnotes(List fl, List ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
public void loadFootnotes(List fl, List<Integer> ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
int fei, MinOptMax fsl, int pfli, int pfei) {
footnotesList = fl;
lengthList = ll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ public int getCurrentColumnWidth() {
return flowIPD;
}

public void holdFootnotes(List fl, List ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
int fei, MinOptMax fsl, int pfli, int pfei) {
public void holdFootnotes(List fl, List<Integer> ll, int tfl, int ifl, boolean fp, boolean nf, int fnfi, int fli,
int fei, MinOptMax fsl, int pfli, int pfei) {
if (fl != null && fl.size() > 0) {
pageBreaker.holdFootnotes(fl, ll, tfl, ifl, fp, nf, fnfi, fli, fei, fsl, pfli, pfei);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected LayoutManager getRestartAtLM(AbstractBreaker breaker, PageBreakingAlgo
.get(eventBroadcaster);
eventProducer.nonRestartableContentFlowingToNarrowerPage(this);
}
breaker.firstElementsForRestart = new LinkedList();
breaker.firstElementsForRestart = new LinkedList<>();
boolean boxFound = false;
Iterator iter = blockList.listIterator(positionIndex + 1);
Position position = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class SpaceResolver {
* @param isFirst Resolution at the beginning of a (full) element list
* @param isLast Resolution at the end of a (full) element list
*/
private SpaceResolver(List first, BreakElement breakPoss, List second,
private SpaceResolver(List first, BreakElement breakPoss, List<ListElement> second,
boolean isFirst, boolean isLast) {
this.isFirst = isFirst;
this.isLast = isLast;
Expand Down Expand Up @@ -603,9 +603,9 @@ public static void resolveElementList(List elems) {
boolean first = true;
boolean last = false;
boolean skipNextElement = false;
List unresolvedFirst = new java.util.ArrayList();
List unresolvedSecond = new java.util.ArrayList();
List currentGroup;
List<ListElement> unresolvedFirst = new java.util.ArrayList<>();
List<ListElement> unresolvedSecond = new java.util.ArrayList<>();
List<ListElement> currentGroup;
ListIterator iter = elems.listIterator();
while (iter.hasNext()) {
ListElement el = (ListElement)iter.next();
Expand Down Expand Up @@ -651,7 +651,7 @@ public static void resolveElementList(List elems) {
LOG.trace("Swap first and second parts in no-break condition,"
+ " second part is empty.");
//The first list is reversed, so swap if this shouldn't happen
List swapList = unresolvedSecond;
List<ListElement> swapList = unresolvedSecond;
unresolvedSecond = unresolvedFirst;
unresolvedFirst = swapList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class SpaceSpecifier implements Cloneable {

private boolean startsReferenceArea;
private boolean hasForcing;
private List spaceVals = new ArrayList();
private List<SpaceVal> spaceVals = new ArrayList<SpaceVal>();

/**
* Creates a new SpaceSpecifier.
Expand All @@ -53,7 +53,7 @@ public Object clone() {
ss.startsReferenceArea = startsReferenceArea;
ss.hasForcing = hasForcing;
// Clone the vector, but share the objects in it!
ss.spaceVals = new ArrayList();
ss.spaceVals = new ArrayList<SpaceVal>();
ss.spaceVals.addAll(spaceVals);
return ss;
} catch (CloneNotSupportedException cnse) {
Expand Down Expand Up @@ -118,7 +118,7 @@ public MinOptMax resolve(boolean endsReferenceArea) {
// Start from the end and count conditional specifiers
// Stop at first non-conditional
for (; lastIndex > 0; --lastIndex) {
SpaceVal spaceVal = (SpaceVal) spaceVals.get(lastIndex - 1);
SpaceVal spaceVal = spaceVals.get(lastIndex - 1);
if (!spaceVal.isConditional()) {
break;
}
Expand All @@ -127,7 +127,7 @@ public MinOptMax resolve(boolean endsReferenceArea) {
MinOptMax resolvedSpace = MinOptMax.ZERO;
int maxPrecedence = -1;
for (int index = 0; index < lastIndex; index++) {
SpaceVal spaceVal = (SpaceVal) spaceVals.get(index);
SpaceVal spaceVal = spaceVals.get(index);
MinOptMax space = spaceVal.getSpace();
if (hasForcing) {
resolvedSpace = resolvedSpace.plus(space);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public boolean createNextChildLMs(int pos) {
* {@inheritDoc}
*/
public List<LayoutManager> getChildLMs() {
List childLMs = new ArrayList(1);
List<LayoutManager> childLMs = new ArrayList<>(1);
childLMs.add(childLM);
return childLMs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int
depth += 1;

KnuthElement returnedElement;
LinkedList returnedList = new LinkedList();
LinkedList returnedList = new LinkedList<>();
LinkedList<ListElement> returnList = new LinkedList<>();
InlineLevelLayoutManager prevLM = null;
InlineLevelLayoutManager currLM;
Expand Down
Loading

0 comments on commit 8b25c09

Please sign in to comment.