if (p == 0) {
lastBreakClass = effectiveList.getStartOn();
} else {
- KnuthElement lastBreakElement = effectiveList.getElement(endElementIndex);
+ ListElement lastBreakElement = effectiveList.getElement(endElementIndex);
if (lastBreakElement.isPenalty()) {
KnuthPenalty pen = (KnuthPenalty)lastBreakElement;
lastBreakClass = pen.getBreakClass();
*/
public static boolean mustKeepTogether(BlockKnuthSequence sequence1,
BlockKnuthSequence sequence2) {
- KnuthElement element1 = (KnuthElement) sequence1.get(sequence1.size() - 1);
+ ListElement element1 = (ListElement) sequence1.get(sequence1.size() - 1);
LayoutManager lm1 = (LayoutManager) element1.getLayoutManager();
- KnuthElement element2 = (KnuthElement) sequence2.get(0);
+ ListElement element2 = (ListElement) sequence2.get(0);
LayoutManager lm2 = (LayoutManager) element2.getLayoutManager();
if (!lm1.equals(lm2)) {
throw new IllegalStateException
* @return the requested context FO note or null, if no context node could be determined
*/
private FONode findContextFO(KnuthSequence seq, int position) {
- KnuthElement el = seq.getElement(position);
+ ListElement el = seq.getElement(position);
while (el.getLayoutManager() == null && position < seq.size() - 1) {
position++;
el = seq.getElement(position);
return false;
}
// does the first element of the first paragraph add to an existing word?
- KnuthElement lastOldElement, firstNewElement;
+ ListElement lastOldElement, firstNewElement;
lastOldElement = getLast();
firstNewElement = sequence.getElement(0);
- if (firstNewElement.isBox() && !firstNewElement.isAuxiliary()
- && lastOldElement.isBox() && lastOldElement.getW() != 0) {
+ if (firstNewElement.isBox() && !((KnuthElement) firstNewElement).isAuxiliary()
+ && lastOldElement.isBox() && ((KnuthElement) lastOldElement).getW() != 0) {
addALetterSpace();
}
addAll(sequence);
*/
public void wrapPositions(LayoutManager lm) {
ListIterator listIter = listIterator();
- KnuthElement element;
+ ListElement element;
while (listIter.hasNext()) {
- element = (KnuthElement) listIter.next();
+ element = (ListElement) listIter.next();
element.setPosition
(lm.notifyPos(new NonLeafPosition(lm, element.getPosition())));
}
/**
* @return the last element of this sequence.
*/
- public KnuthElement getLast() {
+ public ListElement getLast() {
int idx = size();
if (idx == 0) {
return null;
}
- return (KnuthElement) get(idx - 1);
+ return (ListElement) get(idx - 1);
}
/**
* Remove the last element of this sequence.
* @return the removed element.
*/
- public KnuthElement removeLast() {
+ public ListElement removeLast() {
int idx = size();
if (idx == 0) {
return null;
}
- return (KnuthElement) remove(idx - 1);
+ return (ListElement) remove(idx - 1);
}
/**
* @param index The index of the element to be returned
* @return the element at index index.
*/
- public KnuthElement getElement(int index) {
- return (KnuthElement) get(index);
+ public ListElement getElement(int index) {
+ return (ListElement) get(index);
}
/**
index ++) {
if (par.getElement(index).isGlue() && par.getElement(index - 1).isBox()
|| par.getElement(index).isPenalty()
- && par.getElement(index).getP() < KnuthElement.INFINITE) {
+ && ((KnuthElement) par.getElement(index)).getP() < KnuthElement.INFINITE) {
// break found
break;
}
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
+import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
// the sequence contains inline Knuth elements
if (sequence.isInlineSequence()) {
// look at the last element
- KnuthElement lastElement;
- lastElement = (KnuthElement) sequence.getLast();
+ ListElement lastElement;
+ lastElement = sequence.getLast();
if (lastElement == null) {
throw new NullPointerException(
"Sequence was empty! lastElement is null");
}
- bPrevWasKnuthBox = lastElement.isBox() && lastElement.getW() != 0;
+ bPrevWasKnuthBox = lastElement.isBox() && ((KnuthElement) lastElement).getW() != 0;
// if last paragraph is open, add the new elements to the paragraph
// else this is the last paragraph
int localLineHeight = 0, lineStretch = 0, lineShrink = 0;
ListIterator seqIterator = seq.listIterator();
while (seqIterator.hasNext()) {
- KnuthElement element = (KnuthElement) seqIterator.next();
+ ListElement elt = (ListElement) seqIterator.next();
+ if (!(elt instanceof KnuthElement)) {
+ continue;
+ }
+ KnuthElement element = (KnuthElement) elt;
localLineHeight += element.getW();
if (element.isGlue()) {
lineStretch += element.getY();
LinkedList targetList = new LinkedList();
ListIterator listIter = seq.listIterator();
while (listIter.hasNext()) {
- KnuthElement tempElement;
- tempElement = (KnuthElement) listIter.next();
+ ListElement tempElement;
+ tempElement = (ListElement) listIter.next();
if (tempElement.getLayoutManager() != this) {
tempElement.setPosition(notifyPos(new NonLeafPosition(this,
tempElement.getPosition())));