Package org.apache.fop.layoutmgr.inline
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.
-
-
Field Summary
-
Fields inherited from class org.apache.fop.layoutmgr.AbstractBaseLayoutManager
fobj, generatesBlockArea, generatesReferenceArea
-
-
Constructor Summary
Constructors Constructor Description ContentLayoutManager(Area area, LayoutManager parentLM)Constructs a new ContentLayoutManagerContentLayoutManager(PageSequenceLayoutManager pslm, Title foTitle)Constructor using a fo:title formatting object and its PageSequenceLayoutManager parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ListaddALetterSpaceTo(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 elementsjava.util.ListaddALetterSpaceTo(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 elementsvoidaddAreas(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.voidaddChildArea(Area childArea)Add the area as a child of the current area.voidaddChildLM(LayoutManager lm)Add the LM in the argument to the list of child LMs; set this LM as the parent; initialize the LM.voidaddChildLMs(java.util.List newLMs)Add the LMs in the argument to the list of child LMs;booleanapplyChanges(java.util.List oldList)Tell the LM to apply the changes due to hyphenationbooleanapplyChanges(java.util.List oldList, int depth)Tell the LM to apply the changes due to hyphenationbooleancreateNextChildLMs(int pos)Create more child LMs of the parent, up to child LM index posintgetBaselineOffset()Returns the position of the dominant-baseline of this FO's first descendant line-area.java.util.ListgetChangedKnuthElements(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.java.util.ListgetChangedKnuthElements(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 appliedjava.util.ListgetChildLMs()intgetContentAreaBPD()Returns the BPD of the content areaintgetContentAreaIPD()Returns the IPD of the content areabooleangetGeneratesBlockArea()Returns an indication if the layout manager generates a block area.booleangetGeneratesLineArea()Returns an indication if the layout manager generates a line area.booleangetGeneratesReferenceArea()Returns an indication if the layout manager generates a reference area.java.util.ListgetNextKnuthElements(LayoutContext context, int alignment)Get a sequence of KnuthElements representing the content of the node assigned to the LM.LayoutManagergetParent()Get the parent layout manager.AreagetParentArea(Area childArea)Get the parent area for an area.PageSequenceLayoutManagergetPSLM()Get the active PageSequenceLayoutManager instance for this layout process.intgetStackingSize()java.lang.StringgetWordChars(Position pos)Get the word chars corresponding to the given position.booleanhasLineAreaDescendant()Whether the FO handled by this layout manager has a descendant (including itself) that will generate a line-area.voidhyphenate(Position pos, HyphContext hc)Tell the LM to hyphenate a wordvoidinitialize()initialize the layout manager.booleanisFinished()Return a value indicating whether this LayoutManager has laid out all its content (or generated BreakPossibilities for all content.)PositionnotifyPos(Position pos)Adds a Position to the Position participating in the first|last determination by assigning it a unique position index.voidsetFinished(boolean isFinished)Set a flag indicating whether the LayoutManager has laid out all its content.voidsetParent(LayoutManager lm)Set the parent layout manager.-
Methods inherited from class org.apache.fop.layoutmgr.AbstractBaseLayoutManager
getAncestorBlockAreaBPD, getAncestorBlockAreaIPD, getBaseLength, getChangeBarList, getFObj, getNextKnuthElements, getParentAreaBPD, getParentAreaIPD, getReferenceAreaBPD, getReferenceAreaIPD, isRestartable, preserveChildrenAtEndOfLayout, recreateChildrenLMs, reset, setGeneratesBlockArea, setGeneratesReferenceArea
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.fop.layoutmgr.LayoutManager
getFObj, getNextKnuthElements, isRestartable, reset
-
Methods inherited from interface org.apache.fop.datatypes.PercentBaseContext
getBaseLength
-
-
-
-
Constructor Detail
-
ContentLayoutManager
public ContentLayoutManager(Area area, LayoutManager parentLM)
Constructs a new ContentLayoutManager- Parameters:
area- The parent areaparentLM- 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 LMfoTitle- the Title FO for which this LM is made
-
-
Method Detail
-
initialize
public void initialize()
initialize the layout manager. Allows each layout manager to calculate often used values.- Specified by:
initializein interfaceLayoutManager
-
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:
addAreasin interfaceLayoutManager- Parameters:
posIter- the position iteratorcontext- 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:
getParentAreain interfaceLayoutManager- 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:
addChildAreain interfaceLayoutManager- 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:
setParentin interfaceLayoutManager- Parameters:
lm- the parent layout manager
-
getParent
public LayoutManager getParent()
Get the parent layout manager.- Specified by:
getParentin interfaceLayoutManager- 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:
isFinishedin interfaceLayoutManager- 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:
setFinishedin interfaceLayoutManager- 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:
createNextChildLMsin interfaceLayoutManager- Parameters:
pos- index up to which child LMs are requested- Returns:
- true if requested index does exist
-
getChildLMs
public java.util.List getChildLMs()
- Specified by:
getChildLMsin interfaceLayoutManager- 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:
addChildLMin interfaceLayoutManager- 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:
addChildLMsin interfaceLayoutManager- Parameters:
newLMs- the list of LMs to be added
-
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:
getNextKnuthElementsin interfaceLayoutManager- Parameters:
context- the LayoutContext used to store layout informationalignment- 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:
addALetterSpaceToin interfaceInlineLevelLayoutManager- 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- Specified by:
addALetterSpaceToin interfaceInlineLevelLayoutManager- Parameters:
oldList- the elements which must be given one more letter spacedepth- 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:
getWordCharsin interfaceInlineLevelLayoutManager- 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:
hyphenatein interfaceInlineLevelLayoutManager- Parameters:
pos- the Position referring to the wordhc- 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:
applyChangesin interfaceInlineLevelLayoutManager- 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- Specified by:
applyChangesin interfaceInlineLevelLayoutManager- Parameters:
oldList- the list of the old elements the changes refer todepth- 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)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:
getChangedKnuthElementsin interfaceLayoutManager- Parameters:
oldList- the elements to replacealignment- the desired text alignment- Returns:
- the updated list of KnuthElements
-
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:
getChangedKnuthElementsin interfaceInlineLevelLayoutManager- Parameters:
oldList- the elements to replacealignment- the desired text alignmentdepth- 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:
getPSLMin interfaceLayoutManager- Returns:
- the PageSequenceLayoutManager
-
hasLineAreaDescendant
public boolean hasLineAreaDescendant()
Description copied from interface:LayoutManagerWhether the FO handled by this layout manager has a descendant (including itself) that will generate a line-area.- Specified by:
hasLineAreaDescendantin interfaceLayoutManager- Returns:
trueif a descendant line-area will be generated,falseotherwise
-
getBaselineOffset
public int getBaselineOffset()
Description copied from interface:LayoutManagerReturns 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:
getBaselineOffsetin interfaceLayoutManager- 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()
-
getContentAreaIPD
public int getContentAreaIPD()
Returns the IPD of the content area- Specified by:
getContentAreaIPDin interfaceLayoutManager- Overrides:
getContentAreaIPDin classAbstractBaseLayoutManager- Returns:
- the IPD of the content area
-
getContentAreaBPD
public int getContentAreaBPD()
Returns the BPD of the content area- Specified by:
getContentAreaBPDin interfaceLayoutManager- Overrides:
getContentAreaBPDin classAbstractBaseLayoutManager- Returns:
- the BPD of the content area
-
getGeneratesReferenceArea
public boolean getGeneratesReferenceArea()
Returns an indication if the layout manager generates a reference area.- Specified by:
getGeneratesReferenceAreain interfaceLayoutManager- Overrides:
getGeneratesReferenceAreain classAbstractBaseLayoutManager- 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:
getGeneratesBlockAreain interfaceLayoutManager- Overrides:
getGeneratesBlockAreain classAbstractBaseLayoutManager- 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:
getGeneratesLineAreain interfaceLayoutManager- Overrides:
getGeneratesLineAreain classAbstractBaseLayoutManager- 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:
notifyPosin interfaceLayoutManager- Parameters:
pos- the Position- Returns:
- the same Position but with a position index
-
-