Package com.itextpdf.svg.renderers.impl
Class PatternSvgNodeRenderer
- java.lang.Object
-
- com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
-
- com.itextpdf.svg.renderers.impl.AbstractBranchSvgNodeRenderer
-
- com.itextpdf.svg.renderers.impl.PatternSvgNodeRenderer
-
- All Implemented Interfaces:
IBranchSvgNodeRenderer
,INoDrawSvgNodeRenderer
,ISvgNodeRenderer
,ISvgPaintServer
public class PatternSvgNodeRenderer extends AbstractBranchSvgNodeRenderer implements ISvgPaintServer
Implementation for the svg <pattern> tag.
-
-
Field Summary
Fields Modifier and Type Field Description private static double
CONVERT_COEFF
private static org.slf4j.Logger
LOGGER
-
Fields inherited from class com.itextpdf.svg.renderers.impl.AbstractBranchSvgNodeRenderer
VIEWBOX_VALUES_NUMBER
-
Fields inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
attributesAndStyles, doFill, doStroke, partOfClipPath
-
-
Constructor Summary
Constructors Constructor Description PatternSvgNodeRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Rectangle
calculateAppliedViewBox(Rectangle viewBox, double xStep, double yStep)
private Rectangle
calculateOriginalPatternRectangle(SvgDrawContext context, boolean isObjectBoundingBoxInPatternUnits)
Color
createColor(SvgDrawContext context, Rectangle objectBoundingBox, float objectBoundingBoxMargin, float parentOpacity)
Creates theColor
that represents the corresponding paint server for specified object box.private static PdfPattern.Tiling
createColoredTilingPatternInstance(AffineTransform patternAffineTransform, Rectangle bbox, double xStep, double yStep)
ISvgNodeRenderer
createDeepCopy()
Creates a deep copy of this renderer, including it's subtree of childrenprivate PdfPattern.Tiling
createTilingPattern(SvgDrawContext context, Rectangle objectBoundingBox)
private void
drawPatternContent(SvgDrawContext context, PdfPattern.Tiling pattern)
Rectangle
getObjectBoundingBox(SvgDrawContext context)
Calculates the current object bounding box.private AffineTransform
getPatternTransform()
private static AffineTransform
getTransformToUserSpaceOnUse(Rectangle objectBoundingBox)
private boolean
isObjectBoundingBoxInPatternContentUnits()
private boolean
isObjectBoundingBoxInPatternUnits()
private static boolean
isViewBoxInvalid(float[] viewBoxValues)
private static void
setPatternMatrix(PdfPattern.Tiling pattern, AffineTransform affineTransform)
private static boolean
xStepYStepAreValid(double xStep, double yStep)
-
Methods inherited from class com.itextpdf.svg.renderers.impl.AbstractBranchSvgNodeRenderer
addChild, addXObject, applyViewBox, calculateAndApplyViewBox, deepCopyChildren, doDraw, getChildren, getViewBoxValues, postDraw, processAspectRatioPosition, retrieveAlignAndMeet, setPartOfClipPath
-
Methods inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
calculateViewPortTranslation, canConstructViewPort, canElementFill, deepCopyAttributesAndStyles, draw, getAttribute, getAttributeMapCopy, getAttributeOrDefault, getCurrentFontSize, getParent, parseAbsoluteLength, preDraw, setAttribute, setAttributesAndStyles, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.svg.renderers.IBranchSvgNodeRenderer
addChild, getChildren
-
Methods inherited from interface com.itextpdf.svg.renderers.ISvgNodeRenderer
draw, getAttribute, getAttributeMapCopy, getParent, setAttribute, setAttributesAndStyles, setParent
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
CONVERT_COEFF
private static final double CONVERT_COEFF
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDeepCopy
public ISvgNodeRenderer createDeepCopy()
Description copied from interface:ISvgNodeRenderer
Creates a deep copy of this renderer, including it's subtree of children- Specified by:
createDeepCopy
in interfaceISvgNodeRenderer
- Specified by:
createDeepCopy
in classAbstractBranchSvgNodeRenderer
- Returns:
- deep copy of this renderer
-
createColor
public Color createColor(SvgDrawContext context, Rectangle objectBoundingBox, float objectBoundingBoxMargin, float parentOpacity)
Description copied from interface:ISvgPaintServer
Creates theColor
that represents the corresponding paint server for specified object box.- Specified by:
createColor
in interfaceISvgPaintServer
- Parameters:
context
- the current svg draw contextobjectBoundingBox
- the coloring object bounding box without any adjustments (additional stroke width or others)objectBoundingBoxMargin
- the objectBoundingBoxMargin of the object bounding box to be colored (for example - the part of stroke width that exceeds the object bounding box, i.e. the half of stroke width value)parentOpacity
- current parent opacity modifier- Returns:
- the created color
-
getObjectBoundingBox
public Rectangle getObjectBoundingBox(SvgDrawContext context)
Description copied from interface:ISvgNodeRenderer
Calculates the current object bounding box.- Specified by:
getObjectBoundingBox
in interfaceISvgNodeRenderer
- Parameters:
context
- the current context, for instance it contains current viewport and available font data- Returns:
- the
Rectangle
representing the current object's bounding box, or null if bounding box is undefined
-
createTilingPattern
private PdfPattern.Tiling createTilingPattern(SvgDrawContext context, Rectangle objectBoundingBox)
-
calculateAppliedViewBox
private Rectangle calculateAppliedViewBox(Rectangle viewBox, double xStep, double yStep)
-
drawPatternContent
private void drawPatternContent(SvgDrawContext context, PdfPattern.Tiling pattern)
-
calculateOriginalPatternRectangle
private Rectangle calculateOriginalPatternRectangle(SvgDrawContext context, boolean isObjectBoundingBoxInPatternUnits)
-
isObjectBoundingBoxInPatternUnits
private boolean isObjectBoundingBoxInPatternUnits()
-
isObjectBoundingBoxInPatternContentUnits
private boolean isObjectBoundingBoxInPatternContentUnits()
-
createColoredTilingPatternInstance
private static PdfPattern.Tiling createColoredTilingPatternInstance(AffineTransform patternAffineTransform, Rectangle bbox, double xStep, double yStep)
-
setPatternMatrix
private static void setPatternMatrix(PdfPattern.Tiling pattern, AffineTransform affineTransform)
-
getTransformToUserSpaceOnUse
private static AffineTransform getTransformToUserSpaceOnUse(Rectangle objectBoundingBox)
-
xStepYStepAreValid
private static boolean xStepYStepAreValid(double xStep, double yStep)
-
isViewBoxInvalid
private static boolean isViewBoxInvalid(float[] viewBoxValues)
-
getPatternTransform
private AffineTransform getPatternTransform()
-
-