*/
public class ElementListUtils {
- /**
- * Removes all legal breaks in an element list.
- * @param elements the element list
- */
- public static void removeLegalBreaks(LinkedList elements) {
- ListIterator i = elements.listIterator();
- while (i.hasNext()) {
- ListElement el = (ListElement)i.next();
- if (el.isPenalty()) {
- BreakElement breakPoss = (BreakElement)el;
- //Convert all penalties no break inhibitors
- if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) {
- breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
- }
- } else if (el.isGlue()) {
- i.previous();
- if (el.isBox()) {
- i.next();
- i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
- null, false));
- }
- }
- }
- }
-
/**
* Removes legal breaks in an element list. A constraint can be specified to limit the
* range in which the breaks are removed. Legal breaks occuring before at least
public static boolean removeLegalBreaks(LinkedList elements, MinOptMax constraint) {
return removeLegalBreaks(elements, constraint.opt);
}
-
+
/**
* Removes legal breaks in an element list. A constraint can be specified to limit the
* range in which the breaks are removed. Legal breaks occuring before at least
KnuthPenalty penalty = (KnuthPenalty)el;
//Convert all penalties to break inhibitors
if (penalty.getP() < KnuthPenalty.INFINITE) {
- iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
+ iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
}
} else if (el.isGlue()) {
el = (ListElement)iter.previous();
iter.next();
if (el.isBox()) {
- iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
+ iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
null, false));
}
iter.next();
KnuthPenalty penalty = (KnuthPenalty)el;
//Convert all penalties to break inhibitors
if (penalty.getP() < KnuthPenalty.INFINITE) {
- i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
+ i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
}
} else if (el.isGlue()) {
el = (ListElement)i.previous();
i.next();
if (el.isBox()) {
- i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
+ i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
null, false));
}
} else if (el.isUnresolvedElement()) {
}
return true;
}
-
+
/**
* Calculates the content length of the given element list. Warning: It doesn't take any
* stretch and shrink possibilities into account.
}
return len;
}
-
+
/**
* Calculates the content length of the given element list. Warning: It doesn't take any
* stretch and shrink possibilities into account.
public static int calcContentLength(List elems) {
return calcContentLength(elems, 0, elems.size() - 1);
}
-
+
/**
* Indicates whether the given element list ends with a forced break.
* @param elems the element list
ListElement last = (ListElement)elems.getLast();
return last.isForcedBreak();
}
-
+
/**
* Determines the position of the previous break before the start index on an
* element list.
}
return prevBreak;
}
-
+
}
if (headerIter != null && headerList == null) {
this.headerList = getKnuthElementsForRowIterator(
headerIter, context, alignment, TableRowIterator.HEADER);
- ElementListUtils.removeLegalBreaks(this.headerList);
this.headerNetHeight
= ElementListUtils.calcContentLength(this.headerList);
if (log.isDebugEnabled()) {
if (footerIter != null && footerList == null) {
this.footerList = getKnuthElementsForRowIterator(
footerIter, context, alignment, TableRowIterator.FOOTER);
- ElementListUtils.removeLegalBreaks(this.footerList);
this.footerNetHeight
= ElementListUtils.calcContentLength(this.footerList);
if (log.isDebugEnabled()) {