Class LeafNodeLayoutManager

    • Field Detail

      • log

        protected static final org.apache.commons.logging.Log log
        logging instance
      • curArea

        protected InlineArea curArea
        The inline area that this leafnode will add.
      • commonBorderPaddingBackground

        protected CommonBorderPaddingBackground commonBorderPaddingBackground
        Any border, padding and background properties applying to this area
      • alignmentContext

        protected AlignmentContext alignmentContext
        The alignment context applying to this area
      • somethingChanged

        protected boolean somethingChanged
        Flag to indicate if something was changed as part of the getChangeKnuthElements sequence
    • Constructor Detail

      • LeafNodeLayoutManager

        public LeafNodeLayoutManager​(FObj node)
        Create a Leaf node layout manager.
        Parameters:
        node - the FObj to attach to this LM.
      • LeafNodeLayoutManager

        public LeafNodeLayoutManager()
        Create a Leaf node layout manager.
    • Method Detail

      • get

        public InlineArea get​(LayoutContext context)
        get the inline area.
        Parameters:
        context - the context used to create the area
        Returns:
        the current inline area for this layout manager
      • resolved

        public boolean resolved()
        Check if this inline area is resolved due to changes in page or ipd. Currently not used.
        Returns:
        true if the area is resolved when adding
      • setCurrentArea

        public void setCurrentArea​(InlineArea ia)
        Set the current inline area.
        Parameters:
        ia - the inline area to set for this layout manager
      • setCommonBorderPaddingBackground

        protected void setCommonBorderPaddingBackground​(CommonBorderPaddingBackground commonBorderPaddingBackground)
        Set the border and padding properties of the inline area.
        Parameters:
        commonBorderPaddingBackground - the alignment adjust property
      • getAllocationIPD

        protected MinOptMax getAllocationIPD​(int refIPD)
        Get the allocation ipd of the inline area. This method may be overridden to handle percentage values.
        Parameters:
        refIPD - the ipd of the parent reference area
        Returns:
        the min/opt/max ipd of the inline area
      • getEffectiveArea

        protected InlineArea getEffectiveArea​(LayoutContext layoutContext)
        Returns:
        the effective area to be added to the area tree. Normally, this is simply "curArea" but in the case of page-number(-citation) curArea is cloned, updated and returned.
      • offsetArea

        protected void offsetArea​(InlineArea area,
                                  LayoutContext context)
        Offset this area. Offset the inline area in the bpd direction when adding the inline area. This is used for vertical alignment. Subclasses should override this if necessary.
        Parameters:
        area - the inline area to be updated
        context - the layout context used for adding the area
      • makeAlignmentContext

        protected AlignmentContext makeAlignmentContext​(LayoutContext context)
        Creates a new alignment context or returns the current alignment context. This is used for vertical alignment. Subclasses should override this if necessary.
        Parameters:
        context - the layout context used
        Returns:
        the appropriate alignment context
      • widthAdjustArea

        protected void widthAdjustArea​(InlineArea area,
                                       LayoutContext context)
        Adjust the width of the area when adding. This uses the min/opt/max values to adjust the with of the inline area by a percentage.
        Parameters:
        area - the inline area to be updated
        context - the layout context for adding this area
      • 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
      • addALetterSpaceTo

        public java.util.List addALetterSpaceTo​(java.util.List oldList)
        Tell the LM to modify its data, adding a letter space to the word fragment represented by the given elements, and returning the corrected elements
        Specified by:
        addALetterSpaceTo in interface InlineLevelLayoutManager
        Parameters:
        oldList - the elements which must be given one more letter space
        Returns:
        the new elements replacing the old ones
      • addALetterSpaceTo

        public java.util.List addALetterSpaceTo​(java.util.List oldList,
                                                int depth)
        Tell the LM to modify its data, adding a letter space to the word fragment represented by the given elements, and returning the corrected elements Only TextLM has a meaningful implementation of this method
        Specified by:
        addALetterSpaceTo in interface InlineLevelLayoutManager
        Parameters:
        oldList - the elements which must be given one more letter space
        depth - the depth at which the Positions for this LM in oldList are found
        Returns:
        the new elements replacing the old ones
      • getWordChars

        public java.lang.String getWordChars​(Position pos)
        Get the word chars corresponding to the given position.
        Specified by:
        getWordChars in interface InlineLevelLayoutManager
        Parameters:
        pos - the position referring to the needed word chars.
        Returns:
        the word chars
      • hyphenate

        public void hyphenate​(Position pos,
                              HyphContext hyphContext)
        Tell the LM to hyphenate a word
        Specified by:
        hyphenate in interface InlineLevelLayoutManager
        Parameters:
        pos - the Position referring to the word
        hyphContext - the HyphContext storing hyphenation information
      • applyChanges

        public boolean applyChanges​(java.util.List oldList)
        Tell the LM to apply the changes due to hyphenation
        Specified by:
        applyChanges in interface InlineLevelLayoutManager
        Parameters:
        oldList - the list of the old elements the changes refer to
        Returns:
        true if the LM had to change its data, false otherwise
      • applyChanges

        public boolean applyChanges​(java.util.List oldList,
                                    int depth)
        Tell the LM to apply the changes due to hyphenation Only TextLM has a meaningful implementation of this method
        Specified by:
        applyChanges in interface InlineLevelLayoutManager
        Parameters:
        oldList - the list of the old elements the changes refer to
        depth - the depth at which the Positions for this LM in oldList are found
        Returns:
        true if the LM had to change its data, false otherwise
      • 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 No subclass has a meaningful implementation of this method
        Specified by:
        getChangedKnuthElements in interface InlineLevelLayoutManager
        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 AbstractLayoutManager
        Parameters:
        oldList - the elements to replace
        alignment - the desired text alignment
        Returns:
        the updated list of KnuthElements
      • addKnuthElementsForBorderPaddingStart

        protected void addKnuthElementsForBorderPaddingStart​(java.util.List returnList)
        Creates Knuth elements for start border padding and adds them to the return list.
        Parameters:
        returnList - return list to add the additional elements to
      • addKnuthElementsForBorderPaddingEnd

        protected void addKnuthElementsForBorderPaddingEnd​(java.util.List returnList)
        Creates Knuth elements for end border padding and adds them to the return list.
        Parameters:
        returnList - return list to add the additional elements to