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
ConstructorDescriptionContentLayoutManager
(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
Modifier and TypeMethodDescriptionaddALetterSpaceTo
(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 elementsaddALetterSpaceTo
(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 elementsvoid
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.void
addChildArea
(Area childArea) Add the area as a child of the current area.void
Add the LM in the argument to the list of child LMs; set this LM as the parent; initialize the LM.void
addChildLMs
(List newLMs) Add the LMs in the argument to the list of child LMs;boolean
applyChanges
(List oldList) Tell the LM to apply the changes due to hyphenationboolean
applyChanges
(List oldList, int depth) Tell the LM to apply the changes due to hyphenationboolean
createNextChildLMs
(int pos) Create more child LMs of the parent, up to child LM index posint
Returns the position of the dominant-baseline of this FO's first descendant line-area.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.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 appliedint
Returns the BPD of the content areaint
Returns the IPD of the content areaboolean
Returns an indication if the layout manager generates a block area.boolean
Returns an indication if the layout manager generates a line area.boolean
Returns an indication if the layout manager generates a reference area.getNextKnuthElements
(LayoutContext context, int alignment) Get a sequence of KnuthElements representing the content of the node assigned to the LM.Get the parent layout manager.getParentArea
(Area childArea) Get the parent area for an area.getPSLM()
Get the active PageSequenceLayoutManager instance for this layout process.int
getWordChars
(Position pos) Get the word chars corresponding to the given position.boolean
Whether the FO handled by this layout manager has a descendant (including itself) that will generate a line-area.void
hyphenate
(Position pos, HyphContext hc) Tell the LM to hyphenate a wordvoid
initialize the layout manager.boolean
Return a value indicating whether this LayoutManager has laid out all its content (or generated BreakPossibilities for all content.)Adds a Position to the Position participating in the first|last determination by assigning it a unique position index.void
setFinished
(boolean isFinished) Set a flag indicating whether the LayoutManager has laid out all its content.void
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 Details
-
ContentLayoutManager
Constructs a new ContentLayoutManager- Parameters:
area
- The parent areaparentLM
- the parent layout manager
-
ContentLayoutManager
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 Details
-
initialize
public void initialize()initialize the layout manager. Allows each layout manager to calculate often used values.- Specified by:
initialize
in interfaceLayoutManager
-
addAreas
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 interfaceLayoutManager
- Parameters:
posIter
- the position iteratorcontext
- the context
-
getStackingSize
public int getStackingSize()- Returns:
- stack size
-
getParentArea
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 interfaceLayoutManager
- Parameters:
childArea
- the child area to get the parent for- Returns:
- the parent Area
-
addChildArea
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 interfaceLayoutManager
- Parameters:
childArea
- the child area to add
-
setParent
Set the parent layout manager. The parent layout manager is required for adding areas.- Specified by:
setParent
in interfaceLayoutManager
- Parameters:
lm
- the parent layout manager
-
getParent
Get the parent layout manager.- Specified by:
getParent
in 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:
isFinished
in 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:
setFinished
in 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:
createNextChildLMs
in interfaceLayoutManager
- Parameters:
pos
- index up to which child LMs are requested- Returns:
- true if requested index does exist
-
getChildLMs
- Specified by:
getChildLMs
in interfaceLayoutManager
- Returns:
- the list of child LMs
-
addChildLM
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 interfaceLayoutManager
- Parameters:
lm
- the LM to be added
-
addChildLMs
Add the LMs in the argument to the list of child LMs;- Specified by:
addChildLMs
in interfaceLayoutManager
- Parameters:
newLMs
- the list of LMs to be added
-
getNextKnuthElements
Get a sequence of KnuthElements representing the content of the node assigned to the LM.- Specified by:
getNextKnuthElements
in interfaceLayoutManager
- Parameters:
context
- the LayoutContext used to store layout informationalignment
- the desired text alignment- Returns:
- the list of KnuthElements
-
addALetterSpaceTo
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 interfaceInlineLevelLayoutManager
- Parameters:
oldList
- the elements which must be given one more letter space- Returns:
- the new elements replacing the old ones
-
addALetterSpaceTo
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 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
Get the word chars corresponding to the given position.- Specified by:
getWordChars
in interfaceInlineLevelLayoutManager
- Parameters:
pos
- the position referring to the needed word chars.- Returns:
- the word chars
-
hyphenate
Tell the LM to hyphenate a word- Specified by:
hyphenate
in interfaceInlineLevelLayoutManager
- Parameters:
pos
- the Position referring to the wordhc
- the HyphContext storing hyphenation information
-
applyChanges
Tell the LM to apply the changes due to hyphenation- Specified by:
applyChanges
in 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
Tell the LM to apply the changes due to hyphenation- Specified by:
applyChanges
in 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
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 interfaceLayoutManager
- Parameters:
oldList
- the elements to replacealignment
- the desired text alignment- Returns:
- the updated list of KnuthElements
-
getChangedKnuthElements
Get a sequence of KnuthElements representing the content of the node assigned to the LM, after changes have been applied- Specified by:
getChangedKnuthElements
in 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
Get the active PageSequenceLayoutManager instance for this layout process.- Specified by:
getPSLM
in interfaceLayoutManager
- 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 interfaceLayoutManager
- 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 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:
-
getContentAreaIPD
public int getContentAreaIPD()Returns the IPD of the content area- Specified by:
getContentAreaIPD
in interfaceLayoutManager
- Overrides:
getContentAreaIPD
in classAbstractBaseLayoutManager
- Returns:
- the IPD of the content area
-
getContentAreaBPD
public int getContentAreaBPD()Returns the BPD of the content area- Specified by:
getContentAreaBPD
in interfaceLayoutManager
- Overrides:
getContentAreaBPD
in 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:
getGeneratesReferenceArea
in interfaceLayoutManager
- Overrides:
getGeneratesReferenceArea
in 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:
getGeneratesBlockArea
in interfaceLayoutManager
- Overrides:
getGeneratesBlockArea
in 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:
getGeneratesLineArea
in interfaceLayoutManager
- Overrides:
getGeneratesLineArea
in classAbstractBaseLayoutManager
- Returns:
- True if the layout manager generates a line area
-
notifyPos
Adds a Position to the Position participating in the first|last determination by assigning it a unique position index.- Specified by:
notifyPos
in interfaceLayoutManager
- Parameters:
pos
- the Position- Returns:
- the same Position but with a position index
-