Package com.itextpdf.svg.renderers
Class SvgImageRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.ImageRenderer
-
- com.itextpdf.svg.renderers.SvgImageRenderer
-
- All Implemented Interfaces:
IPropertyContainer,ILeafElementRenderer,IRenderer
public class SvgImageRenderer extends ImageRenderer
Represents a renderer for theSvgImagelayout element.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSvgImageRenderer.Areaprivate static classSvgImageRenderer.NullableArea
-
Field Summary
-
Fields inherited from class com.itextpdf.layout.renderer.ImageRenderer
deltaX, fixedXPosition, fixedYPosition, imageHeight, imageWidth, pivotY
-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties
-
-
Constructor Summary
Constructors Constructor Description SvgImageRenderer(SvgImage image)Creates an SvgImageRenderer from its corresponding layout object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalculateRelativeSizedSvgSize(SvgImage svgImage, Rectangle layoutBox)voiddraw(DrawContext drawContext)Flushes the renderer subtree contents, i.e.private SvgImageRenderer.AreainitMissingMetricsAndApplyAspectRatio(java.lang.Float aspectRatio, SvgImageRenderer.NullableArea retrievedArea, SvgImageRenderer.Area area, UnitValue xObjectWidth, UnitValue xObjectHeight)LayoutResultlayout(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.private static booleantryToApplyAspectRatio(SvgImageRenderer.NullableArea retrievedArea, SvgImageRenderer.Area inputArea, SvgImageRenderer.Area resultArea, java.lang.Float aspectRatio)-
Methods inherited from class com.itextpdf.layout.renderer.ImageRenderer
applyPaddings, autoScale, getAscent, getBorderAreaBBox, getDescent, getImageHeight, getImageWidth, getMinMaxWidth, getNextRenderer, move
-
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, updateWidth
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
-
Methods inherited from interface com.itextpdf.layout.renderer.IRenderer
addChild, getChildRenderers, getModelElement, getOccupiedArea, getParent, getProperty, isFlushed, setParent
-
-
-
-
Method Detail
-
layout
public LayoutResult layout(LayoutContext layoutContext)
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.- Specified by:
layoutin interfaceIRenderer- Overrides:
layoutin classImageRenderer- Parameters:
layoutContext- the description of layout area and any other additional information- Returns:
- result of the layout process
-
draw
public void draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocumentetc.- Specified by:
drawin interfaceIRenderer- Overrides:
drawin classImageRenderer- 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
-
calculateRelativeSizedSvgSize
private void calculateRelativeSizedSvgSize(SvgImage svgImage, Rectangle layoutBox)
-
initMissingMetricsAndApplyAspectRatio
private SvgImageRenderer.Area initMissingMetricsAndApplyAspectRatio(java.lang.Float aspectRatio, SvgImageRenderer.NullableArea retrievedArea, SvgImageRenderer.Area area, UnitValue xObjectWidth, UnitValue xObjectHeight)
-
tryToApplyAspectRatio
private static boolean tryToApplyAspectRatio(SvgImageRenderer.NullableArea retrievedArea, SvgImageRenderer.Area inputArea, SvgImageRenderer.Area resultArea, java.lang.Float aspectRatio)
-
-