Package org.apache.fop.layoutmgr
Class LayoutContext
- java.lang.Object
-
- org.apache.fop.layoutmgr.LayoutContext
-
public final class LayoutContext extends java.lang.Object
This class is used to pass information to the getNextKnuthElements() method. It is set up by higher level LM and used by lower level LM.
-
-
Field Summary
Fields Modifier and Type Field Description private AlignmentContext
alignmentContext
private int
bpAlignment
Alignment in BP directionprivate int
breakAfter
private int
breakBefore
private int
currentSpan
to keep track of spanning in multi-column layoutprivate int
disableColumnBalancing
private double
dSpaceAdjust
Stretch or shrink value when adding spaces.static int
FIRST_AREA
private int
flags
private HyphContext
hyphContext
Current hyphenation context.private double
ipdAdjust
Stretch or shrink value when making areas.static int
LAST_AREA
private SpaceSpecifier
leadingSpace
Current pending space-before or space-start from ancestor areasprivate int
lineEndBorderAndPaddingWidth
Amount of space to reserve at the end of each lineprivate int
lineStartBorderAndPaddingWidth
Amount of space to reserve at the beginning of each linestatic int
NEW_AREA
Generated break possibility is first in a new areaprivate int
nextSpan
private java.util.List
pendingAfterMarks
A list of pending marks (border and padding) on the after edge when a page break occurs.private java.util.List
pendingBeforeMarks
A list of pending marks (border and padding) on the before edge when a page break occurs.private Keep
pendingKeepWithNext
private Keep
pendingKeepWithPrevious
private int
refIPD
inline-progression-dimension of nearest ancestor reference areastatic int
RESOLVE_LEADING_SPACE
private int
spaceAfter
Amount of space after / endprivate int
spaceBefore
Amount of space before / startprivate MinOptMax
stackLimitBP
Total available stacking dimension for a "galley-level" layout manager in block-progression-direction.static int
SUPPRESS_BREAK_BEFORE
If this flag is set, it indicates that any break-before values other than "auto" should not cause a mandatory break as this break was already handled by a parent layout manager.private SpaceSpecifier
trailingSpace
Current pending space-after or space-end from preceding areaprivate static int
TREAT_AS_ARTIFACT
private WritingMode
writingMode
the writing mode established by the nearest ancestor reference area
-
Constructor Summary
Constructors Modifier Constructor Description private
LayoutContext(int flags)
private
LayoutContext(LayoutContext parentLC)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPendingAfterMark(UnresolvedListElementWithLength element)
Adds a border or padding element to the pending list which will be used to generate the right element list for break possibilities.void
addPendingBeforeMark(UnresolvedListElementWithLength element)
Adds a border or padding element to the pending list which will be used to generate the right element list for break possibilities.void
clearKeepsPending()
Clears both keep-with-previous and keep-with-next strengths.void
clearKeepWithNextPending()
Clears any pending keep-with-next strength.void
clearKeepWithPreviousPending()
Clears any pending keep-with-previous strength.void
clearPendingMarks()
Clears all pending marks on the LayoutContext.static LayoutContext
copyOf(LayoutContext copy)
void
copyPendingMarksFrom(LayoutContext source)
AlignmentContext
getAlignmentContext()
int
getBPAlignment()
int
getBreakAfter()
Returns the value of the break after the element whoseLayoutManager.getNextKnuthElements(LayoutContext, int)
method has just been called.int
getBreakBefore()
Returns the value of the break before the element whoseLayoutManager.getNextKnuthElements(LayoutContext, int)
method has just been called.int
getCurrentSpan()
int
getDisableColumnBalancing()
Returns whether the column balancer should be disabled before a spanning blockHyphContext
getHyphContext()
double
getIPDAdjust()
Keep
getKeepWithNextPending()
Returns the strength of a keep-with-next currently pending.Keep
getKeepWithPreviousPending()
Returns the strength of a keep-with-previous currently pending.SpaceSpecifier
getLeadingSpace()
int
getLineEndBorderAndPaddingWidth()
Get the width to be reserved for border and padding at the end of the line.int
getLineStartBorderAndPaddingWidth()
Get the width to be reserved for border and padding at the start of the line.int
getNextSpan()
java.util.List
getPendingAfterMarks()
java.util.List
getPendingBeforeMarks()
int
getRefIPD()
Returns the inline-progression-dimension of the nearest ancestor reference area.double
getSpaceAdjust()
int
getSpaceAfter()
Get the current amount of space after / endint
getSpaceBefore()
Get the current amount of space before / startMinOptMax
getStackLimitBP()
Returns the stack limit in block-progression-dimension.SpaceSpecifier
getTrailingSpace()
WritingMode
getWritingMode()
Get the writing mode of the relevant reference area.boolean
isFirstArea()
boolean
isKeepWithNextPending()
Indicates whether a keep-with-next constraint is pending.boolean
isKeepWithPreviousPending()
Indicates whether a keep-with-previous constraint is pending.boolean
isLastArea()
boolean
isStart()
static LayoutContext
newInstance()
static LayoutContext
offspringOf(LayoutContext parent)
Returns a descendant of the given layout context.void
resetAlignmentContext()
Reset alignment context.boolean
resolveLeadingSpace()
void
setAlignmentContext(AlignmentContext alignmentContext)
void
setBPAlignment(int alignment)
Sets the currently applicable alignment in BP direction.void
setBreakAfter(int breakAfter)
Sets the value of the break after the current element.void
setBreakBefore(int breakBefore)
Sets the value of the break before the current element.void
setDisableColumnBalancing(int disableColumnBalancing)
Sets whether the column balancer should be disabled before a spanning blockvoid
setFlags(int flags)
void
setFlags(int flags, boolean bSet)
void
setHyphContext(HyphContext hyph)
void
setIPDAdjust(double ipdA)
void
setLeadingSpace(SpaceSpecifier space)
void
setLineEndBorderAndPaddingWidth(int lineEndBorderAndPaddingWidth)
Set the width to be reserved for border and padding at the end of the line.void
setLineStartBorderAndPaddingWidth(int lineStartBorderAndPaddingWidth)
Set the width to be reserved for border and padding at the start of the line.void
setRefIPD(int ipd)
Sets the inline-progression-dimension of the nearest ancestor reference area.void
setSpaceAdjust(double adjust)
void
setSpaceAfter(int spaceAfter)
Set the amount of space after / endvoid
setSpaceBefore(int spaceBefore)
Set the amount of space before / startvoid
setStackLimitBP(MinOptMax limit)
Sets the stack limit in block-progression-dimension.void
setTrailingSpace(SpaceSpecifier space)
void
setTreatAsArtifact(boolean treatAsArtifact)
void
setWritingMode(WritingMode writingMode)
Set the writing mode.void
signalSpanChange(int span)
Used to signal the PSLM that the element list ends early because of a span change in multi-column layout.boolean
startsNewArea()
boolean
suppressBreakBefore()
java.lang.String
toString()
boolean
treatAsArtifact()
void
unsetFlags(int flags)
void
updateKeepWithNextPending(Keep keep)
Updates the currently pending keep-with-next strength.void
updateKeepWithPreviousPending(Keep keep)
Updates the currently pending keep-with-previous strength.
-
-
-
Field Detail
-
NEW_AREA
public static final int NEW_AREA
Generated break possibility is first in a new area- See Also:
- Constant Field Values
-
SUPPRESS_BREAK_BEFORE
public static final int SUPPRESS_BREAK_BEFORE
If this flag is set, it indicates that any break-before values other than "auto" should not cause a mandatory break as this break was already handled by a parent layout manager.- See Also:
- Constant Field Values
-
FIRST_AREA
public static final int FIRST_AREA
- See Also:
- Constant Field Values
-
LAST_AREA
public static final int LAST_AREA
- See Also:
- Constant Field Values
-
RESOLVE_LEADING_SPACE
public static final int RESOLVE_LEADING_SPACE
- See Also:
- Constant Field Values
-
TREAT_AS_ARTIFACT
private static final int TREAT_AS_ARTIFACT
- See Also:
- Constant Field Values
-
flags
private int flags
-
stackLimitBP
private MinOptMax stackLimitBP
Total available stacking dimension for a "galley-level" layout manager in block-progression-direction. It is passed by the parent LM. These LM may wish to pass this information down to lower level LM to allow them to optimize returned break possibilities.
-
currentSpan
private int currentSpan
to keep track of spanning in multi-column layout
-
nextSpan
private int nextSpan
-
refIPD
private int refIPD
inline-progression-dimension of nearest ancestor reference area
-
writingMode
private WritingMode writingMode
the writing mode established by the nearest ancestor reference area
-
trailingSpace
private SpaceSpecifier trailingSpace
Current pending space-after or space-end from preceding area
-
leadingSpace
private SpaceSpecifier leadingSpace
Current pending space-before or space-start from ancestor areas
-
pendingAfterMarks
private java.util.List pendingAfterMarks
A list of pending marks (border and padding) on the after edge when a page break occurs. May be null.
-
pendingBeforeMarks
private java.util.List pendingBeforeMarks
A list of pending marks (border and padding) on the before edge when a page break occurs. May be null.
-
hyphContext
private HyphContext hyphContext
Current hyphenation context. May be null.
-
bpAlignment
private int bpAlignment
Alignment in BP direction
-
ipdAdjust
private double ipdAdjust
Stretch or shrink value when making areas.
-
dSpaceAdjust
private double dSpaceAdjust
Stretch or shrink value when adding spaces.
-
alignmentContext
private AlignmentContext alignmentContext
-
spaceBefore
private int spaceBefore
Amount of space before / start
-
spaceAfter
private int spaceAfter
Amount of space after / end
-
lineStartBorderAndPaddingWidth
private int lineStartBorderAndPaddingWidth
Amount of space to reserve at the beginning of each line
-
lineEndBorderAndPaddingWidth
private int lineEndBorderAndPaddingWidth
Amount of space to reserve at the end of each line
-
breakBefore
private int breakBefore
-
breakAfter
private int breakAfter
-
pendingKeepWithNext
private Keep pendingKeepWithNext
-
pendingKeepWithPrevious
private Keep pendingKeepWithPrevious
-
disableColumnBalancing
private int disableColumnBalancing
-
-
Constructor Detail
-
LayoutContext
private LayoutContext(LayoutContext parentLC)
-
LayoutContext
private LayoutContext(int flags)
-
-
Method Detail
-
newInstance
public static LayoutContext newInstance()
-
copyOf
public static LayoutContext copyOf(LayoutContext copy)
-
offspringOf
public static LayoutContext offspringOf(LayoutContext parent)
Returns a descendant of the given layout context. The new context is the same as what would have been created bynewInstance()
, except for inheritable properties that are passed on by the parent. At the moment, the only inheritable property is the value returned bytreatAsArtifact()
.
-
copyPendingMarksFrom
public void copyPendingMarksFrom(LayoutContext source)
- Parameters:
source
- from which pending marks are copied
-
setFlags
public void setFlags(int flags)
- Parameters:
flags
- to set
-
setFlags
public void setFlags(int flags, boolean bSet)
- Parameters:
flags
- to set or clearbSet
- true to set, false to clear
-
unsetFlags
public void unsetFlags(int flags)
- Parameters:
flags
- to clear
-
isStart
public boolean isStart()
- Returns:
- true if new area is set
-
startsNewArea
public boolean startsNewArea()
- Returns:
- true if new area is set and leading space is non-null
-
isFirstArea
public boolean isFirstArea()
- Returns:
- true if first area is set
-
isLastArea
public boolean isLastArea()
- Returns:
- true if last area is set
-
suppressBreakBefore
public boolean suppressBreakBefore()
- Returns:
- true if suppress break before is set
-
getKeepWithNextPending
public Keep getKeepWithNextPending()
Returns the strength of a keep-with-next currently pending.- Returns:
- the keep-with-next strength
-
getKeepWithPreviousPending
public Keep getKeepWithPreviousPending()
Returns the strength of a keep-with-previous currently pending.- Returns:
- the keep-with-previous strength
-
clearKeepWithNextPending
public void clearKeepWithNextPending()
Clears any pending keep-with-next strength.
-
clearKeepWithPreviousPending
public void clearKeepWithPreviousPending()
Clears any pending keep-with-previous strength.
-
clearKeepsPending
public void clearKeepsPending()
Clears both keep-with-previous and keep-with-next strengths.
-
updateKeepWithNextPending
public void updateKeepWithNextPending(Keep keep)
Updates the currently pending keep-with-next strength.- Parameters:
keep
- the new strength to consider
-
updateKeepWithPreviousPending
public void updateKeepWithPreviousPending(Keep keep)
Updates the currently pending keep-with-previous strength.- Parameters:
keep
- the new strength to consider
-
isKeepWithNextPending
public boolean isKeepWithNextPending()
Indicates whether a keep-with-next constraint is pending.- Returns:
- true if a keep-with-next constraint is pending
-
isKeepWithPreviousPending
public boolean isKeepWithPreviousPending()
Indicates whether a keep-with-previous constraint is pending.- Returns:
- true if a keep-with-previous constraint is pending
-
setLeadingSpace
public void setLeadingSpace(SpaceSpecifier space)
- Parameters:
space
- leading space
-
getLeadingSpace
public SpaceSpecifier getLeadingSpace()
- Returns:
- leading space
-
resolveLeadingSpace
public boolean resolveLeadingSpace()
- Returns:
- true if resolve leading space is set
-
setTrailingSpace
public void setTrailingSpace(SpaceSpecifier space)
- Parameters:
space
- trailing space
-
getTrailingSpace
public SpaceSpecifier getTrailingSpace()
- Returns:
- trailing space
-
addPendingAfterMark
public void addPendingAfterMark(UnresolvedListElementWithLength element)
Adds a border or padding element to the pending list which will be used to generate the right element list for break possibilities. Conditionality resolution will be done elsewhere.- Parameters:
element
- the border, padding or space element
-
getPendingAfterMarks
public java.util.List getPendingAfterMarks()
- Returns:
- the pending border and padding elements at the after edge
- See Also:
addPendingAfterMark(UnresolvedListElementWithLength)
-
clearPendingMarks
public void clearPendingMarks()
Clears all pending marks on the LayoutContext.
-
addPendingBeforeMark
public void addPendingBeforeMark(UnresolvedListElementWithLength element)
Adds a border or padding element to the pending list which will be used to generate the right element list for break possibilities. Conditionality resolution will be done elsewhere.- Parameters:
element
- the border, padding or space element
-
getPendingBeforeMarks
public java.util.List getPendingBeforeMarks()
- Returns:
- the pending border and padding elements at the before edge
- See Also:
addPendingBeforeMark(UnresolvedListElementWithLength)
-
setStackLimitBP
public void setStackLimitBP(MinOptMax limit)
Sets the stack limit in block-progression-dimension.- Parameters:
limit
- the stack limit
-
getStackLimitBP
public MinOptMax getStackLimitBP()
Returns the stack limit in block-progression-dimension.- Returns:
- the stack limit
-
setRefIPD
public void setRefIPD(int ipd)
Sets the inline-progression-dimension of the nearest ancestor reference area.- Parameters:
ipd
- of nearest ancestor reference area
-
getRefIPD
public int getRefIPD()
Returns the inline-progression-dimension of the nearest ancestor reference area.- Returns:
- the inline-progression-dimension of the nearest ancestor reference area
-
setHyphContext
public void setHyphContext(HyphContext hyph)
- Parameters:
hyph
- a hyphenation context
-
getHyphContext
public HyphContext getHyphContext()
- Returns:
- hyphenation context
-
setBPAlignment
public void setBPAlignment(int alignment)
Sets the currently applicable alignment in BP direction.- Parameters:
alignment
- one of EN_START, EN_JUSTIFY etc.
-
getBPAlignment
public int getBPAlignment()
- Returns:
- the currently applicable alignment in BP direction (EN_START, EN_JUSTIFY...)
-
setSpaceAdjust
public void setSpaceAdjust(double adjust)
- Parameters:
adjust
- space adjustment
-
getSpaceAdjust
public double getSpaceAdjust()
- Returns:
- space adjustment
-
setIPDAdjust
public void setIPDAdjust(double ipdA)
- Parameters:
ipdA
- ipd adjustment
-
getIPDAdjust
public double getIPDAdjust()
- Returns:
- ipd adjustment
-
setAlignmentContext
public void setAlignmentContext(AlignmentContext alignmentContext)
- Parameters:
alignmentContext
- alignment context
-
getAlignmentContext
public AlignmentContext getAlignmentContext()
- Returns:
- alignment context
-
resetAlignmentContext
public void resetAlignmentContext()
Reset alignment context.
-
getLineStartBorderAndPaddingWidth
public int getLineStartBorderAndPaddingWidth()
Get the width to be reserved for border and padding at the start of the line.- Returns:
- the width to be reserved
-
setLineStartBorderAndPaddingWidth
public void setLineStartBorderAndPaddingWidth(int lineStartBorderAndPaddingWidth)
Set the width to be reserved for border and padding at the start of the line.- Parameters:
lineStartBorderAndPaddingWidth
- the width to be reserved
-
getLineEndBorderAndPaddingWidth
public int getLineEndBorderAndPaddingWidth()
Get the width to be reserved for border and padding at the end of the line.- Returns:
- the width to be reserved
-
setLineEndBorderAndPaddingWidth
public void setLineEndBorderAndPaddingWidth(int lineEndBorderAndPaddingWidth)
Set the width to be reserved for border and padding at the end of the line.- Parameters:
lineEndBorderAndPaddingWidth
- the width to be reserved
-
getNextSpan
public int getNextSpan()
- Returns:
- one of:
Constants.NOT_SET
,Constants.EN_NONE
Constants.EN_ALL
-
getCurrentSpan
public int getCurrentSpan()
- Returns:
- one of:
Constants.NOT_SET
,Constants.EN_NONE
Constants.EN_ALL
-
signalSpanChange
public void signalSpanChange(int span)
Used to signal the PSLM that the element list ends early because of a span change in multi-column layout.- Parameters:
span
- the new span value (legal values: NOT_SET, EN_NONE, EN_ALL)
-
getWritingMode
public WritingMode getWritingMode()
Get the writing mode of the relevant reference area.- Returns:
- the applicable writing mode
-
setWritingMode
public void setWritingMode(WritingMode writingMode)
Set the writing mode.- Parameters:
writingMode
- the writing mode
-
getSpaceBefore
public int getSpaceBefore()
Get the current amount of space before / start- Returns:
- the space before / start amount
-
setSpaceBefore
public void setSpaceBefore(int spaceBefore)
Set the amount of space before / start- Parameters:
spaceBefore
- the amount of space before / start
-
getSpaceAfter
public int getSpaceAfter()
Get the current amount of space after / end- Returns:
- the space after / end amount
-
setSpaceAfter
public void setSpaceAfter(int spaceAfter)
Set the amount of space after / end- Parameters:
spaceAfter
- the amount of space after / end
-
getBreakBefore
public int getBreakBefore()
Returns the value of the break before the element whoseLayoutManager.getNextKnuthElements(LayoutContext, int)
method has just been called.- Returns:
- one of
Constants.EN_AUTO
,Constants.EN_COLUMN
,Constants.EN_PAGE
,Constants.EN_EVEN_PAGE
, orConstants.EN_ODD_PAGE
-
setBreakBefore
public void setBreakBefore(int breakBefore)
Sets the value of the break before the current element.- Parameters:
breakBefore
- the value of the break-before- See Also:
getBreakBefore()
-
getBreakAfter
public int getBreakAfter()
Returns the value of the break after the element whoseLayoutManager.getNextKnuthElements(LayoutContext, int)
method has just been called.- Returns:
- one of
Constants.EN_AUTO
,Constants.EN_COLUMN
,Constants.EN_PAGE
,Constants.EN_EVEN_PAGE
, orConstants.EN_ODD_PAGE
-
setBreakAfter
public void setBreakAfter(int breakAfter)
Sets the value of the break after the current element.- Parameters:
breakAfter
- the value of the break-after- See Also:
getBreakAfter()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getDisableColumnBalancing
public int getDisableColumnBalancing()
Returns whether the column balancer should be disabled before a spanning block- Returns:
- one of
Constants.EN_TRUE
,Constants.EN_FALSE
-
setDisableColumnBalancing
public void setDisableColumnBalancing(int disableColumnBalancing)
Sets whether the column balancer should be disabled before a spanning block- Parameters:
disableColumnBalancing
- the value of the fox:disable-column-balancing property- See Also:
getDisableColumnBalancing()
-
treatAsArtifact
public boolean treatAsArtifact()
-
setTreatAsArtifact
public void setTreatAsArtifact(boolean treatAsArtifact)
-
-