/**
* 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 {
* 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)
// 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;
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;
/**
* 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
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
}
}
-
-
private BreakPoss getBestBP(ArrayList vecPossEnd) {
if (vecPossEnd.size() == 1) {
return ((BreakCost) vecPossEnd.get(0)).getBP();
}
}
-
+ /**
+ * 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
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;
}
}
+ /**
+ * 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);
// 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()) {
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