Package com.itextpdf.kernel.geom
Class Path
- java.lang.Object
-
- com.itextpdf.kernel.geom.Path
-
public class Path extends java.lang.Object
Paths define shapes, trajectories, and regions of all sorts. They shall be used to draw lines, define the shapes of filled areas, and specify boundaries for clipping other graphics. A path shall be composed of straight and curved line segments, which may connect to one another or may be disconnected.
-
-
Field Summary
Fields Modifier and Type Field Description private Point
currentPoint
private static java.lang.String
START_PATH_ERR_MSG
private java.util.List<Subpath>
subpaths
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubpath(Subpath subpath)
Adds the subpath to this path.void
addSubpaths(java.util.List<? extends Subpath> subpaths)
Adds the subpaths to this path.void
closeAllSubpaths()
Closes all subpathes contained in this path.void
closeSubpath()
Closes the current subpath.void
curveFromTo(float x1, float y1, float x3, float y3)
Appends a cubic Bezier curve to the current path.void
curveTo(float x2, float y2, float x3, float y3)
Appends a cubic Bezier curve to the current path.void
curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
Appends a cubic Bezier curve to the current path.Point
getCurrentPoint()
The current point is the trailing endpoint of the segment most recently added to the current path.private Subpath
getLastSubpath()
java.util.List<Subpath>
getSubpaths()
boolean
isEmpty()
Path is empty if it contains no subpaths.void
lineTo(float x, float y)
Appends a straight line segment from the current point to the point(x, y)
.void
moveTo(float x, float y)
Begins a new subpath by moving the current point to coordinates(x, y)
.void
rectangle(float x, float y, float w, float h)
Appends a rectangle to the current path as a complete subpath.void
rectangle(Rectangle rect)
Appends a rectangle to the current path as a complete subpath.java.util.List<java.lang.Integer>
replaceCloseWithLine()
Adds additional line to each closed subpath and makes the subpath unclosed.
-
-
-
Field Detail
-
START_PATH_ERR_MSG
private static final java.lang.String START_PATH_ERR_MSG
- See Also:
- Constant Field Values
-
subpaths
private java.util.List<Subpath> subpaths
-
currentPoint
private Point currentPoint
-
-
Method Detail
-
getSubpaths
public java.util.List<Subpath> getSubpaths()
- Returns:
- A
List
of subpaths forming this path.
-
addSubpath
public void addSubpath(Subpath subpath)
Adds the subpath to this path.- Parameters:
subpath
- The subpath to be added to this path.
-
addSubpaths
public void addSubpaths(java.util.List<? extends Subpath> subpaths)
Adds the subpaths to this path.- Parameters:
subpaths
-List
of subpaths to be added to this path.
-
getCurrentPoint
public Point getCurrentPoint()
The current point is the trailing endpoint of the segment most recently added to the current path.- Returns:
- The current point.
-
moveTo
public void moveTo(float x, float y)
Begins a new subpath by moving the current point to coordinates(x, y)
.- Parameters:
x
- x-coordinate of the new pointy
- y-coordinate of the new point
-
lineTo
public void lineTo(float x, float y)
Appends a straight line segment from the current point to the point(x, y)
.- Parameters:
x
- x-coordinate of the new pointy
- y-coordinate of the new point
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
Appends a cubic Bezier curve to the current path. The curve shall extend from the current point to the point(x3, y3)
.- Parameters:
x1
- x-coordinate of the first control pointy1
- y-coordinate of the first control pointx2
- x-coordinate of the second control pointy2
- y-coordinate of the second control pointx3
- x-coordinate of the third control pointy3
- y-coordinate of the third control point
-
curveTo
public void curveTo(float x2, float y2, float x3, float y3)
Appends a cubic Bezier curve to the current path. The curve shall extend from the current point to the point(x3, y3)
using the current point and(x2, y2)
as intermediate control points. Note that current point is both used as the starting point and a control point- Parameters:
x2
- x-coordinate of the second intermediate control pointy2
- y-coordinate of the second intermediate control pointx3
- x-coordinate of the ending pointy3
- y-coordinate of the ending point
-
curveFromTo
public void curveFromTo(float x1, float y1, float x3, float y3)
Appends a cubic Bezier curve to the current path. The curve shall extend from the current point to the point(x3, y3)
using(x1, y1)
and(x3, y3)
as control points. Note that(x3, y3)
is used both as both a control point and an ending point- Parameters:
x1
- x-coordinate of the first intermediate control pointy1
- y-coordinate of the first intermediate control pointx3
- x-coordinate of the second intermediate control point (and ending point)y3
- y-coordinate of the second intermediate control point (and ending point)
-
rectangle
public void rectangle(Rectangle rect)
Appends a rectangle to the current path as a complete subpath.- Parameters:
rect
- the rectangle to append to the current path
-
rectangle
public void rectangle(float x, float y, float w, float h)
Appends a rectangle to the current path as a complete subpath.- Parameters:
x
- lower left x-coordinate of the rectangley
- lower left y-coordinate of the rectanglew
- width of the rectangleh
- height of the rectangle
-
closeSubpath
public void closeSubpath()
Closes the current subpath.
-
closeAllSubpaths
public void closeAllSubpaths()
Closes all subpathes contained in this path.
-
replaceCloseWithLine
public java.util.List<java.lang.Integer> replaceCloseWithLine()
Adds additional line to each closed subpath and makes the subpath unclosed. The line connects the last and the first points of the subpaths.- Returns:
- Indices of modified subpaths.
-
isEmpty
public boolean isEmpty()
Path is empty if it contains no subpaths.- Returns:
true
in case the path is empty andfalse
otherwise
-
getLastSubpath
private Subpath getLastSubpath()
-
-