]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
These new classes are part of the implementation of the new line
authorSimon Pepping <spepping@apache.org>
Sun, 5 Sep 2004 19:16:39 +0000 (19:16 +0000)
committerSimon Pepping <spepping@apache.org>
Sun, 5 Sep 2004 19:16:39 +0000 (19:16 +0000)
breaking algorithm, patch 29124, submitted by Luca Furini.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197908 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/KnuthBox.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/KnuthElement.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/KnuthGlue.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/KnuthPenalty.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java [new file with mode: 0644]

diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBox.java
new file mode 100644 (file)
index 0000000..d7b5689
--- /dev/null
@@ -0,0 +1,26 @@
+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
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthElement.java b/src/java/org/apache/fop/layoutmgr/KnuthElement.java
new file mode 100644 (file)
index 0000000..8f3f41e
--- /dev/null
@@ -0,0 +1,58 @@
+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
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
new file mode 100644 (file)
index 0000000..4448cdc
--- /dev/null
@@ -0,0 +1,20 @@
+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
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java
new file mode 100644 (file)
index 0000000..b39104a
--- /dev/null
@@ -0,0 +1,20 @@
+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
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
new file mode 100644 (file)
index 0000000..3d006a9
--- /dev/null
@@ -0,0 +1,53 @@
+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();
+    }
+}