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) |
protected void |
applyAbsolutePositioningTranslation(boolean reverse) |
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 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 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.
|
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.
|
Rectangle |
getBorderAreaBBox()
Gets the border box of a renderer.
|
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[] |
getMargins()
Returns margins of the renderer
|
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
|
|
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.
|
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 |
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)
Deprecated.
Use
isNotFittingLayoutArea(LayoutArea) instead.
|
protected boolean |
isNotFittingLayoutArea(LayoutArea layoutArea) |
protected boolean |
isPositioned()
Indicates whether the renderer's position is fixed or not.
|
protected boolean |
isRelativePosition() |
void |
move(float dxRight, float dyUp)
Moves the renderer subtree by the specified offset.
|
protected List<Point> |
rectangleToPointsList(Rectangle rect) |
protected Float |
retrieveHeight() |
protected Float |
retrieveUnitValue(float basePercentValue, int property) |
protected Float |
retrieveWidth(float parentBoxWidth) |
protected AbstractRenderer |
setBorders(Border border, int borderNumber) |
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) |
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 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 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
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.
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 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 Float retrieveWidth(float parentBoxWidth)
protected Float retrieveHeight()
protected Float retrieveUnitValue(float basePercentValue, int property)
protected Float getFirstYLineRecursively()
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 false) 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 false) the rectangle.
border box
of the renderer
protected float[] getMargins()
margins
of the renderer
protected float[] getPaddings()
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 applyAbsolutePositioningTranslation(boolean reverse)
protected void applyDestination(PdfDocument document)
protected void applyAction(PdfDocument document)
@Deprecated protected boolean isNotFittingHeight(LayoutArea layoutArea)
isNotFittingLayoutArea(LayoutArea)
instead.
protected boolean isNotFittingLayoutArea(LayoutArea layoutArea)
protected boolean isPositioned()
boolean
protected boolean isFixedLayout()
boolean
protected boolean isRelativePosition()
protected boolean isKeepTogether()
protected void alignChildHorizontally(IRenderer childRenderer, float availableWidth)
protected Border[] getBorders()
Property.BORDER
is used, and if Property.BORDER
is also not set then null
is returned on position of this border
-
setBorders
protected AbstractRenderer setBorders(Border border,
int borderNumber)
-
calculateAbsolutePdfBBox
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. document page or form xObject. This is particularly useful for the cases when element is nested in the rotated element.
- Returns:
-
a
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.
-
calculateBBox
protected Rectangle calculateBBox(List<Point> points)
Calculates bounding box around points.
- Parameters:
-
points
- list of the points calculated bbox will enclose.
- Returns:
-
array of float values which denote left, bottom, right, top lines of bbox in this specific order
-
transformPoints
protected List<Point> transformPoints(List<Point> points,
AffineTransform transform)
Copyright © 1998–2016 iText Group NV. All rights reserved.