Class ListItemLayoutManager

All Implemented Interfaces:
PercentBaseContext, Constants, BlockLevelLayoutManager, BreakOpportunity, ConditionalElementListener, LayoutManager

public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManager implements BreakOpportunity
LayoutManager for a list-item FO. The list item contains a list item label and a list item body.
  • Constructor Details

    • ListItemLayoutManager

      public ListItemLayoutManager(ListItem node)
      Create a new list item layout manager.
      Parameters:
      node - list-item to create the layout manager for
  • Method Details

    • getCommonBorderPaddingBackground

      protected CommonBorderPaddingBackground getCommonBorderPaddingBackground()
      Description copied from class: SpacedBorderedPaddedBlockLayoutManager
      Returns the CommonBorderPaddingBackground instance from the FO handled by this layout manager.
      Specified by:
      getCommonBorderPaddingBackground in class SpacedBorderedPaddedBlockLayoutManager
    • getListItemFO

      protected ListItem getListItemFO()
      Convenience method.
      Returns:
      the ListBlock node
    • setLabel

      public void setLabel(ListItemLabel node)
      Create a LM for the fo:list-item-label object
      Parameters:
      node - the fo:list-item-label FO
    • setBody

      public void setBody(ListItemBody node)
      Create a LM for the fo:list-item-body object
      Parameters:
      node - the fo:list-item-body FO
    • initialize

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

      public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack, Position restartPosition, LayoutManager restartAtLM)
      Returns an updated list of Knuth elements corresponding to this layout manager, after a change of IPD has been detected.
      Specified by:
      getNextKnuthElements in interface LayoutManager
      Overrides:
      getNextKnuthElements in class BlockStackingLayoutManager
      Parameters:
      context - the layout context
      alignment - the alignment
      lmStack - the stack of LMs that are active at the IPD change
      restartPosition - the position corresponding to the element finishing the page before the IPD change
      restartAtLM - if not null, the layout manager from which to restart. That is, the IPD change occurs between two block elements and not inside a paragraph
      Returns:
      an updated list of elements, taking the new IPD into account
    • addFirstVisibleMarks

      protected void addFirstVisibleMarks(List<ListElement> elements, LayoutContext context, int alignment)
      Overridden to unconditionally add elements for space-before. Checks if this LM's first "visible marks" (= borders, padding, spaces) have already been processed, and if necessary, adds corresponding elements to the specified list, and updates the given layout context accordingly.
      Overrides:
      addFirstVisibleMarks in class BlockStackingLayoutManager
      Parameters:
      elements - the element list
      context - the layout context
      alignment - the vertical alignment
    • getChangedKnuthElements

      public List 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
    • 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
      Overrides:
      hasLineAreaDescendant in class AbstractLayoutManager
      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
      Overrides:
      getBaselineOffset in class SpacedBorderedPaddedBlockLayoutManager
      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:
    • addAreas

      public void addAreas(PositionIterator parentIter, LayoutContext layoutContext)
      Add the areas for the break points.
      Specified by:
      addAreas in interface LayoutManager
      Overrides:
      addAreas in class AbstractLayoutManager
      Parameters:
      parentIter - the position iterator
      layoutContext - the layout context for adding areas
    • 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
      Returns:
      the parent are for the child
    • addChildArea

      public void addChildArea(Area childArea)
      Add the child. Rows return the areas returned by the child elements. This simply adds the area to the parent layout manager.
      Specified by:
      addChildArea in interface LayoutManager
      Overrides:
      addChildArea in class BlockStackingLayoutManager
      Parameters:
      childArea - the child area
    • getKeepTogetherProperty

      public KeepProperty getKeepTogetherProperty()
      Returns the keep-together property specified on the FObj. Default implementation throws a IllegalStateException. Must be implemented by the subclass, if applicable.
      Specified by:
      getKeepTogetherProperty in interface BlockLevelLayoutManager
      Overrides:
      getKeepTogetherProperty in class BlockStackingLayoutManager
      Returns:
      the keep-together property
    • getKeepWithPreviousProperty

      public KeepProperty getKeepWithPreviousProperty()
      Returns the keep-with-previous property specified on the FObj. Default implementation throws a IllegalStateException. Must be implemented by the subclass, if applicable.
      Specified by:
      getKeepWithPreviousProperty in interface BlockLevelLayoutManager
      Overrides:
      getKeepWithPreviousProperty in class BlockStackingLayoutManager
      Returns:
      the keep-together property
    • getKeepWithNextProperty

      public KeepProperty getKeepWithNextProperty()
      Returns the keep-with-next property specified on the FObj. Default implementation throws a IllegalStateException. Must be implemented by the subclass, if applicable.
      Specified by:
      getKeepWithNextProperty in interface BlockLevelLayoutManager
      Overrides:
      getKeepWithNextProperty in class BlockStackingLayoutManager
      Returns:
      the keep-together property
    • 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 BlockStackingLayoutManager
    • getBreakBefore

      public int getBreakBefore()
      Description copied from class: BlockStackingLayoutManager
      Returns the highest priority break-before value on this layout manager or its relevant descendants.
      Specified by:
      getBreakBefore in interface BreakOpportunity
      Overrides:
      getBreakBefore in class BlockStackingLayoutManager
      Returns:
      the break-before value (Constants.EN_*)
      See Also:
    • 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