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 Detail

      • 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 Detail

      • getNextKnuthElements

        public java.util.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
      • getNextChildElements

        protected java.util.List<ListElement> getNextChildElements​(LayoutManager childLM,
                                                                   LayoutContext context,
                                                                   LayoutContext childLC,
                                                                   int alignment,
                                                                   java.util.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
      • getChangedKnuthElements

        public java.util.List<KnuthElement> getChangedKnuthElements​(java.util.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
      • 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()