public abstract class AbstractRenderer extends Object implements IRenderer
IRenderer
implementations. All default Renderers are subclasses of this default implementation.
Modifier and Type | Field and Description |
---|---|
protected List<IRenderer> |
childRenderers |
static float |
EPS
The maximum difference between Rectangle coordinates to consider rectangles equal
|
protected boolean |
flushed |
static float |
INF
The infinity value which is used while layouting
|
protected boolean |
isLastRendererForModelElement |
protected IPropertyContainer |
modelElement |
protected LayoutArea |
occupiedArea |
protected IRenderer |
parent |
protected List<IRenderer> |
positionedRenderers |
protected Map<Integer,Object> |
properties |
Modifier | Constructor and Description |
---|---|
protected |
AbstractRenderer()
Creates a renderer.
|
protected |
AbstractRenderer(AbstractRenderer other) |
protected |
AbstractRenderer(IElement modelElement)
Creates a renderer for the specified layout element.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAllProperties(Map<Integer,Object> properties) |
void |
addChild(IRenderer renderer)
Adds a child to the current renderer
|
protected void |
alignChildHorizontally(IRenderer childRenderer, float availableWidth)
Deprecated.
|
protected void |
alignChildHorizontally(IRenderer childRenderer, Rectangle currentArea) |
protected void |
applyAbsolutePosition(Rectangle parentRect) |
protected void |
applyAction(PdfDocument document) |
protected Rectangle |
applyBorderBox(Rectangle rect, boolean reverse)
Applies the border box of the renderer on the given rectangle If the border of a certain side is null, the side will remain as it was.
|
protected Rectangle |
applyBorderBox(Rectangle rect, Border[] borders, boolean reverse)
Applies the given border box (borders) on the given rectangle
|
protected void |
applyDestination(PdfDocument document) |
protected void |
applyDestinationsAndAnnotation(DrawContext drawContext) |
protected void |
applyLinkAnnotation(PdfDocument document) |
protected Rectangle |
applyMargins(Rectangle rect, boolean reverse)
Applies margins of the renderer on the given rectangle
|
protected Rectangle |
applyMargins(Rectangle rect, float[] margins, boolean reverse)
Applies given margins on the given rectangle
|
protected Rectangle |
applyPaddings(Rectangle rect, boolean reverse)
Applies paddings of the renderer on the given rectangle
|
protected Rectangle |
applyPaddings(Rectangle rect, float[] paddings, boolean reverse)
Applies given paddings on the given rectangle
|
protected void |
applyRelativePositioningTranslation(boolean reverse) |
protected void |
beginElementOpacityApplying(DrawContext drawContext) |
protected void |
beginTranformationIfApplied(PdfCanvas canvas) |
protected Rectangle |
calculateAbsolutePdfBBox()
Calculates the bounding box of the content in the coordinate system of the pdf entity on which content is placed, e.g.
|
protected Rectangle |
calculateBBox(List<Point> points)
Calculates bounding box around points.
|
protected float[] |
calculateShiftToPositionBBoxOfPointsAt(float left, float top, List<Point> points)
This method calculates the shift needed to be applied to the points in order to position upper and left borders of their bounding box at the given lines.
|
protected boolean |
clipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox) |
protected boolean |
clipBorderArea(DrawContext drawContext, Rectangle outerBorderBox) |
void |
deleteOwnProperty(int property)
Deletes the own property of this entity.
|
void |
deleteProperty(int property)
Deletes property from this very renderer, or in case the property is specified on its model element, the property of the model element is deleted
|
void |
draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e.
|
void |
drawBackground(DrawContext drawContext)
Draws a background layer if it is defined by a key Property.BACKGROUND in either the layout element or this IRenderer itself.
|
void |
drawBorder(DrawContext drawContext)
Performs the drawing operation for the border of this renderer, if defined by any of the Property.BORDER values in either the layout element or this IRenderer itself.
|
void |
drawChildren(DrawContext drawContext)
Performs the drawing operation for all children of this renderer.
|
protected void |
endElementOpacityApplying(DrawContext drawContext) |
protected void |
endTranformationIfApplied(PdfCanvas canvas) |
Rectangle |
getBorderAreaBBox()
Gets the border box of a renderer.
|
protected BorderRadius[] |
getBorderRadii()
Gets border radii of the element in the specified order: top-left, top-right, bottom-right, bottom-left.
|
protected Border[] |
getBorders()
Gets borders of the element in the specified order: top, right, bottom, left.
|
List<IRenderer> |
getChildRenderers()
Gets the child IRenderer s.
|
|
getDefaultProperty(int property)
Gets the default property from this entity.
|
protected Float |
getFirstYLineRecursively()
Gets the first yLine of the nested children recursively.
|
Rectangle |
getInnerAreaBBox() |
protected Float |
getLastYLineRecursively() |
protected float[] |
getMargins()
Returns margins of the renderer
|
protected MinMaxWidth |
getMinMaxWidth() |
protected MinMaxWidth |
getMinMaxWidth(float availableWidth)
Deprecated.
Will be removed in 7.1. Use
getMinMaxWidth() instead.
|
IPropertyContainer |
getModelElement()
Gets the model element associated with this renderer.
|
LayoutArea |
getOccupiedArea()
Gets the resultant occupied area after the last call to the IRenderer.layout(LayoutContext) method.
|
Rectangle |
getOccupiedAreaBBox()
Gets the bounding box that contains all content written to the DrawContext by this IRenderer .
|
protected Map<Integer,Object> |
getOwnProperties() |
|
getOwnProperty(int property)
Gets own property from this entity.
|
protected float[] |
getPaddings()
Returns paddings of the renderer
|
IRenderer |
getParent()
Gets the parent of this IRenderer , if previously set by setParent(IRenderer)
|
|
getProperty(int key)
Gets the property from this entity.
|
|
getProperty(int property, T1 defaultValue)
Gets a property from this entity or one of its hierarchical parents.
|
Boolean |
getPropertyAsBoolean(int property)
Returns a property with a certain key, as a boolean value.
|
Color |
getPropertyAsColor(int property)
Returns a property with a certain key, as a color.
|
Float |
getPropertyAsFloat(int property)
Returns a property with a certain key, as a floating point value.
|
Float |
getPropertyAsFloat(int property, Float defaultValue)
Returns a property with a certain key, as a floating point value.
|
PdfFont |
getPropertyAsFont(int property)
Returns a property with a certain key, as a font object.
|
Integer |
getPropertyAsInteger(int property)
Returns a property with a certain key, as an integer value.
|
TransparentColor |
getPropertyAsTransparentColor(int property)
Returns a property with a certain key, as a TransparentColor .
|
UnitValue |
getPropertyAsUnitValue(int property)
Returns a property with a certain key, as a unit value.
|
protected boolean |
hasAbsoluteUnitValue(int property)
Check if corresponding property has point value.
|
boolean |
hasOwnOrModelProperty(int property)
Checks if this renderer or its model element have the specified property, i.e.
|
boolean |
hasOwnProperty(int property)
Checks if this entity has the specified property, i.e.
|
boolean |
hasProperty(int property)
Checks if this entity has the specified property.
|
List<Rectangle> |
initElementAreas(LayoutArea area)
Gets all rectangles that this IRenderer can draw upon in the given area.
|
protected boolean |
isAbsolutePosition() |
protected boolean |
isFixedLayout()
Indicates whether the renderer's position is fixed or not.
|
boolean |
isFlushed()
Indicates whether this renderer is flushed or not, i.e.
|
protected boolean |
isKeepTogether() |
protected boolean |
isNotFittingHeight(LayoutArea layoutArea) |
protected boolean |
isNotFittingLayoutArea(LayoutArea layoutArea) |
protected boolean |
isNotFittingWidth(LayoutArea layoutArea) |
protected boolean |
isPositioned()
Indicates whether the renderer's position is fixed or not.
|
protected boolean |
isRelativePosition() |
protected boolean |
isStaticLayout() |
void |
move(float dxRight, float dyUp)
Moves the renderer subtree by the specified offset.
|
protected void |
overrideHeightProperties()
Deprecated.
|
protected List<Point> |
rectangleToPointsList(Rectangle rect) |
protected Float |
retrieveHeight()
Retrieves the element's fixed content box height, if it's set.
|
protected Float |
retrieveMaxHeight()
Retrieve element's content box max-ehight, if it's set.
|
protected Float |
retrieveMaxWidth(float parentBoxWidth)
Retrieves element's fixed content box max width, if it's set.
|
protected Float |
retrieveMinHeight()
Retrieves element's content box min-height, if it's set.
|
protected Float |
retrieveMinWidth(float parentBoxWidth)
Retrieves element's fixed content box max width, if it's set.
|
protected Float |
retrieveUnitValue(float baseValue, int property) |
protected Float |
retrieveWidth(float parentBoxWidth)
Retrieves element's fixed content box width, if it's set.
|
protected AbstractRenderer |
setBorders(Border border, int borderNumber) |
protected boolean |
setMinMaxWidthBasedOnFixedWidth(MinMaxWidth minMaxWidth) |
IRenderer |
setParent(IRenderer parent)
Explicitly sets this object as the child of another IRenderer in the renderer hierarchy.
|
void |
setProperty(int property, Object value)
Sets a property for this entity.
|
String |
toString()
Returns a string representation of the renderer.
|
protected List<Point> |
transformPoints(List<Point> points, AffineTransform transform) |
protected void |
updateHeightsOnSplit(boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getNextRenderer, layout
public static final float EPS
Rectangle
coordinates to consider rectangles equal
public static final float INF
protected IPropertyContainer modelElement
protected boolean flushed
protected LayoutArea occupiedArea
protected IRenderer parent
protected boolean isLastRendererForModelElement
protected AbstractRenderer()
protected AbstractRenderer(IElement modelElement)
modelElement
- the layout element that will be drawn by this renderer
protected AbstractRenderer(AbstractRenderer other)
public void addChild(IRenderer renderer)
public IPropertyContainer getModelElement()
getModelElement
in interface IRenderer
container of properties
public List<IRenderer> getChildRenderers()
IRenderer
s.
getChildRenderers
in interface IRenderer
renderers
of this instance
public boolean hasProperty(int property)
IPropertyContainer.hasOwnProperty(int)
, this method can check parent's properties, styles, etc, depending on the origin of the instance
hasProperty
in interface IPropertyContainer
property
- the property to be checked
true
if this instance has given property, false
otherwise
public boolean hasOwnProperty(int property)
hasOwnProperty
in interface IPropertyContainer
property
- the property to be checked
true
if this instance has given own property, false
otherwise
public boolean hasOwnOrModelProperty(int property)
property
- the property to be checked
true
if this instance or its model element have given own property, false
otherwise
public void deleteOwnProperty(int property)
deleteOwnProperty
in interface IPropertyContainer
property
- the property to be deleted
public void deleteProperty(int property)
property
- the property key to be deleted
publicT1 getProperty(int key)
IPropertyContainer.getOwnProperty(int)
, this method can check parent's properties, styles, etc, depending on the origin of the instance
getProperty
in interface IPropertyContainer
T1
- the return type associated with the property
key
- the property to be retrieved
null
will be returned if the property value was not found
publicT1 getOwnProperty(int property)
null
will be returned.
getOwnProperty
in interface IPropertyContainer
T1
- the return type associated with the property
property
- the property to be retrieved
null
will be returned if the property value was not found
publicT1 getProperty(int property, T1 defaultValue)
defaultValue
will be returned.
getProperty
in interface IRenderer
T1
- the return type associated with the property
property
- the property to be retrieved
defaultValue
- a fallback value
public void setProperty(int property, Object value)
setProperty
in interface IPropertyContainer
property
- the property to be set
value
- the value of the property
publicT1 getDefaultProperty(int property)
getDefaultProperty
in interface IPropertyContainer
T1
- the return type associated with the property
property
- the property to be retrieved
null
will be returned
public PdfFont getPropertyAsFont(int property)
property
- an enum value
PdfFont
public Color getPropertyAsColor(int property)
property
- an enum value
Color
public TransparentColor getPropertyAsTransparentColor(int property)
TransparentColor
.
property
- an enum value
TransparentColor
public Float getPropertyAsFloat(int property)
property
- an enum value
Float
public Float getPropertyAsFloat(int property, Float defaultValue)
property
- an enum value
defaultValue
- default value to be returned if property is not found
Float
public Boolean getPropertyAsBoolean(int property)
property
- an enum value
Boolean
public UnitValue getPropertyAsUnitValue(int property)
property
- an enum value
UnitValue
public Integer getPropertyAsInteger(int property)
property
- an enum value
Integer
public String toString()
toString
in class Object
String
Object.toString()
public LayoutArea getOccupiedArea()
IRenderer.layout(LayoutContext)
method.
getOccupiedArea
in interface IRenderer
LayoutArea
instance
public void draw(DrawContext drawContext)
PdfDocument
etc.
draw
in interface IRenderer
drawContext
- contains the PdfDocument
to which the renderer subtree if flushed, the PdfCanvas
on which the renderer subtree is drawn and other additional parameters needed to perform drawing
protected void beginElementOpacityApplying(DrawContext drawContext)
protected void endElementOpacityApplying(DrawContext drawContext)
public void drawBackground(DrawContext drawContext)
Property.BACKGROUND
in either the layout element or this IRenderer
itself.
drawContext
- the context (canvas, document, etc) of this drawing operation.
protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderBox)
protected boolean clipBackgroundArea(DrawContext drawContext, Rectangle outerBorderBox)
public void drawChildren(DrawContext drawContext)
children
of this renderer.
drawContext
- the context (canvas, document, etc) of this drawing operation.
public void drawBorder(DrawContext drawContext)
Property.BORDER
values in either the layout element or this IRenderer
itself.
drawContext
- the context (canvas, document, etc) of this drawing operation.
public boolean isFlushed()
draw(DrawContext)
has already been called.
isFlushed
in interface IRenderer
draw(com.itextpdf.layout.renderer.DrawContext)
public IRenderer setParent(IRenderer parent)
IRenderer
in the renderer hierarchy. Some implementations also use this method internally to create a consistent hierarchy tree.
public IRenderer getParent()
IRenderer
, if previously set by setParent(IRenderer)
public void move(float dxRight, float dyUp)
public List<Rectangle> initElementAreas(LayoutArea area)
IRenderer
can draw upon in the given area.
area
- a physical area on the DrawContext
rectangles
public Rectangle getOccupiedAreaBBox()
DrawContext
by this IRenderer
.
Rectangle
that surrounds the content
public Rectangle getBorderAreaBBox()
public Rectangle getInnerAreaBBox()
protected void applyDestinationsAndAnnotation(DrawContext drawContext)
protected Float retrieveWidth(float parentBoxWidth)
Property.BOX_SIZING
, Property.MIN_WIDTH
, and Property.MAX_WIDTH
properties.
parentBoxWidth
- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.
hasAbsoluteUnitValue(int)
protected Float retrieveMaxWidth(float parentBoxWidth)
Property.BOX_SIZING
and Property.MIN_WIDTH
properties.
parentBoxWidth
- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.
hasAbsoluteUnitValue(int)
protected Float retrieveMinWidth(float parentBoxWidth)
Property.BOX_SIZING
property value.
parentBoxWidth
- width of the parent element content box. If element has relative width, it will be calculated relatively to this parameter.
hasAbsoluteUnitValue(int)
protected Float retrieveHeight()
Property.BOX_SIZING
, Property.MIN_HEIGHT
, and Property.MAX_HEIGHT
properties.
protected Float retrieveMaxHeight()
Property.BOX_SIZING
property value.
protected Float retrieveMinHeight()
Property.BOX_SIZING
property value.
protected Float retrieveUnitValue(float baseValue, int property)
protected Float getFirstYLineRecursively()
protected Float getLastYLineRecursively()
protected Rectangle applyMargins(Rectangle rect, boolean reverse)
rect
- a rectangle margins will be applied on.
reverse
- indicates whether margins will be applied inside (in case of false) or outside (in case of true) the rectangle.
border box
of the renderer
getMargins()
protected Rectangle applyMargins(Rectangle rect, float[] margins, boolean reverse)
rect
- a rectangle margins will be applied on.
margins
- the margins to be applied on the given rectangle
reverse
- indicates whether margins will be applied inside (in case of false) or outside (in case of true) the rectangle.
border box
of the renderer
protected float[] getMargins()
float[]
margins of the renderer
protected float[] getPaddings()
float[]
paddings of the renderer
protected Rectangle applyPaddings(Rectangle rect, boolean reverse)
rect
- a rectangle paddings will be applied on.
reverse
- indicates whether paddings will be applied inside (in case of false) or outside (in case of false) the rectangle.
border box
of the renderer
getPaddings()
protected Rectangle applyPaddings(Rectangle rect, float[] paddings, boolean reverse)
rect
- a rectangle paddings will be applied on.
paddings
- the paddings to be applied on the given rectangle
reverse
- indicates whether paddings will be applied inside (in case of false) or outside (in case of false) the rectangle.
border box
of the renderer
protected Rectangle applyBorderBox(Rectangle rect, boolean reverse)
rect
- a rectangle the border box will be applied on.
reverse
- indicates whether the border box will be applied inside (in case of false) or outside (in case of false) the rectangle.
border box
of the renderer
getBorders()
protected Rectangle applyBorderBox(Rectangle rect, Border[] borders, boolean reverse)
rect
- a rectangle paddings will be applied on.
borders
- the borders
to be applied on the given rectangle
reverse
- indicates whether the border box will be applied inside (in case of false) or outside (in case of false) the rectangle.
border box
of the renderer
protected void applyAbsolutePosition(Rectangle parentRect)
protected void applyRelativePositioningTranslation(boolean reverse)
protected void applyDestination(PdfDocument document)
protected void applyAction(PdfDocument document)
protected void applyLinkAnnotation(PdfDocument document)
@Deprecated protected void overrideHeightProperties()
protected void updateHeightsOnSplit(boolean wasHeightClipped, AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer)
protected MinMaxWidth getMinMaxWidth()
@Deprecated protected MinMaxWidth getMinMaxWidth(float availableWidth)
getMinMaxWidth()
instead.
protected boolean setMinMaxWidthBasedOnFixedWidth(MinMaxWidth minMaxWidth)
protected boolean isNotFittingHeight(LayoutArea layoutArea)
protected boolean isNotFittingWidth(LayoutArea layoutArea)
protected boolean isNotFittingLayoutArea(LayoutArea layoutArea)
protected boolean isPositioned()
boolean
protected boolean isFixedLayout()
boolean
protected boolean isStaticLayout()
protected boolean isRelativePosition()
protected boolean isAbsolutePosition()
protected boolean isKeepTogether()
@Deprecated protected void alignChildHorizontally(IRenderer childRenderer, float availableWidth)
protected void alignChildHorizontally(IRenderer childRenderer, Rectangle currentArea)
protected Border[] getBorders()
Property.BORDER
is used, and if Property.BORDER
is also not set then null
is returned on position of this border
protected BorderRadius[] getBorderRadii()
Property.BORDER_RADIUS
is used, and if Property.BORDER_RADIUS
is also not set then null
is returned on position of this border radius
protected AbstractRenderer setBorders(Border border, int borderNumber)
protected Rectangle calculateAbsolutePdfBBox()
Rectangle
which is a bbox of the content not relative to the parent's layout area but rather to the some pdf entity coordinate system.
protected Rectangle calculateBBox(List<Point> points)
points
- list of the points calculated bbox will enclose.
protected List<Point> transformPoints(List<Point> points, AffineTransform transform)
protected float[] calculateShiftToPositionBBoxOfPointsAt(float left, float top, List<Point> points)
left
- x coordinate at which points bbox left border is to be aligned
top
- y coordinate at which points bbox upper border is to be aligned
points
- the points, which bbox will be aligned at the given position
protected boolean hasAbsoluteUnitValue(int property)
property
- Property
protected void beginTranformationIfApplied(PdfCanvas canvas)
protected void endTranformationIfApplied(PdfCanvas canvas)
Copyright © 1998–2018 iText Group NV. All rights reserved.