java.lang.Object | |
↳ | android.graphics.Path |
The Path class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves. It can be drawn with canvas.drawPath(path, paint), either filled or stroked (based on the paint's Style), or it can be used for clipping or to draw text on a path.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Path.Direction | Specifies how closed shapes (e.g. | ||||||||||
Path.FillType | Enum for the ways a path may be filled. | ||||||||||
Path.Op | The logical operations that can be performed when combining two paths. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create an empty path
| |||||||||||
Create a new path, copying the contents from the src path.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add the specified arc to the path as a new contour.
| |||||||||||
Add a closed circle contour to the path
| |||||||||||
Add a closed oval contour to the path
| |||||||||||
Add a closed oval contour to the path
| |||||||||||
Add a copy of src to the path, offset by (dx,dy)
| |||||||||||
Add a copy of src to the path
| |||||||||||
Add a copy of src to the path, transformed by matrix
| |||||||||||
Add a closed rectangle contour to the path
| |||||||||||
Add a closed rectangle contour to the path
| |||||||||||
Add a closed round-rectangle contour to the path.
| |||||||||||
Add a closed round-rectangle contour to the path
| |||||||||||
Append the specified arc to the path as a new contour.
| |||||||||||
Append the specified arc to the path as a new contour.
| |||||||||||
Close the current contour.
| |||||||||||
Compute the bounds of the control points of the path, and write the
answer into bounds.
| |||||||||||
Add a cubic bezier from the last point, approaching control points
(x1,y1) and (x2,y2), and ending at (x3,y3).
| |||||||||||
Return the path's fill type.
| |||||||||||
Hint to the path to prepare for adding more points.
| |||||||||||
Returns the path's convexity, as defined by the content of the path.
| |||||||||||
Returns true if the path is empty (contains no lines or curves)
| |||||||||||
Returns true if the filltype is one of the INVERSE variants
| |||||||||||
Returns true if the path specifies a rectangle.
| |||||||||||
Add a line from the last point to the specified point (x,y).
| |||||||||||
Set the beginning of the next contour to the point (x,y).
| |||||||||||
Offset the path by (dx,dy), returning true on success
| |||||||||||
Offset the path by (dx,dy), returning true on success
| |||||||||||
Set this path to the result of applying the Op to the two specified paths.
| |||||||||||
Set this path to the result of applying the Op to this path and the specified path.
| |||||||||||
Add a quadratic bezier from the last point, approaching control point
(x1,y1), and ending at (x2,y2).
| |||||||||||
Same as cubicTo, but the coordinates are considered relative to the
current point on this contour.
| |||||||||||
Same as lineTo, but the coordinates are considered relative to the last
point on this contour.
| |||||||||||
Set the beginning of the next contour relative to the last point on the
previous contour.
| |||||||||||
Same as quadTo, but the coordinates are considered relative to the last
point on this contour.
| |||||||||||
Clear any lines and curves from the path, making it empty.
| |||||||||||
Rewinds the path: clears any lines and curves from the path but
keeps the internal data structure for faster reuse.
| |||||||||||
Replace the contents of this with the contents of src.
| |||||||||||
Set the path's fill type.
| |||||||||||
Sets the last point of the path.
| |||||||||||
Toggles the INVERSE state of the filltype
| |||||||||||
Transform the points in this path by matrix, and write the answer
into dst.
| |||||||||||
Transform the points in this path by matrix.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new path, copying the contents from the src path.
src | The path to copy from when initializing the new path |
---|
Add the specified arc to the path as a new contour.
oval | The bounds of oval defining the shape and size of the arc |
---|---|
startAngle | Starting angle (in degrees) where the arc begins |
sweepAngle | Sweep angle (in degrees) measured clockwise |
Add a closed circle contour to the path
x | The x-coordinate of the center of a circle to add to the path |
---|---|
y | The y-coordinate of the center of a circle to add to the path |
radius | The radius of a circle to add to the path |
dir | The direction to wind the circle's contour |
Add a closed oval contour to the path
dir | The direction to wind the oval's contour |
---|
Add a closed oval contour to the path
oval | The bounds of the oval to add as a closed contour to the path |
---|---|
dir | The direction to wind the oval's contour |
Add a copy of src to the path, offset by (dx,dy)
src | The path to add as a new contour |
---|---|
dx | The amount to translate the path in X as it is added |
Add a copy of src to the path
src | The path that is appended to the current path |
---|
Add a copy of src to the path, transformed by matrix
src | The path to add as a new contour |
---|
Add a closed rectangle contour to the path
left | The left side of a rectangle to add to the path |
---|---|
top | The top of a rectangle to add to the path |
right | The right side of a rectangle to add to the path |
bottom | The bottom of a rectangle to add to the path |
dir | The direction to wind the rectangle's contour |
Add a closed rectangle contour to the path
rect | The rectangle to add as a closed contour to the path |
---|---|
dir | The direction to wind the rectangle's contour |
Add a closed round-rectangle contour to the path. Each corner receives two radius values [X, Y]. The corners are ordered top-left, top-right, bottom-right, bottom-left
rect | The bounds of a round-rectangle to add to the path |
---|---|
radii | Array of 8 values, 4 pairs of [X,Y] radii |
dir | The direction to wind the round-rectangle's contour |
Add a closed round-rectangle contour to the path
rect | The bounds of a round-rectangle to add to the path |
---|---|
rx | The x-radius of the rounded corners on the round-rectangle |
ry | The y-radius of the rounded corners on the round-rectangle |
dir | The direction to wind the round-rectangle's contour |
Append the specified arc to the path as a new contour. If the start of the path is different from the path's current last point, then an automatic lineTo() is added to connect the current contour to the start of the arc. However, if the path is empty, then we call moveTo() with the first point of the arc.
oval | The bounds of oval defining shape and size of the arc |
---|---|
startAngle | Starting angle (in degrees) where the arc begins |
sweepAngle | Sweep angle (in degrees) measured clockwise |
Append the specified arc to the path as a new contour. If the start of the path is different from the path's current last point, then an automatic lineTo() is added to connect the current contour to the start of the arc. However, if the path is empty, then we call moveTo() with the first point of the arc. The sweep angle is tread mod 360.
oval | The bounds of oval defining shape and size of the arc |
---|---|
startAngle | Starting angle (in degrees) where the arc begins |
sweepAngle | Sweep angle (in degrees) measured clockwise, treated mod 360. |
forceMoveTo | If true, always begin a new contour with the arc |
Close the current contour. If the current point is not equal to the first point of the contour, a line segment is automatically added.
Compute the bounds of the control points of the path, and write the answer into bounds. If the path contains 0 or 1 points, the bounds is set to (0,0,0,0)
bounds | Returns the computed bounds of the path's control points. |
---|---|
exact | This parameter is no longer used. |
Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
x1 | The x-coordinate of the 1st control point on a cubic curve |
---|---|
y1 | The y-coordinate of the 1st control point on a cubic curve |
x2 | The x-coordinate of the 2nd control point on a cubic curve |
y2 | The y-coordinate of the 2nd control point on a cubic curve |
x3 | The x-coordinate of the end point on a cubic curve |
y3 | The y-coordinate of the end point on a cubic curve |
Return the path's fill type. This defines how "inside" is computed. The default value is WINDING.
Hint to the path to prepare for adding more points. This can allow the path to more efficiently allocate its storage.
extraPtCount | The number of extra points that may be added to this path |
---|
Returns the path's convexity, as defined by the content of the path.
A path is convex if it has a single contour, and only ever curves in a single direction.
This function will calculate the convexity of the path from its control points, and cache the result.
Returns true if the path is empty (contains no lines or curves)
Returns true if the filltype is one of the INVERSE variants
Returns true if the path specifies a rectangle. If so, and if rect is not null, set rect to the bounds of the path. If the path does not specify a rectangle, return false and ignore rect.
rect | If not null, returns the bounds of the path if it specifies a rectangle |
---|
Add a line from the last point to the specified point (x,y). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
x | The x-coordinate of the end of a line |
---|---|
y | The y-coordinate of the end of a line |
Set the beginning of the next contour to the point (x,y).
x | The x-coordinate of the start of a new contour |
---|---|
y | The y-coordinate of the start of a new contour |
Offset the path by (dx,dy), returning true on success
dx | The amount in the X direction to offset the entire path |
---|---|
dy | The amount in the Y direction to offset the entire path |
dst | The translated path is written here. If this is null, then the original path is modified. |
Offset the path by (dx,dy), returning true on success
dx | The amount in the X direction to offset the entire path |
---|---|
dy | The amount in the Y direction to offset the entire path |
Set this path to the result of applying the Op to the two specified paths. The resulting path will be constructed from non-overlapping contours. The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
path1 | The first operand (for difference, the minuend) |
---|---|
path2 | The second operand (for difference, the subtrahend) |
Set this path to the result of applying the Op to this path and the specified path. The resulting path will be constructed from non-overlapping contours. The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
path | The second operand (for difference, the subtrahend) |
---|
Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
x1 | The x-coordinate of the control point on a quadratic curve |
---|---|
y1 | The y-coordinate of the control point on a quadratic curve |
x2 | The x-coordinate of the end point on a quadratic curve |
y2 | The y-coordinate of the end point on a quadratic curve |
Same as cubicTo, but the coordinates are considered relative to the current point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
Same as lineTo, but the coordinates are considered relative to the last point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
dx | The amount to add to the x-coordinate of the previous point on this contour, to specify a line |
---|---|
dy | The amount to add to the y-coordinate of the previous point on this contour, to specify a line |
Set the beginning of the next contour relative to the last point on the previous contour. If there is no previous contour, this is treated the same as moveTo().
dx | The amount to add to the x-coordinate of the end of the previous contour, to specify the start of a new contour |
---|---|
dy | The amount to add to the y-coordinate of the end of the previous contour, to specify the start of a new contour |
Same as quadTo, but the coordinates are considered relative to the last point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
dx1 | The amount to add to the x-coordinate of the last point on this contour, for the control point of a quadratic curve |
---|---|
dy1 | The amount to add to the y-coordinate of the last point on this contour, for the control point of a quadratic curve |
dx2 | The amount to add to the x-coordinate of the last point on this contour, for the end point of a quadratic curve |
dy2 | The amount to add to the y-coordinate of the last point on this contour, for the end point of a quadratic curve |
Clear any lines and curves from the path, making it empty. This does NOT change the fill-type setting.
Rewinds the path: clears any lines and curves from the path but keeps the internal data structure for faster reuse.
Replace the contents of this with the contents of src.
Set the path's fill type. This defines how "inside" is computed.
ft | The new fill type for this path |
---|
Sets the last point of the path.
dx | The new X coordinate for the last point |
---|---|
dy | The new Y coordinate for the last point |
Transform the points in this path by matrix, and write the answer into dst. If dst is null, then the the original path is modified.
matrix | The matrix to apply to the path |
---|---|
dst | The transformed path is written here. If dst is null, then the the original path is modified |
Transform the points in this path by matrix.
matrix | The matrix to apply to the path |
---|
Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.
Note that objects that override finalize
are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit close
method (and implement
Closeable
), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a BigInteger
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
If you must use finalizers, consider at least providing your own
ReferenceQueue
and having your own thread process that queue.
Unlike constructors, finalizers are not automatically chained. You are responsible for
calling super.finalize()
yourself.
Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
Throwable |
---|