Package com.itextpdf.layout.renderer
Class ImageRenderer
java.lang.Object
com.itextpdf.layout.renderer.AbstractRenderer
com.itextpdf.layout.renderer.ImageRenderer
- All Implemented Interfaces:
-
IPropertyContainer,ILeafElementRenderer,IRenderer
- Direct Known Subclasses:
-
SvgImageRenderer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatprotected Floatprotected Floatprotected floatprotected floatprotected floatFields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties -
Constructor Summary
ConstructorsConstructorDescriptionImageRenderer(Image image) Creates an ImageRenderer from its corresponding layout object. -
Method Summary
Modifier and TypeMethodDescriptionprotected RectangleapplyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse) Applies given paddings to the given rectangle.protected ImageRendererautoScale(LayoutArea layoutArea) voiddraw(DrawContext drawContext) Flushes the renderer subtree contents, i.e.floatGets the maximum offset above the base line that thisILeafElementRendererextends to.Gets the border box of a renderer.floatGets the maximum offset below the base line that thisILeafElementRendererextends to.floatGets original height of the image, not the height set byImage.setHeight(float)method.floatGets original width of the image, not the width set byImage.setWidth(float)method.Calculates min and max width values for current renderer.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.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.voidmove(float dxRight, float dyUp) Moves the renderer subtree by the specified offset.Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllProperties, addChild, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateBBox, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createXObject, deleteOwnProperty, deleteProperty, drawBackground, drawBorder, drawChildren, endElementOpacityApplying, endTransformationIfApplied, getBackgroundArea, getBorderRadii, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getMinMaxWidth, getModelElement, getOccupiedArea, getOccupiedAreaBBox, getOwnProperties, getOwnProperty, getPaddings, getParent, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, hasAbsoluteUnitValue, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, rectangleToPointsList, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveResolvedDeclaredHeight, retrieveUnitValue, retrieveUnitValue, retrieveWidth, setBorders, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, toString, transformPoints, updateHeight, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidthMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setPropertyMethods inherited from interface com.itextpdf.layout.renderer.IRenderer
addChild, getChildRenderers, getModelElement, getOccupiedArea, getParent, getProperty, isFlushed, setParent
-
Field Details
-
fixedXPosition
-
fixedYPosition
-
pivotY
protected float pivotY -
deltaX
protected float deltaX -
imageWidth
protected float imageWidth -
imageHeight
protected float imageHeight
-
-
Constructor Details
-
ImageRenderer
Creates an ImageRenderer from its corresponding layout object.- Parameters:
-
image- theImagewhich this object should manage
-
-
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. -
draw
Description copied from class:AbstractRendererFlushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocumentetc.- Specified by:
-
drawin interfaceIRenderer - Overrides:
-
drawin classAbstractRenderer - Parameters:
-
drawContext- contains thePdfDocumentto which the renderer subtree if flushed, thePdfCanvason which the renderer subtree is drawn and other additional parameters needed to perform drawing
-
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.- Specified by:
-
getNextRendererin interfaceIRenderer - Returns:
- new renderer instance
-
getBorderAreaBBox
Description copied from class:AbstractRendererGets the border box of a renderer. This is a box used to draw borders.- Overrides:
-
getBorderAreaBBoxin classAbstractRenderer - Returns:
- border box of a renderer
-
getImageWidth
public float getImageWidth()Gets original width of the image, not the width set byImage.setWidth(float)method.- Returns:
- original image width
-
getImageHeight
public float getImageHeight()Gets original height of the image, not the height set byImage.setHeight(float)method.- Returns:
- original image height
-
applyPaddings
Description copied from class:AbstractRendererApplies given paddings to the given rectangle.- Overrides:
-
applyPaddingsin classAbstractRenderer - Parameters:
-
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 true) the rectangle. - Returns:
-
a
border boxof the renderer
-
move
public void move(float dxRight, float dyUp) Description copied from class:AbstractRendererMoves the renderer subtree by the specified offset. This method affects occupied area of the renderer.- Specified by:
-
movein interfaceIRenderer - Overrides:
-
movein 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.
-
getMinMaxWidth
Description copied from class:AbstractRendererCalculates min and max width values for current renderer.- Overrides:
-
getMinMaxWidthin classAbstractRenderer - Returns:
-
instance of
MinMaxWidth
-
autoScale
-
getAscent
public float getAscent()Description copied from interface:ILeafElementRendererGets the maximum offset above the base line that thisILeafElementRendererextends to.- Specified by:
-
getAscentin interfaceILeafElementRenderer - Returns:
-
the upwards vertical offset of this
ILeafElementRenderer
-
getDescent
public float getDescent()Description copied from interface:ILeafElementRendererGets the maximum offset below the base line that thisILeafElementRendererextends to.- Specified by:
-
getDescentin interfaceILeafElementRenderer - Returns:
-
the downwards vertical offset of this
ILeafElementRenderer
-