Chapter 6. Phase 2b: The addAreas call tree

Table of Contents

1. Overview
2. Detailed overviews
2.1. PageLM
2.2. FlowLM
2.3. BlockLM1
2.4. LineLM
2.5. TextLM
2.6. BlockLM2
2.7. LineLM
2.8. TextLM
2.9. AddLMVisitor$2

1. Overview

This section presents a verbose overview of the addAreas call tree. The following section presents the Layout Managers in more detail.

  • FlowLM receives from its parent LM an iterator with a single pagebreak. The first belongs to BlockLM1, the second belongs to BlockLM2. FlowLM itself holds 2 child BPs. The flow consists of two blocks. FlowLM sets up an iterator with its 2 BPs.
  • BlockLM1 receives from its parent LM the iterator with those 2 BPs, of which only the first one belongs to it. Its leaf position is 13. BlockLM itself holds 14 child BPs, which all belong to a single LineLM. The block consists of 14 lines. BlockLM sets up an iterator corresponding to the first BP, containing the child BPs 0–13.
  • LineLM receives from its parent LM an iterator with those 14 BPs. The leaf positions are 3, 6, 11, 12, 13, 16, 19, 21, 23, 24, 25, 26, 27, 28. LineLM itself holds 29 child BPs, which all belong to a single TextLM. LineLM maintains the position of the next BP in vecInlineBreaks, iStartPos. Initially it is set to 0. For each of its 14 BPs in the iterator, LineLM sets up an iterator with the child BPs in vecInlineBreaks from iStartPos up to an including the index iLeafPos to which the iterator BP points. Then it updates iStartPos to point to the next child BP. The iterators contain the child BP ranges: 0–3, 4–6, 7–11, 12, 13, 14–16, 17–19, 20–21, 22–23, 24, 25, 26, 27, 28.

    while (parentIter.hasNext()) {
        LineBreakPosition lbp = (LineBreakPosition) parentIter.next();
    	...
        PositionIterator inlinePosIter =
          new BreakPossPosIter(vecInlineBreaks, iStartPos,
                               lbp.getLeafPos() + 1);
        iStartPos = lbp.getLeafPos() + 1;
    	...
        while ((childLM = inlinePosIter.getNextChildLM()) != null) {
            childLM.addAreas(inlinePosIter, lc);
    		...
    	}
    	...
    }
    
  • TextLM receives from its parent LM an iterator with the BPs 0–3. The leaf positions are 0, 1, 2, 3. It has itself 47 items in vecAreaInfo. It iterates over the 4 corresponding AIs, records the start of the first one, counts the word spaces, and records the end of the last one. This line contains the characters from 0 up to 13 and has no word spaces.
  • TextLM receives from its parent LM an iterator with the BPs 4–6. The leaf positions are 5, 7, 8. It iterates over the three corresponding AIs. This line contains the characters from 13 up to 26 and has one word space. Note that the AIs 4 and 6 remain unused because they do not have a corresponding BP. These AIs represent areas that were too long, and over which the LM backed up.
  • TextLM receives from its parent LM an iterator with the BPs 7–11. The leaf positions are 11, 12, 13, 14, 15. It iterates over the five corresponding AIs. This line contains the characters from 26 up to 40 and has no word spaces. Note that the AIs 9 and 10 remain unused because they do not have a corresponding BP.
  • TextLM receives from its parent LM an iterator with the single BP 12. The leaf position is 16. This line contains the characters from 40 up to 42 and has no word spaces.
  • TextLM receives from its parent LM an iterator with the single BP 13. The leaf position is 18. This line contains the characters from 43 up to 60 and has no word spaces. Note that the AI 17 remains unused because it does not have a corresponding BP. Note also that character 42 has been dropped, because it would be a leading space.
  • etc. until all 14 line areas are done. LineLM returns.
  • The second BP in the iterator from FlowLM belongs to BlockLM2. The loop while (parentIter.hasNext()) ends because the LM of the next object is different from the current LM (BreakPossPosIter.checkNext()), and BlockLM1 returns. FlowLM's loop while ((childLM = breakPosIter.getNextChildLM()) != null) then passes the iterator to BlockLM2.
  • BlockLM2 receives from its parent LM the iterator with those 2 BPs. The cursor is at one, because BlockLM1 has used the first object. Only the second BP belongs to BlockLM2. Its leaf position is 0. BlockLM itself holds 1 child BP, belonging to a LineLM. The block consists of a single line. BlockLM sets up an iterator corresponding to the second BP, containing a single child BP.
  • LineLM receives from its parent LM an iterator with that BP. The leaf position is 1. LineLM itself holds 2 child BPs, one belonging to a TextLM, the other to AddLMVisitor$2. LineLM sets up an iterator corresponding to the BP, containing its two child BPs.
  • TextLM receives from its parent LM an iterator with the BPs 0 and 1, of which only the first belongs to it. Its leaf position is 0. It iterates over the corresponding AI. This text area contains the characters from 0 up to 1, i.e. " ", and has one word space. This converted to a space area.
  • AddLMVisitor$2 receives from its parent LM an iterator with the BPs 0 and 1. The cursor is at one, because TextLM has used the first object. Only the second BP belongs to AddLMVisitor$2. Its leaf position is 0.
  • This completes the line. LineLM returns.
  • BlockLM2 returns.
  • FlowLM returns.