aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorSimon Pepping <spepping@apache.org>2004-09-05 19:16:39 +0000
committerSimon Pepping <spepping@apache.org>2004-09-05 19:16:39 +0000
commita0831593665d120fcd6da96b0c33795e21531818 (patch)
tree305d694a88caf652e5f0beb23b30257305dec264 /src/java
parentd93dfd6e1ef331a1539cdae9f2a37f274aba89c4 (diff)
downloadxmlgraphics-fop-a0831593665d120fcd6da96b0c33795e21531818.tar.gz
xmlgraphics-fop-a0831593665d120fcd6da96b0c33795e21531818.zip
These new classes are part of the implementation of the new line
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
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthBox.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthElement.java58
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthGlue.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthPenalty.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java53
5 files changed, 177 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthBox.java b/src/java/org/apache/fop/layoutmgr/KnuthBox.java
new file mode 100644
index 000000000..d7b5689ed
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/KnuthBox.java
@@ -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
index 000000000..8f3f41e2b
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/KnuthElement.java
@@ -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
index 000000000..4448cdc08
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
@@ -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
index 000000000..b39104aa9
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java
@@ -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
index 000000000..3d006a928
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
@@ -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();
+ }
+}