--- /dev/null
+package org.apache.fop.layoutmgr;
+
+public class KnuthBox extends KnuthElement {
+ private int lead;
+ private int total;
+ private int middle;
+
+ public KnuthBox(int w, int l, int t, int m, Position pos, boolean bAux) {
+ super(KNUTH_BOX, w, pos, bAux);
+ lead = l;
+ total = t;
+ middle = m;
+ }
+
+ public int getLead() {
+ return lead;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public int getMiddle() {
+ return middle;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.layoutmgr;
+
+public abstract class KnuthElement {
+
+ public static final int KNUTH_BOX = 0;
+ public static final int KNUTH_GLUE = 1;
+ public static final int KNUTH_PENALTY = 2;
+
+ public static final int INFINITE = 1000;
+
+ private int type;
+ private int width;
+ private Position position;
+ private boolean bIsAuxiliary;
+
+ protected KnuthElement(int t, int w, Position pos, boolean bAux) {
+ type = t;
+ width = w;
+ position = pos;
+ bIsAuxiliary = bAux;
+ }
+
+ public boolean isBox() {
+ return (type == KNUTH_BOX);
+ }
+
+ public boolean isGlue() {
+ return (type == KNUTH_GLUE);
+ }
+
+ public boolean isPenalty() {
+ return (type == KNUTH_PENALTY);
+ }
+
+ public boolean isAuxiliary() {
+ return bIsAuxiliary;
+ }
+
+ public int getW() {
+ return width;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void setPosition(Position pos) {
+ position = pos;
+ }
+
+ public LayoutManager getLayoutManager() {
+ if (position != null) {
+ return position.getLM();
+ } else {
+ return null;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.layoutmgr;
+
+public class KnuthGlue extends KnuthElement {
+ private int stretchability;
+ private int shrinkability;
+
+ public KnuthGlue(int w, int y, int z, Position pos, boolean bAux) {
+ super(KNUTH_GLUE, w, pos, bAux);
+ stretchability = y;
+ shrinkability = z;
+ }
+
+ public int getY() {
+ return stretchability;
+ }
+
+ public int getZ() {
+ return shrinkability;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.layoutmgr;
+
+public class KnuthPenalty extends KnuthElement {
+ private int penalty;
+ private boolean bFlagged;
+
+ public KnuthPenalty(int w, int p, boolean f, Position pos, boolean bAux) {
+ super(KNUTH_PENALTY, w, pos, bAux);
+ penalty = p;
+ bFlagged = f;
+ }
+
+ public int getP() {
+ return penalty;
+ }
+
+ public boolean isFlagged() {
+ return bFlagged;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.layoutmgr;
+
+import java.util.List;
+
+public class KnuthPossPosIter extends PositionIterator {
+
+ private int iterCount;
+
+ /**
+ * Main constructor
+ * @param bpList List of break possibilities
+ * @param startPos starting position
+ * @param endPos ending position
+ */
+ public KnuthPossPosIter(List bpList, int startPos, int endPos) {
+ super(bpList.listIterator(startPos));
+ iterCount = endPos - startPos;
+ }
+
+ // Check position < endPos
+
+ /**
+ * @see org.apache.fop.layoutmgr.PositionIterator#checkNext()
+ */
+ protected boolean checkNext() {
+ if (iterCount > 0) {
+ return super.checkNext();
+ } else {
+ endIter();
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ --iterCount;
+ return super.next();
+ }
+
+ public KnuthElement getKE() {
+ return (KnuthElement) peekNext();
+ }
+
+ protected LayoutManager getLM(Object nextObj) {
+ return ((KnuthElement) nextObj).getLayoutManager();
+ }
+
+ protected Position getPos(Object nextObj) {
+ return ((KnuthElement) nextObj).getPosition();
+ }
+}