Class FlowLayoutManager

All Implemented Interfaces:
PercentBaseContext, Constants, BlockLevelLayoutManager, LayoutManager

public class FlowLayoutManager extends BlockStackingLayoutManager
LayoutManager for an fo:flow object. Its parent LM is the PageSequenceLayoutManager. This LM is responsible for getting columns of the appropriate size and filling them with block-level areas generated by its children. TODO Reintroduce emergency counter (generate error to avoid endless loop)
  • Constructor Details

    • FlowLayoutManager

      public FlowLayoutManager(PageSequenceLayoutManager pslm, Flow node)
      This is the top level layout manager. It is created by the PageSequence FO.
      Parameters:
      pslm - parent PageSequenceLayoutManager object
      node - Flow object
  • Method Details

    • getNextKnuthElements

      public List getNextKnuthElements(LayoutContext context, int alignment)
      Get a sequence of KnuthElements representing the content of the node assigned to the LM.
      Specified by:
      getNextKnuthElements in interface LayoutManager
      Overrides:
      getNextKnuthElements in class BlockStackingLayoutManager
      Parameters:
      context - the LayoutContext used to store layout information
      alignment - the desired text alignment
      Returns:
      the list of KnuthElements
    • makeChildLayoutContext

      protected LayoutContext makeChildLayoutContext(LayoutContext context)
      Overridden to take into account the current page-master's writing-mode Creates and initializes a LayoutContext to pass to the child LM
      Overrides:
      makeChildLayoutContext in class BlockStackingLayoutManager
      Parameters:
      context - the parent LayoutContext
      Returns:
      a new child layout context
    • getNextChildElements

      protected List<ListElement> getNextChildElements(LayoutManager childLM, LayoutContext context, LayoutContext childLC, int alignment, Stack<LayoutManager> lmStack, Position restartPosition, LayoutManager restartLM)
      Overridden to wrap the child positions before returning the list Gets the next set of child elements for the given childLM. The default implementation basically copies the pending marks to the child layout context, and subsequently calls the appropriate variant of childLM.getNextKnuthElements(), passing it all relevant parameters.
      Overrides:
      getNextChildElements in class BlockStackingLayoutManager
      Parameters:
      childLM - the current child LM
      context - the layout context
      childLC - the child layout context
      alignment - the vertical alignment
      lmStack - the stack of currently active LMs (if any)
      restartPosition - the position to restart from (if any)
      restartLM - the LM to restart from (if any)
      Returns:
      list of elements corresponding to the content generated by childLM
    • negotiateBPDAdjustment

      public int negotiateBPDAdjustment(int adj, KnuthElement lastElement)
      Negotiate BPD adjustment.
      Specified by:
      negotiateBPDAdjustment in interface BlockLevelLayoutManager
      Overrides:
      negotiateBPDAdjustment in class BlockStackingLayoutManager
      Parameters:
      adj - amount to adjust
      lastElement - the last knuth element
      Returns:
      the resulting adjusted BPD
    • discardSpace

      public void discardSpace(KnuthGlue spaceGlue)
      Discard space.
      Specified by:
      discardSpace in interface BlockLevelLayoutManager
      Overrides:
      discardSpace in class BlockStackingLayoutManager
      Parameters:
      spaceGlue - the space
    • getKeepTogether

      public Keep getKeepTogether()
      Returns the keep-together strength for this element.
      Specified by:
      getKeepTogether in interface BlockLevelLayoutManager
      Overrides:
      getKeepTogether in class BlockStackingLayoutManager
      Returns:
      the keep-together strength
    • getKeepWithNext

      public Keep getKeepWithNext()
      Returns the keep-with-next strength for this element.
      Specified by:
      getKeepWithNext in interface BlockLevelLayoutManager
      Overrides:
      getKeepWithNext in class BlockStackingLayoutManager
      Returns:
      the keep-with-next strength
    • getKeepWithPrevious

      public Keep getKeepWithPrevious()
      Returns the keep-with-previous strength for this element.
      Specified by:
      getKeepWithPrevious in interface BlockLevelLayoutManager
      Overrides:
      getKeepWithPrevious in class BlockStackingLayoutManager
      Returns:
      the keep-with-previous strength
    • getChangedKnuthElements

      public List<KnuthElement> getChangedKnuthElements(List oldList, int alignment)
      Get a sequence of KnuthElements representing the content of the node assigned to the LM, after changes have been applied In the context of line breaking, this method is called after hyphenation has been performed, in order to receive the sequence of elements representing the text together with all possible hyphenation points. For example, if the text "representation" originates a single box element when getNextKnuthElements() is called, it will be now split in syllables (rep-re-sen-ta-tion) each one originating a box and divided by additional elements allowing a line break. In the context of page breaking, this method is called only if the pages need to be "vertically justified" modifying (also) the quantity of lines created by the paragraphs, and after a first page breaking has been performed. According to the result of the first page breaking, each paragraph now knows how many lines it must create (among the existing layout possibilities) and has to create a sequence of elements representing this layout; in particular, each box, representing a line, will contain a LineBreakPositions that will be used in the addAreas() phase. LMs having children look at the old list of elements in order to know which ones they must get the new elements from, as break conditions of preserved linefeeds can divide children into smaller groups (page sequences or paragraphs). LMs having no children can simply return the old elements if they have nothing to change. Inline LMs need to know the text alignment because it affects the elements representing feasible breaks between syllables.
      Specified by:
      getChangedKnuthElements in interface LayoutManager
      Overrides:
      getChangedKnuthElements in class BlockStackingLayoutManager
      Parameters:
      oldList - the elements to replace
      alignment - the desired text alignment
      Returns:
      the updated list of KnuthElements
    • addAreas

      public void addAreas(PositionIterator parentIter, LayoutContext layoutContext)
      Tell the layout manager to add all the child areas implied by Position objects which will be returned by the Iterator.
      Specified by:
      addAreas in interface LayoutManager
      Overrides:
      addAreas in class AbstractLayoutManager
      Parameters:
      parentIter - the position iterator
      layoutContext - the context
    • addChildArea

      public void addChildArea(Area childArea)
      Add child area to a the correct container, depending on its area class. A Flow can fill at most one area container of any class at any one time. The actual work is done by BlockStackingLM.
      Specified by:
      addChildArea in interface LayoutManager
      Overrides:
      addChildArea in class BlockStackingLayoutManager
      Parameters:
      childArea - the area to add
    • getParentArea

      public Area getParentArea(Area childArea)
      Return an Area which can contain the passed childArea. The childArea may not yet have any content, but it has essential traits set. In general, if the LayoutManager already has an Area it simply returns it. Otherwise, it makes a new Area of the appropriate class. It gets a parent area for its area by calling its parent LM. Finally, based on the dimensions of the parent area, it initializes its own area. This includes setting the content IPD and the maximum BPD.
      Specified by:
      getParentArea in interface LayoutManager
      Overrides:
      getParentArea in class AbstractLayoutManager
      Parameters:
      childArea - the child area for which the parent area is wanted
      Returns:
      the parent area for the given child
    • getContentAreaIPD

      public int getContentAreaIPD()
      Returns the IPD of the content area
      Specified by:
      getContentAreaIPD in interface LayoutManager
      Overrides:
      getContentAreaIPD in class BlockStackingLayoutManager
      Returns:
      the IPD of the content area
    • getContentAreaBPD

      public int getContentAreaBPD()
      Returns the BPD of the content area
      Specified by:
      getContentAreaBPD in interface LayoutManager
      Overrides:
      getContentAreaBPD in class BlockStackingLayoutManager
      Returns:
      the BPD of the content area
    • isRestartable

      public boolean isRestartable()
      Returns true if this layout manager is able to re-generate its Knuth elements after an IPD change.
      Specified by:
      isRestartable in interface LayoutManager
      Overrides:
      isRestartable in class AbstractBaseLayoutManager
      Returns:
      true if this layout manager can be restarted after an IPD change
    • handleFloatOn

      public void handleFloatOn()
    • handleFloatOff

      public void handleFloatOff()
    • handlingFloat

      public boolean handlingFloat()
      Overrides:
      handlingFloat in class AbstractLayoutManager