Class AbstractPathShape
- java.lang.Object
-
- com.itextpdf.svg.renderers.path.impl.AbstractPathShape
-
- All Implemented Interfaces:
IPathShape
- Direct Known Subclasses:
CurveTo
,EllipticalCurveTo
,LineTo
,MoveTo
,QuadraticCurveTo
public abstract class AbstractPathShape extends java.lang.Object implements IPathShape
This class handles common behaviour in IPathShape implementations
-
-
Field Summary
Fields Modifier and Type Field Description protected SvgDrawContext
context
protected java.lang.String[]
coordinates
protected IOperatorConverter
copier
private PathSvgNodeRenderer
parent
protected java.util.Map<java.lang.String,java.lang.String>
properties
The properties of this shape.protected boolean
relative
Whether this is a relative operator or not.private AffineTransform
transform
-
Constructor Summary
Constructors Constructor Description AbstractPathShape()
Creates newAbstractPathShape
instance.AbstractPathShape(boolean relative)
Creates newAbstractPathShape
instance.AbstractPathShape(boolean relative, IOperatorConverter copier)
Creates newAbstractPathShape
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) void
applyTransform(double[] points)
protected Point
createPoint(java.lang.String coordX, java.lang.String coordY)
abstract void
draw()
Draws this instruction to a canvas object.void
draw(PdfCanvas canvas)
Draws this instruction to a canvas object.Point
getEndingPoint()
Gets the ending point on the canvas after the path shape has been drawn via theIPathShape.draw(PdfCanvas)
method, in SVG space coordinates.Rectangle
getPathShapeRectangle(Point lastPoint)
Get bounding rectangle of the current path shape.boolean
isRelative()
Returns true when this shape is a relative operator.protected float
parseHorizontalLength(java.lang.String length)
Parse x axis length value.protected float
parseVerticalLength(java.lang.String length)
Parse y axis length value.void
setContext(SvgDrawContext context)
Set svg draw context for this shape.void
setParent(PathSvgNodeRenderer parent)
Set parent path for this shape.void
setTransform(AffineTransform transform)
SetsAffineTransform
to apply before drawing the shape.-
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.path.IPathShape
setCoordinates
-
-
-
-
Field Detail
-
parent
private PathSvgNodeRenderer parent
-
transform
private AffineTransform transform
-
properties
protected java.util.Map<java.lang.String,java.lang.String> properties
The properties of this shape.
-
relative
protected boolean relative
Whether this is a relative operator or not.
-
copier
protected final IOperatorConverter copier
-
coordinates
protected java.lang.String[] coordinates
-
context
protected SvgDrawContext context
-
-
Constructor Detail
-
AbstractPathShape
public AbstractPathShape()
Creates newAbstractPathShape
instance.
-
AbstractPathShape
public AbstractPathShape(boolean relative)
Creates newAbstractPathShape
instance.- Parameters:
relative
- boolean defining whether this is a relative operator
-
AbstractPathShape
public AbstractPathShape(boolean relative, IOperatorConverter copier)
Creates newAbstractPathShape
instance.- Parameters:
relative
- boolean defining whether this is a relative operatorcopier
-IOperatorConverter
copier for converting relative coordinates to absolute coordinates
-
-
Method Detail
-
isRelative
public boolean isRelative()
Description copied from interface:IPathShape
Returns true when this shape is a relative operator. False if it is an absolute operator.- Specified by:
isRelative
in interfaceIPathShape
- Returns:
- true if relative, false if absolute
-
createPoint
protected Point createPoint(java.lang.String coordX, java.lang.String coordY)
- Parameters:
coordX
-x
coordinate of the pointcoordY
-y
coordinate of the point- Returns:
- created
Point
instance
-
getEndingPoint
public Point getEndingPoint()
Description copied from interface:IPathShape
Gets the ending point on the canvas after the path shape has been drawn via theIPathShape.draw(PdfCanvas)
method, in SVG space coordinates.- Specified by:
getEndingPoint
in interfaceIPathShape
- Returns:
- The
Point
representing the final point in the drawn path. If the point does not exist or does not changenull
may be returned.
-
getPathShapeRectangle
public Rectangle getPathShapeRectangle(Point lastPoint)
Get bounding rectangle of the current path shape.- Specified by:
getPathShapeRectangle
in interfaceIPathShape
- Parameters:
lastPoint
- start point for this shape- Returns:
- calculated rectangle
-
draw
public void draw(PdfCanvas canvas)
Description copied from interface:IPathShape
Draws this instruction to a canvas object.Deprecated in favour of
draw()
and later this method should be introduced in this interface, along withsetContext(SvgDrawContext)
method. Since canvas can be got fromSvgDrawContext
thePdfCanvas
parameter is no more needed.- Specified by:
draw
in interfaceIPathShape
- Parameters:
canvas
- to which this instruction is drawn
-
draw
public abstract void draw()
Draws this instruction to a canvas object.
-
setParent
public void setParent(PathSvgNodeRenderer parent)
Set parent path for this shape.- Parameters:
parent
-PathSvgNodeRenderer
instance
-
setContext
public void setContext(SvgDrawContext context)
Set svg draw context for this shape.- Parameters:
context
-SvgDrawContext
instance.
-
setTransform
public void setTransform(AffineTransform transform)
SetsAffineTransform
to apply before drawing the shape.- Parameters:
transform
-AffineTransform
to apply before drawing
-
parseHorizontalLength
protected float parseHorizontalLength(java.lang.String length)
Parse x axis length value.- Parameters:
length
-String
length for parsing- Returns:
- absolute length in points
-
parseVerticalLength
protected float parseVerticalLength(java.lang.String length)
Parse y axis length value.- Parameters:
length
-String
length for parsing- Returns:
- absolute length in points
-
applyTransform
void applyTransform(double[] points)
-
-