Class LineLayoutManager

    • Field Detail

      • DEFAULT_SPACE_WIDTH

        public static final int DEFAULT_SPACE_WIDTH
        this constant is used to create elements when text-align is center: every TextLM descendant of LineLM must use the same value, otherwise the line breaking algorithm does not find the right break point
        See Also:
        Constant Field Values
    • Constructor Detail

      • LineLayoutManager

        public LineLayoutManager​(Block block,
                                 Length lh,
                                 int l,
                                 int f)
        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.
        Parameters:
        block - the block formatting object
        lh - the default line height
        l - the default lead, from top to baseline
        f - the default follow, from baseline to bottom
    • 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 AbstractLayoutManager
        Parameters:
        context - the LayoutContext used to store layout information
        alignment - the desired text alignment
        Returns:
        the list of KnuthElements
      • getNextKnuthElements

        public java.util.List getNextKnuthElements​(LayoutContext context,
                                                   int alignment,
                                                   LeafPosition restartPosition)
        Get a sequence of KnuthElements representing the content of the node assigned to the LM.
        Parameters:
        context - the LayoutContext used to store layout information
        alignment - the desired text alignment
        restartPosition - position at restart
        Returns:
        the list of KnuthElements
        See Also:
        LayoutManager.getNextKnuthElements(LayoutContext,int)
      • negotiateBPDAdjustment

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

        public java.util.List getChangedKnuthElements​(java.util.List oldList,
                                                      int alignment,
                                                      int depth)
        Get a sequence of KnuthElements representing the content of the node assigned to the LM, after changes have been applied
        Specified by:
        getChangedKnuthElements in interface InlineLevelLayoutManager
        Overrides:
        getChangedKnuthElements in class InlineStackingLayoutManager
        Parameters:
        oldList - the elements to replace
        alignment - the desired text alignment
        depth - the depth at which the Positions for this LM in oldList are found
        Returns:
        the updated list of KnuthElements
      • getChangedKnuthElements

        public java.util.List 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 InlineStackingLayoutManager
        Parameters:
        oldList - the elements to replace
        alignment - the desired text alignment
        Returns:
        the updated list of KnuthElements
      • hasLeadingFence

        protected boolean hasLeadingFence​(boolean isNotFirst)
        Line area is always considered to act as a fence.
        Overrides:
        hasLeadingFence in class InlineStackingLayoutManager
        Parameters:
        isNotFirst - ignored
        Returns:
        always true
      • hasTrailingFence

        protected boolean hasTrailingFence​(boolean isNotLast)
        Line area is always considered to act as a fence.
        Overrides:
        hasTrailingFence in class InlineStackingLayoutManager
        Parameters:
        isNotLast - ignored
        Returns:
        always true
      • addChildArea

        public void addChildArea​(Area childArea)
        Add a child area to the current area. If this causes the maximum dimension of the current area to be exceeded, the parent LM is called to add it.
        Specified by:
        addChildArea in interface LayoutManager
        Overrides:
        addChildArea in class AbstractLayoutManager
        Parameters:
        childArea - the child area to be added
      • 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
      • handleOverflow

        public boolean handleOverflow​(int milliPoints)
        Whether this LM can handle horizontal overflow error messages (only a BlockContainerLayoutManager can).
        Parameters:
        milliPoints - horizontal overflow
        Returns:
        true if handled by a BlockContainerLayoutManager