Package com.itextpdf.layout.renderer
Class ParagraphRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.BlockRenderer
-
- com.itextpdf.layout.renderer.ParagraphRenderer
-
- All Implemented Interfaces:
IPropertyContainer
,IRenderer
- Direct Known Subclasses:
CheckBoxRenderer.FlatParagraphRenderer
,RadioRenderer.FlatParagraphRenderer
public class ParagraphRenderer extends BlockRenderer
This class represents therenderer
object for aParagraph
object. It will draw the glyphs of the textual content on theDrawContext
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<LineRenderer>
lines
-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
BOTTOM_SIDE, childRenderers, EPS, flushed, INF, isLastRendererForModelElement, LEFT_SIDE, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties, RIGHT_SIDE, TOP_SIDE
-
-
Constructor Summary
Constructors Constructor Description ParagraphRenderer(Paragraph modelElement)
Creates a ParagraphRenderer from its corresponding layout object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
alignStaticKids(LineRenderer renderer, float dxRight)
private void
applyTextAlignment(TextAlignment textAlignment, LineLayoutResult result, LineRenderer processedRenderer, Rectangle layoutBox, java.util.List<Rectangle> floatRendererAreas, boolean onlyOverflowedFloatsLeft, float lineIndent)
private ParagraphRenderer
createOverflowRenderer()
protected AbstractRenderer
createOverflowRenderer(int layoutResult)
Creates an overflow renderer.protected ParagraphRenderer
createOverflowRenderer(IRenderer parent)
private ParagraphRenderer
createSplitRenderer()
protected ParagraphRenderer
createSplitRenderer(IRenderer parent)
protected LayoutResult
directLayout(LayoutContext layoutContext)
void
drawChildren(DrawContext drawContext)
Performs the drawing operation for allchildren
of this renderer.private void
fixOverflowRenderer(ParagraphRenderer overflowRenderer)
<T1> T1
getDefaultProperty(int property)
Gets the default property from this entity.protected java.lang.Float
getFirstYLineRecursively()
Gets the first yLine of the nested children recursively.protected java.lang.Float
getLastYLineRecursively()
java.util.List<LineRenderer>
getLines()
Gets the lines which are the result of thelayout(LayoutContext)
.MinMaxWidth
getMinMaxWidth()
Calculates min and max width values for current renderer.IRenderer
getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.LayoutResult
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.void
move(float dxRight, float dyUp)
Moves the renderer subtree by the specified offset.protected ParagraphRenderer[]
split()
java.lang.String
toString()
Returns a string representation of the renderer.private static void
updateParentLines(ParagraphRenderer re)
-
Methods inherited from class com.itextpdf.layout.renderer.BlockRenderer
applyMaxHeight, applyMinHeight, applyRotationLayout, applyVerticalAlignment, applyWidth, beginRotationIfApplied, correctFixedLayout, createRotationTransformInsideOccupiedArea, createSplitAndOverflowRenderers, createSplitRenderer, decreaseLayoutBoxAfterChildPlacement, draw, endRotationIfApplied, fixOccupiedAreaIfOverflowedX, fixOccupiedAreaIfOverflowedY, getOccupiedAreaBBox, getResolvedFont, handleForcedPlacement, processNotFullChildResult, recalculateLayoutBoxBeforeChildLayout, recalculateOccupiedAreaAfterChildLayout, startChildMarginsHandling, stopLayoutingChildrenIfChildResultNotFull
-
Methods inherited from class com.itextpdf.layout.renderer.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, drawBackground, drawBorder, drawPositionedChildren, endElementOpacityApplying, endTransformationIfApplied, getAspectRatio, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getBorders, getChildRenderers, getInnerAreaBBox, getMargins, getModelElement, getOccupiedArea, 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, 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 Detail
-
lines
protected java.util.List<LineRenderer> lines
-
-
Method Detail
-
layout
public LayoutResult 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. if there was enough place to fit the renderer subtree, etc.LayoutResult
can be extended to return custom layout results for custom elements, e.g.TextRenderer
usesTextLayoutResult
as 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.- Specified by:
layout
in interfaceIRenderer
- Overrides:
layout
in classBlockRenderer
- Parameters:
layoutContext
- the description of layout area and any other additional information- Returns:
- result of the layout process
-
directLayout
protected LayoutResult directLayout(LayoutContext layoutContext)
-
getNextRenderer
public IRenderer getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.If a renderer overflows to the next area, iText uses this method to create a renderer for the overflow part. So if one wants to extend
ParagraphRenderer
, one should override this method: otherwise the default method will be used and thus the default rather than the custom renderer will be created.- Returns:
- new renderer instance
-
getDefaultProperty
public <T1> T1 getDefaultProperty(int property)
Gets the default property from this entity.- Specified by:
getDefaultProperty
in interfaceIPropertyContainer
- Overrides:
getDefaultProperty
in classAbstractRenderer
- Type Parameters:
T1
- the return type associated with the property- Parameters:
property
- the property to be retrieved- Returns:
- the default property value. If the default property is not defined,
null
will be returned
-
toString
public java.lang.String toString()
Returns a string representation of the renderer.- Overrides:
toString
in classAbstractRenderer
- Returns:
- a
String
- See Also:
Object.toString()
-
drawChildren
public void drawChildren(DrawContext drawContext)
Performs the drawing operation for allchildren
of this renderer.- Overrides:
drawChildren
in classAbstractRenderer
- Parameters:
drawContext
- the context (canvas, document, etc) of this drawing operation.
-
move
public void move(float dxRight, float dyUp)
Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.- Specified by:
move
in interfaceIRenderer
- Overrides:
move
in classAbstractRenderer
- Parameters:
dxRight
- the x-axis offset in points. Positive value will move the renderer subtree to the right.dyUp
- the y-axis offset in points. Positive value will move the renderer subtree to the top.
-
getLines
public java.util.List<LineRenderer> getLines()
Gets the lines which are the result of thelayout(LayoutContext)
.- Returns:
- paragraph lines, or
null
if layout hasn't been called yet
-
getFirstYLineRecursively
protected java.lang.Float getFirstYLineRecursively()
Description copied from class:AbstractRenderer
Gets 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:
getFirstYLineRecursively
in classAbstractRenderer
- Returns:
- the first yline of the nested children, null if there is no text found
-
getLastYLineRecursively
protected java.lang.Float getLastYLineRecursively()
- Overrides:
getLastYLineRecursively
in classAbstractRenderer
-
createOverflowRenderer
private ParagraphRenderer createOverflowRenderer()
-
createSplitRenderer
private ParagraphRenderer createSplitRenderer()
-
createOverflowRenderer
protected ParagraphRenderer createOverflowRenderer(IRenderer parent)
-
createSplitRenderer
protected ParagraphRenderer createSplitRenderer(IRenderer parent)
-
createOverflowRenderer
protected AbstractRenderer createOverflowRenderer(int layoutResult)
Description copied from class:BlockRenderer
Creates an overflow renderer.- Overrides:
createOverflowRenderer
in classBlockRenderer
- Parameters:
layoutResult
- the result of content layouting- Returns:
- a new
AbstractRenderer
instance
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth()
Description copied from class:BlockRenderer
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidth
in classBlockRenderer
- Returns:
- instance of
MinMaxWidth
-
split
protected ParagraphRenderer[] split()
-
fixOverflowRenderer
private void fixOverflowRenderer(ParagraphRenderer overflowRenderer)
-
alignStaticKids
private void alignStaticKids(LineRenderer renderer, float dxRight)
-
applyTextAlignment
private void applyTextAlignment(TextAlignment textAlignment, LineLayoutResult result, LineRenderer processedRenderer, Rectangle layoutBox, java.util.List<Rectangle> floatRendererAreas, boolean onlyOverflowedFloatsLeft, float lineIndent)
-
updateParentLines
private static void updateParentLines(ParagraphRenderer re)
-
-