Class ContentLayoutManager

java.lang.Object
org.apache.fop.layoutmgr.AbstractBaseLayoutManager
org.apache.fop.layoutmgr.inline.ContentLayoutManager
All Implemented Interfaces:
PercentBaseContext, InlineLevelLayoutManager, LayoutManager

public class ContentLayoutManager extends AbstractBaseLayoutManager implements InlineLevelLayoutManager
Content Layout Manager. For use with objects that contain inline areas such as leader use-content and title.
  • Constructor Details

    • ContentLayoutManager

      public ContentLayoutManager(Area area, LayoutManager parentLM)
      Constructs a new ContentLayoutManager
      Parameters:
      area - The parent area
      parentLM - the parent layout manager
    • ContentLayoutManager

      public ContentLayoutManager(PageSequenceLayoutManager pslm, Title foTitle)
      Constructor using a fo:title formatting object and its PageSequenceLayoutManager parent. throws IllegalStateException if the foTitle has no children. TODO: convert IllegalStateException to FOPException; also in makeLayoutManager and makeContentLayoutManager and callers.
      Parameters:
      pslm - the PageSequenceLayoutManager parent of this LM
      foTitle - the Title FO for which this LM is made
  • Method Details

    • initialize

      public void initialize()
      initialize the layout manager. Allows each layout manager to calculate often used values.
      Specified by:
      initialize in interface LayoutManager
    • 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
    • getStackingSize

      public int getStackingSize()
      Returns:
      stack size
    • getParentArea

      public Area getParentArea(Area childArea)
      Get the parent area for an area. This should get the parent depending on the class of the area passed in.
      Specified by:
      getParentArea in interface LayoutManager
      Parameters:
      childArea - the child area to get the parent for
      Returns:
      the parent Area
    • addChildArea

      public void addChildArea(Area childArea)
      Add the area as a child of the current area. This is called by child layout managers to add their areas as children of the current area.
      Specified by:
      addChildArea in interface LayoutManager
      Parameters:
      childArea - the child area to add
    • 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
    • getParent

      public LayoutManager getParent()
      Get the parent layout manager.
      Specified by:
      getParent in interface LayoutManager
      Returns:
      the parent layout manager.
    • isFinished

      public boolean isFinished()
      Return a value indicating whether this LayoutManager has laid out all its content (or generated BreakPossibilities for all content.)
      Specified by:
      isFinished in interface LayoutManager
      Returns:
      true if this layout manager is finished
    • setFinished

      public void setFinished(boolean isFinished)
      Set a flag indicating whether the LayoutManager has laid out all its content. This is generally called by the LM itself, but can be called by a parentLM when backtracking.
      Specified by:
      setFinished in interface LayoutManager
      Parameters:
      isFinished - the value to set the finished flag to
    • 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
    • getChildLMs

      public List getChildLMs()
      Specified by:
      getChildLMs in interface LayoutManager
      Returns:
      the list of child LMs
    • 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(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
    • getNextKnuthElements

      public 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
    • addALetterSpaceTo

      public List addALetterSpaceTo(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 List addALetterSpaceTo(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
      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 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 hc)
      Tell the LM to hyphenate a word
      Specified by:
      hyphenate in interface InlineLevelLayoutManager
      Parameters:
      pos - the Position referring to the word
      hc - the HyphContext storing hyphenation information
    • applyChanges

      public boolean applyChanges(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(List oldList, int depth)
      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
      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 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
      Parameters:
      oldList - the elements to replace
      alignment - the desired text alignment
      Returns:
      the updated list of KnuthElements
    • getChangedKnuthElements

      public List getChangedKnuthElements(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
      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
    • getPSLM

      public PageSequenceLayoutManager getPSLM()
      Get the active PageSequenceLayoutManager instance for this layout process.
      Specified by:
      getPSLM in interface LayoutManager
      Returns:
      the PageSequenceLayoutManager
    • 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:
    • getContentAreaIPD

      public int getContentAreaIPD()
      Returns the IPD of the content area
      Specified by:
      getContentAreaIPD in interface LayoutManager
      Overrides:
      getContentAreaIPD in class AbstractBaseLayoutManager
      Returns:
      the IPD of the content area
    • getContentAreaBPD

      public int getContentAreaBPD()
      Returns the BPD of the content area
      Specified by:
      getContentAreaBPD in interface LayoutManager
      Overrides:
      getContentAreaBPD in class AbstractBaseLayoutManager
      Returns:
      the BPD of the content area
    • getGeneratesReferenceArea

      public boolean getGeneratesReferenceArea()
      Returns an indication if the layout manager generates a reference area.
      Specified by:
      getGeneratesReferenceArea in interface LayoutManager
      Overrides:
      getGeneratesReferenceArea in class AbstractBaseLayoutManager
      Returns:
      True if the layout manager generates a reference area
    • getGeneratesBlockArea

      public boolean getGeneratesBlockArea()
      Returns an indication if the layout manager generates a block area.
      Specified by:
      getGeneratesBlockArea in interface LayoutManager
      Overrides:
      getGeneratesBlockArea in class AbstractBaseLayoutManager
      Returns:
      True if the layout manager generates a block area
    • getGeneratesLineArea

      public boolean getGeneratesLineArea()
      Returns an indication if the layout manager generates a line area.
      Specified by:
      getGeneratesLineArea in interface LayoutManager
      Overrides:
      getGeneratesLineArea in class AbstractBaseLayoutManager
      Returns:
      True if the layout manager generates a line area
    • 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