Class AbstractLayoutManager

    • Field Detail

      • log

        private static org.apache.commons.logging.Log log
        logging instance
      • parentLayoutManager

        protected LayoutManager parentLayoutManager
        Parent LayoutManager for this LayoutManager
      • childLMs

        protected java.util.List<LayoutManager> childLMs
        List of child LayoutManagers
      • fobjIter

        protected java.util.ListIterator fobjIter
        Iterator for child LayoutManagers
      • markers

        private java.util.Map<java.lang.String,​Marker> markers
        Marker map for markers related to this LayoutManager
      • isFinished

        private boolean isFinished
        True if this LayoutManager has handled all of its content.
      • curChildLM

        protected LayoutManager curChildLM
        child LM during getNextKnuthElement phase
      • childLMiter

        protected java.util.ListIterator<LayoutManager> childLMiter
        child LM iterator during getNextKnuthElement phase
      • lastGeneratedPosition

        private int lastGeneratedPosition
      • smallestPosNumberChecked

        private int smallestPosNumberChecked
      • preserveChildrenAtEndOfLayout

        private boolean preserveChildrenAtEndOfLayout
    • Constructor Detail

      • AbstractLayoutManager

        public AbstractLayoutManager()
        Abstract layout manager.
      • AbstractLayoutManager

        public AbstractLayoutManager​(FObj fo)
        Abstract layout manager.
        Parameters:
        fo - the formatting object for this layout manager
    • Method Detail

      • setParent

        public void setParent​(LayoutManager lm)
        Set the parent layout manager. The parent layout manager is required for adding areas.
        Specified by:
        setParent in interface LayoutManager
        Parameters:
        lm - the parent layout manager
      • initialize

        public void initialize()
        initialize the layout manager. Allows each layout manager to calculate often used values.
        Specified by:
        initialize in interface LayoutManager
      • getChildLM

        protected LayoutManager getChildLM()
        Return currently active child LayoutManager or null if all children have finished layout. Note: child must implement LayoutManager! If it doesn't, skip it and print a warning.
        Returns:
        the current child LayoutManager
      • setCurrentChildLM

        protected void setCurrentChildLM​(LayoutManager childLM)
        Set currently active child layout manager.
        Parameters:
        childLM - the child layout manager
      • hasNextChildLM

        protected boolean hasNextChildLM()
        Return indication if getChildLM will return another LM.
        Returns:
        true if another child LM is still available
      • isFinished

        public boolean isFinished()
        Tell whether this LayoutManager has handled all of its content.
        Specified by:
        isFinished in interface LayoutManager
        Returns:
        True if there are no more break possibilities, ie. the last one returned represents the end of the content.
      • setFinished

        public void setFinished​(boolean fin)
        Set the flag indicating the LayoutManager has handled all of its content.
        Specified by:
        setFinished in interface LayoutManager
        Parameters:
        fin - the flag value to be set
      • addAreas

        public void addAreas​(PositionIterator posIter,
                             LayoutContext context)
        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
        Parameters:
        posIter - the position iterator
        context - the context
      • 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
        Parameters:
        context - the LayoutContext used to store layout information
        alignment - the desired text alignment
        Returns:
        the 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
        Parameters:
        oldList - the elements to replace
        alignment - the desired text alignment
        Returns:
        the updated list of KnuthElements
      • 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
        Parameters:
        childArea - the child area for which the parent area is wanted
        Returns:
        the parent area for the given child
      • 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
        Parameters:
        childArea - the child area to be added
      • createChildLMs

        protected java.util.List<LayoutManager> createChildLMs​(int size)
        Create the LM instances for the children of the formatting object being handled by this LM.
        Parameters:
        size - the requested number of child LMs
        Returns:
        the list with the preloaded child LMs
      • getCurrentPV

        public PageViewport getCurrentPV()
        Returns:
        the current page viewport
      • createNextChildLMs

        public boolean createNextChildLMs​(int pos)
        Create more child LMs of the parent, up to child LM index pos
        Specified by:
        createNextChildLMs in interface LayoutManager
        Parameters:
        pos - index up to which child LMs are requested
        Returns:
        true if requested index does exist
      • addChildLM

        public void addChildLM​(LayoutManager lm)
        Add the LM in the argument to the list of child LMs; set this LM as the parent; initialize the LM.
        Specified by:
        addChildLM in interface LayoutManager
        Parameters:
        lm - the LM to be added
      • addChildLMs

        public void addChildLMs​(java.util.List newLMs)
        Add the LMs in the argument to the list of child LMs;
        Specified by:
        addChildLMs in interface LayoutManager
        Parameters:
        newLMs - the list of LMs to be added
      • notifyPos

        public Position notifyPos​(Position pos)
        Adds a Position to the Position participating in the first|last determination by assigning it a unique position index.
        Specified by:
        notifyPos in interface LayoutManager
        Parameters:
        pos - the Position
        Returns:
        the same Position but with a position index
      • verifyNonNullPosition

        private void verifyNonNullPosition​(Position pos)
      • isFirst

        public boolean isFirst​(Position pos)
        Indicates whether the given Position is the first area-generating Position of this LM.
        Parameters:
        pos - the Position (must be one with a position index)
        Returns:
        True if it is the first Position
      • isLast

        public boolean isLast​(Position pos)
        Indicates whether the given Position is the last area-generating Position of this LM.
        Parameters:
        pos - the Position (must be one with a position index)
        Returns:
        True if it is the last Position
      • hasLineAreaDescendant

        public boolean hasLineAreaDescendant()
        Description copied from interface: LayoutManager
        Whether the FO handled by this layout manager has a descendant (including itself) that will generate a line-area.
        Specified by:
        hasLineAreaDescendant in interface LayoutManager
        Returns:
        true if a descendant line-area will be generated, false otherwise
      • getBaselineOffset

        public int getBaselineOffset()
        Description copied from interface: LayoutManager
        Returns the position of the dominant-baseline of this FO's first descendant line-area.

        The behavior of this method is undefined if this FO has no descendant line-area, and an exception may be thrown. See LayoutManager.hasLineAreaDescendant()

        Specified by:
        getBaselineOffset in interface LayoutManager
        Returns:
        this FO's space-before plus the distance from the before-edge of its allocation-rectangle to the dominant-baseline of the first line-area descendant
        See Also:
        LayoutManager.hasLineAreaDescendant()
      • newNoLineAreaDescendantException

        protected java.lang.IllegalStateException newNoLineAreaDescendantException()
      • transferForeignAttributes

        protected void transferForeignAttributes​(AreaTreeObject targetArea)
        Transfers foreign attributes from the formatting object to the area.
        Parameters:
        targetArea - the area to set the attributes on
      • transferExtensionAttachments

        protected void transferExtensionAttachments​(AreaTreeObject targetArea)
        Transfers extension attachments from the formatting object to the area.
        Parameters:
        targetArea - the area to set the extensions on
      • transferExtensions

        protected void transferExtensions​(AreaTreeObject targetArea)
        Transfers extensions (foreign attributes and extension attachments) from the formatting object to the area.
        Parameters:
        targetArea - the area to set the extensions on
      • registerMarkers

        protected void registerMarkers​(boolean isStarting,
                                       boolean isFirst,
                                       boolean isLast)
        Registers the FO's markers on the current PageViewport, and if applicable on the parent TableLM.
        Parameters:
        isStarting - boolean indicating whether the markers qualify as 'starting'
        isFirst - boolean indicating whether the markers qualify as 'first'
        isLast - boolean indicating whether the markers qualify as 'last'
      • addId

        protected void addId()
        Registers the FO's id on the current PageViewport
      • notifyEndOfLayout

        protected void notifyEndOfLayout()
        Notifies the PageSequenceLayoutManager that layout for this LM has ended.
      • checkEndOfLayout

        protected void checkEndOfLayout​(Position pos)
        Checks to see if the incoming Position is the last one for this LM, and if so, calls notifyEndOfLayout() and cleans up.
        Parameters:
        pos - the Position to check
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • reset

        public void reset()
        Re-initializes this layout manager in order to re-generate its Knuth elements according to a new IPD value.
        Specified by:
        reset in interface LayoutManager
        Overrides:
        reset in class AbstractBaseLayoutManager
      • possiblyRegisterMarkersForTables

        protected void possiblyRegisterMarkersForTables​(java.util.Map<java.lang.String,​Marker> markers,
                                                        boolean isStarting,
                                                        boolean isFirst,
                                                        boolean isLast)
      • handlingFloat

        public boolean handlingFloat()