aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-10-28 13:07:22 +0000
committerKeiron Liddle <keiron@apache.org>2002-10-28 13:07:22 +0000
commitdda7be14923d345d088bdd8a3eaf6805a3e9ac83 (patch)
tree107937131c67f92784f9b95bdbd22f78405f9e02 /src/org/apache/fop
parentcc9e5958c53acc701c420b81d8b9f5c614f8409a (diff)
downloadxmlgraphics-fop-dda7be14923d345d088bdd8a3eaf6805a3e9ac83.tar.gz
xmlgraphics-fop-dda7be14923d345d088bdd8a3eaf6805a3e9ac83.zip
fixed a looping problem, added more comments
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r--src/org/apache/fop/layoutmgr/LineLayoutManager.java82
1 files changed, 73 insertions, 9 deletions
diff --git a/src/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
index 445ce66cb..ad79b552f 100644
--- a/src/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -36,6 +36,13 @@ import java.util.ArrayList;
/**
* LayoutManager for lines. It builds one or more lines containing
* inline areas generated by its sub layout managers.
+ * A break is found for each line which may contain one of more
+ * breaks from the child layout managers.
+ * Once a break is found then it is return for the parent layout
+ * manager to handle.
+ * When the areas are being added to the page this manager
+ * creates a line area to contain the inline areas added by the
+ * child layout managers.
*/
public class LineLayoutManager extends InlineStackingLayoutManager {
@@ -44,7 +51,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
* Each value holds the start and end indexes into a List of
* inline break positions.
*/
- // private static class LineBreakPosition implements Position {
private static class LineBreakPosition extends LeafPosition {
// int m_iPos;
double m_dAdjust; // Percentage to adjust (stretch or shrink)
@@ -82,8 +88,18 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
// inline start pos when adding areas
int iStartPos = 0;
+ /**
+ * Create a new Line Layout Manager.
+ * This is used by the block layout manager to create
+ * line managers for handling inline areas flowing into line areas.
+ *
+ * @param fobj the block the is creating the lines
+ * @param lms the list of layout managers that will add inline areas
+ * @param lh the default line height
+ * @param l the default lead, from top to baseline
+ * @param f the default follow, from baseline to bottom
+ */
public LineLayoutManager(FObj fobj, List lms, int lh, int l, int f) {
- //super(fobj, lms.listIterator(), lh, l, f);
super(fobj, lms.listIterator());
lineHeight = lh;
lead = l;
@@ -91,6 +107,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
init(); // Normally done when started by parent!
}
+ /**
+ * Initialize the properties for this layout manager.
+ * The properties are from the block area.
+ */
protected void initProperties(PropertyManager propMgr) {
MarginProps marginProps = propMgr.getMarginProps();
m_iIndents = marginProps.startIndent + marginProps.endIndent;
@@ -103,7 +123,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
/**
* Call child layout managers to generate content.
* This gets the next break which is a full line.
- *
+ *
+ * @param context the layout context for finding breaks
+ * @return the next break position
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
// Get a break from currently active child LM
@@ -126,6 +148,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
clearPrevIPD();
int iPrevLineEnd = m_vecInlineBreaks.size();
+ m_prevBP = null;
+
while ((curLM = getChildLM()) != null) {
// INITIALIZE LAYOUT CONTEXT FOR CALL TO CHILD LM
// First break for the child LM in each of its areas
@@ -302,8 +326,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
}
}
-
-
private BreakPoss getBestBP(ArrayList vecPossEnd) {
if (vecPossEnd.size() == 1) {
return ((BreakCost) vecPossEnd.get(0)).getBP();
@@ -389,7 +411,16 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
}
}
-
+ /**
+ * Make a line break for returning as the next break.
+ * This makes the line break and calculates the height and
+ * ipd adjustment factors.
+ *
+ * @param prevLineEnd previous line break index
+ * @param target the target ipd value
+ * @param textalign the text align in operation for this line
+ * @return the line break position
+ */
private BreakPoss makeLineBreak(int prevLineEnd, MinOptMax target,
int textalign) {
// make a new BP
@@ -509,6 +540,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
return curLineBP;
}
+ /**
+ * Reset the positions to the given position.
+ *
+ * @param resetPos the position to reset to
+ */
public void resetPosition(Position resetPos) {
if (resetPos == null) {
iStartPos = 0;
@@ -525,6 +561,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
}
}
+ /**
+ * Add the areas with the break points.
+ *
+ * @param parentIter the iterator of break positions
+ * @param context the context for adding areas
+ */
public void addAreas(PositionIterator parentIter,
LayoutContext context) {
addAreas(parentIter, 0.0);
@@ -536,8 +578,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
// Generate and add areas to parent area
// Set size etc
// dSpaceAdjust should reference extra space in the BPD
+ /**
+ * Add the areas with the associated space adjustment.
+ *
+ * @param parentIter the iterator of breaks positions
+ * @param dSpaceAdjust the space adjustment
+ */
public void addAreas(PositionIterator parentIter, double dSpaceAdjust) {
- LayoutManager childLM ;
+ LayoutManager childLM;
//int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
@@ -563,13 +611,29 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
lc.setLeadingSpace(lc.getTrailingSpace());
lc.setTrailingSpace(new SpaceSpecifier(false));
}
- addSpace(lineArea, lc.getTrailingSpace().resolve(true),
- lc.getSpaceAdjust());
+ // when can this be null?
+ if(lc.getTrailingSpace() != null) {
+ addSpace(lineArea, lc.getTrailingSpace().resolve(true),
+ lc.getSpaceAdjust());
+ }
parentLM.addChild(lineArea);
}
setCurrentArea(null); // ?? necessary
}
+ /**
+ * Add an unresolved area.
+ * If a child layout manager needs to add an unresolved area
+ * for page reference or linking then this intercepts it for
+ * line area handling.
+ * A line area may need to have the inline areas adjusted
+ * to properly fill the line area. This adds a resolver that
+ * resolves the inline area and can do the necessary
+ * adjustments to the line and inline areas.
+ *
+ * @param id the id reference of the resolveable
+ * @param res the resolveable object
+ */
public void addUnresolvedArea(String id, Resolveable res) {
// create a resolveable class that handles ipd
// adjustment for the current line