Class LineRenderer
java.lang.Object
com.itextpdf.layout.renderer.AbstractRenderer
com.itextpdf.layout.renderer.LineRenderer
- All Implemented Interfaces:
IPropertyContainer, IRenderer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]private static final org.slf4j.Loggerprotected floatprivate floatprivate floatprotected float(package private) float(package private) floatprivate static final floatFields inherited from class AbstractRenderer
BOTTOM_SIDE, childRenderers, EPS, flushed, INF, isLastRendererForModelElement, LEFT_SIDE, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties, RIGHT_SIDE, TOP_SIDE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidadjustChildPositionsAfterReordering(List<IRenderer> children, float initialXPos) private voidprotected LineRendererprivate voidprivate voidadjustLineOnFloatPlaced(Rectangle layoutBox, int childPos, FloatPropertyValue kidFloatPropertyVal, Rectangle justPlacedFloatBox) protected voidapplyLeading(float deltaY) private BaseDirectionapplyOtf()Apply OTF features and return the last(!) base direction of child rendererprivate floatapplyTextAnchor(float textWidth) protected intReturns the number of base characters, i.e.private floatcalculateTab(Rectangle layoutBox, float curWidth, TabStop tabStop, List<IRenderer> affectedRenderers, IRenderer tabRenderer) Calculates and sets tab size with the account of the element that is next in the line after the tab.private TabStopcalculateTab(IRenderer childRenderer, float curWidth, float lineWidth) Calculates and sets encountered tab size.booleanprotected LineRendererprotected LineRendererprivate floatdecreaseRelativeWidthByChildAdditionalWidth(IRenderer childRenderer, float normalizedChildWidth) voiddrawChildren(DrawContext drawContext) Performs the drawing operation for allchildrenof this renderer.(package private) float[]getAscentDescentOfLayoutedChildRenderer(IRenderer childRenderer, LayoutResult childResult, RenderingMode childRenderingMode, boolean isInlineBlockChild) Extracts ascender and descender of an already layoutedchildRenderer.(package private) floatgetBottomLeadingIndent(Leading leading) protected FloatGets the first yLine of the nested children recursively.private IRendererprotected FloatfloatgetLeadingValue(Leading leading) floatfloatCalculates min and max width values for current renderer.private float[]Gets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)is called more than once.private TabStopgetNextTabStop(float curWidth) protected int(package private) floatgetTopLeadingIndent(Leading leading) floatgetYLine()(package private) booleanprivate boolean(package private) static booleanisChildFloating(IRenderer childRenderer) (package private) booleanisForceOverflowForTextRendererPartialResult(IRenderer childRenderer, boolean wasXOverflowChanged, OverflowPropertyValue oldXOverflow, LayoutContext layoutContext, Rectangle layoutBox, boolean wasParentsHeightClipped) Checks if the word that's been split when has been layouted on this line can fit the next line without splitting.(package private) static booleanisInlineBlockChild(IRenderer child) voidjustify(float width) layout(LayoutContext layoutContext) This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult, representing the layout result, including occupied area, status, i.e.protected intlength()Gets the total lengths of characters in this line.private voidprocessDefaultTab(IRenderer tabRenderer, float curWidth, float lineWidth) (package private) static voidreorder(LineRenderer toProcess, LineRenderer.LineSplitIntoGlyphsData splitLineIntoGlyphsResult, int[] newOrder) private voidreplaceSplitRendererKidFloats(Map<Integer, IRenderer> floatsToNextPageSplitRenderers, LineRenderer splitRenderer) private voidWhile resolving TextRenderer may split into several ones with different fonts.protected FloatRetrieve the resolved height declaration.protected LineRenderer[]split()(package private) static LineRenderer.LineSplitIntoGlyphsDatasplitLineIntoGlyphs(LineRenderer toSplit) private LineRenderer[]splitNotFittingFloat(int childPos, LayoutResult childResult) toString()Returns a string representation of the renderer.(package private) intTrim first child text renderers.protected LineRenderertrimLast()(package private) voidupdateAscentDescentAfterChildLayout(float[] childAscentDescent, IRenderer childRenderer, boolean isChildFloating) UpdatemaxAscent,maxDescent,maxTextAscent,maxTextDescent,maxBlockAscentandmaxBlockDescentafter child's layout.(package private) float[]updateAscentDescentAfterTextRendererSequenceProcessing(int newChildPos, LineRenderer.LineAscentDescentState lineAscentDescentStateBeforeTextRendererSequence, Map<Integer, float[]> textRendererSequenceAscentDescent) UpdatesmaxAscent,maxDescent,maxTextAscentandmaxTextDescentafter aTextRenderersequence has been fully processed.private voidupdateBidiLevels(int totalNumberOfTrimmedGlyphs, BaseDirection baseDirection) private voidMethods inherited from class AbstractRenderer
addAllChildRenderers, addAllChildRenderers, addAllProperties, addChild, addChildRenderer, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAbsolutePositionIfNeeded, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyMarginsBordersPaddings, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateAdditionalWidth, calculateBBox, calculatePaddingBorderHeight, calculatePaddingBorderWidth, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createFontCharacteristics, createXObject, deleteOwnProperty, deleteProperty, draw, drawBackground, drawBorder, drawPositionedChildren, endElementOpacityApplying, endTransformationIfApplied, getAspectRatio, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getBorders, getChildRenderers, getDefaultProperty, getInnerAreaBBox, getMargins, getMinMaxWidth, getModelElement, getOccupiedArea, getOccupiedAreaBBox, getOwnProperties, getOwnProperty, getPaddings, getParent, getPdfDocument, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, getPropertyAsUnitValue, getRootRenderer, hasAbsoluteUnitValue, hasAspectRatio, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, logWarningIfGetNextRendererNotOverridden, move, noAbsolutePositionInfo, preparePositionedRendererAndAreaForLayout, processWaitingDrawing, rectangleToPointsList, removeAllChildRenderers, removeChildRenderer, replaceOwnProperty, resolveFirstPdfFont, resolveFirstPdfFont, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveUnitValue, retrieveUnitValue, retrieveWidth, returnBackOwnProperty, setBorders, setChildRenderer, setChildRenderers, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, setThisAsParent, shrinkOccupiedAreaForAbsolutePosition, transformPoints, updateHeight, updateHeightsOnSplit, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidth
-
Field Details
-
MIN_MAX_WIDTH_CORRECTION_EPS
private static final float MIN_MAX_WIDTH_CORRECTION_EPS- See Also:
-
logger
private static final org.slf4j.Logger logger -
maxAscent
protected float maxAscent -
maxDescent
protected float maxDescent -
levels
protected byte[] levels -
maxTextAscent
float maxTextAscent -
maxTextDescent
float maxTextDescent -
maxBlockAscent
private float maxBlockAscent -
maxBlockDescent
private float maxBlockDescent
-
-
Constructor Details
-
LineRenderer
public LineRenderer()
-
-
Method Details
-
layout
Description copied from interface:IRendererThis method simulates positioning of the renderer, including all of its children, and returns theLayoutResult, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc.LayoutResultcan be extended to return custom layout results for custom elements, e.g.TextRendererusesTextLayoutResultas its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called beforeIRenderer.draw(DrawContext), to prepare the renderer to be flushed to the output stream.- Parameters:
layoutContext- the description of layout area and any other additional information- Returns:
- result of the layout process
-
getMaxAscent
public float getMaxAscent() -
getMaxDescent
public float getMaxDescent() -
getYLine
public float getYLine() -
getLeadingValue
-
drawChildren
Description copied from class:AbstractRendererPerforms the drawing operation for allchildrenof this renderer.- Overrides:
drawChildrenin classAbstractRenderer- Parameters:
drawContext- the context (canvas, document, etc) of this drawing operation.
-
getNextRenderer
Description copied from interface:IRendererGets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)is called more than once.- Returns:
- new renderer instance
-
getFirstYLineRecursively
Description copied from class:AbstractRendererGets the first yLine of the nested children recursively. E.g. for a list, this will be the yLine of the first item (if the first item is indeed a paragraph). NOTE: this method will no go further than the first child.- Overrides:
getFirstYLineRecursivelyin classAbstractRenderer- Returns:
- the first yline of the nested children, null if there is no text found
-
getLastYLineRecursively
- Overrides:
getLastYLineRecursivelyin classAbstractRenderer
-
justify
public void justify(float width) -
getNumberOfSpaces
protected int getNumberOfSpaces() -
length
protected int length()Gets the total lengths of characters in this line. Other elements (images, tables) are not taken into account.- Returns:
- the total lengths of characters in this line.
-
baseCharactersCount
protected int baseCharactersCount()Returns the number of base characters, i.e. non-mark characters- Returns:
- the number of base non-mark characters
-
toString
Description copied from class:AbstractRendererReturns a string representation of the renderer.- Overrides:
toStringin classAbstractRenderer- Returns:
- a
String - See Also:
-
createSplitRenderer
-
createOverflowRenderer
-
split
-
adjustChildrenYLine
-
applyLeading
protected void applyLeading(float deltaY) -
trimLast
-
containsImage
public boolean containsImage() -
getMinMaxWidth
Description copied from class:AbstractRendererCalculates min and max width values for current renderer.- Overrides:
getMinMaxWidthin classAbstractRenderer- Returns:
- instance of
MinMaxWidth
-
retrieveResolvedDeclaredHeight
Retrieve the resolved height declaration. If it has a relative height declaration,AbstractRenderer.retrieveHeight()is called.- Overrides:
retrieveResolvedDeclaredHeightin classAbstractRenderer- Returns:
nullif no height declaration is set on the parent, or if its own height declaration cannot be resolved. The float value of the resolved height otherwise
-
hasChildRendererInHtmlMode
boolean hasChildRendererInHtmlMode() -
getTopLeadingIndent
-
getBottomLeadingIndent
-
splitLineIntoGlyphs
-
reorder
static void reorder(LineRenderer toProcess, LineRenderer.LineSplitIntoGlyphsData splitLineIntoGlyphsResult, int[] newOrder) -
adjustChildPositionsAfterReordering
-
splitNotFittingFloat
-
adjustLineOnFloatPlaced
private void adjustLineOnFloatPlaced(Rectangle layoutBox, int childPos, FloatPropertyValue kidFloatPropertyVal, Rectangle justPlacedFloatBox) -
replaceSplitRendererKidFloats
private void replaceSplitRendererKidFloats(Map<Integer, IRenderer> floatsToNextPageSplitRenderers, LineRenderer splitRenderer) -
getLastNonFloatChildRenderer
-
getNextTabStop
-
calculateTab
Calculates and sets encountered tab size. Returns null, if processing is finished and layout can be performed for the tab renderer; otherwise, in case when the tab should be processed after the next element in the line, this method returns corresponding tab stop. -
calculateTab
-
processDefaultTab
-
updateChildrenParent
private void updateChildrenParent() -
trimFirst
int trimFirst()Trim first child text renderers.- Returns:
- total number of trimmed glyphs.
-
applyOtf
Apply OTF features and return the last(!) base direction of child renderer- Returns:
- the last(!) base direction of child renderer.
-
isChildFloating
-
isInlineBlockChild
-
isForceOverflowForTextRendererPartialResult
boolean isForceOverflowForTextRendererPartialResult(IRenderer childRenderer, boolean wasXOverflowChanged, OverflowPropertyValue oldXOverflow, LayoutContext layoutContext, Rectangle layoutBox, boolean wasParentsHeightClipped) Checks if the word that's been split when has been layouted on this line can fit the next line without splitting.- Parameters:
childRenderer- the childRenderer containing the split wordwasXOverflowChanged- true ifProperty.OVERFLOW_Xhas been changed during layouting ofLineRendereroldXOverflow- the value ofProperty.OVERFLOW_Xbefore it's been changed during layouting ofLineRendereror null ifProperty.OVERFLOW_Xhasn't been changedlayoutContext-LayoutContextlayoutBox- current layoutBoxwasParentsHeightClipped- true if layoutBox's height has been clipped- Returns:
- true if the split word can fit the next line without splitting
-
getAscentDescentOfLayoutedChildRenderer
float[] getAscentDescentOfLayoutedChildRenderer(IRenderer childRenderer, LayoutResult childResult, RenderingMode childRenderingMode, boolean isInlineBlockChild) Extracts ascender and descender of an already layoutedchildRenderer.- Parameters:
childRenderer- an already layouted child who's ascender and descender are to be extractedchildResult-LayoutResultof the childRenderer based on which ascender and descender are definedchildRenderingMode-rendering modeisInlineBlockChild- true if childRendererisInlineBlockChild(IRenderer)- Returns:
- a two-element float array where first element is ascender value and second element is descender value
-
updateAscentDescentAfterTextRendererSequenceProcessing
float[] updateAscentDescentAfterTextRendererSequenceProcessing(int newChildPos, LineRenderer.LineAscentDescentState lineAscentDescentStateBeforeTextRendererSequence, Map<Integer, float[]> textRendererSequenceAscentDescent) UpdatesmaxAscent,maxDescent,maxTextAscentandmaxTextDescentafter aTextRenderersequence has been fully processed.- Parameters:
newChildPos- position of the lastTextRendererchild of the sequence to remain on the linelineAscentDescentStateBeforeTextRendererSequence- aLineRenderer.LineAscentDescentStatecontainingLineRenderer's maxAscent, maxDescent, maxTextAscent, maxTextDescent beforeTextRenderersequence starttextRendererSequenceAscentDescent- aMapwithTextRendererchildren's positions as keys and float arrays consisting of maxAscent, maxDescent, maxTextAscent, maxTextDescent of the correspondingTextRendererchildren.- Returns:
- a two-element float array where first element is a new
LineRenderer's ascender and second element is a newLineRenderer's descender
-
updateAscentDescentAfterChildLayout
void updateAscentDescentAfterChildLayout(float[] childAscentDescent, IRenderer childRenderer, boolean isChildFloating) UpdatemaxAscent,maxDescent,maxTextAscent,maxTextDescent,maxBlockAscentandmaxBlockDescentafter child's layout.- Parameters:
childAscentDescent- a two-element float array where first element is ascender of a layouted child and second element is descender of a layouted childchildRenderer- the layoutedchildRendererof currentLineRendererisChildFloating- true ifisChildFloating(IRenderer)
-
updateBidiLevels
-
resolveChildrenFonts
private void resolveChildrenFonts()While resolving TextRenderer may split into several ones with different fonts. -
decreaseRelativeWidthByChildAdditionalWidth
private float decreaseRelativeWidthByChildAdditionalWidth(IRenderer childRenderer, float normalizedChildWidth) -
adjustChildrenYLineDefaultMode
private void adjustChildrenYLineDefaultMode() -
hasInlineBlocksWithVerticalAlignment
private boolean hasInlineBlocksWithVerticalAlignment() -
adjustChildrenXLine
private void adjustChildrenXLine() -
getMinMaxX
private float[] getMinMaxX() -
applyTextAnchor
private float applyTextAnchor(float textWidth)
-