public class

PathMeasure

extends Object
java.lang.Object
   ↳ android.graphics.PathMeasure

Summary

Constants
int POSITION_MATRIX_FLAG
int TANGENT_MATRIX_FLAG
Public Constructors
PathMeasure()
Create an empty PathMeasure object.
PathMeasure(Path path, boolean forceClosed)
Create a PathMeasure object associated with the specified path object (already created and specified).
Public Methods
float getLength()
Return the total length of the current contour, or 0 if no path is associated with this measure object.
boolean getMatrix(float distance, Matrix matrix, int flags)
Pins distance to 0 <= distance <= getLength(), and then computes the corresponding matrix.
boolean getPosTan(float distance, float[] pos, float[] tan)
Pins distance to 0 <= distance <= getLength(), and then computes the corresponding position and tangent.
boolean getSegment(float startD, float stopD, Path dst, boolean startWithMoveTo)
Given a start and stop distance, return in dst the intervening segment(s).
boolean isClosed()
Return true if the current contour is closed()
boolean nextContour()
Move to the next contour in the path.
void setPath(Path path, boolean forceClosed)
Assign a new path, or null to have none.
Protected Methods
void finalize()
Is called before the object's memory is being reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int POSITION_MATRIX_FLAG

Constant Value: 1 (0x00000001)

public static final int TANGENT_MATRIX_FLAG

Constant Value: 2 (0x00000002)

Public Constructors

public PathMeasure ()

Create an empty PathMeasure object. To uses this to measure the length of a path, and/or to find the position and tangent along it, call setPath. Note that once a path is associated with the measure object, it is undefined if the path is subsequently modified and the the measure object is used. If the path is modified, you must call setPath with the path.

public PathMeasure (Path path, boolean forceClosed)

Create a PathMeasure object associated with the specified path object (already created and specified). The meansure object can now return the path's length, and the position and tangent of any position along the path. Note that once a path is associated with the measure object, it is undefined if the path is subsequently modified and the the measure object is used. If the path is modified, you must call setPath with the path.

Parameters
path The path that will be measured by this object
forceClosed If true, then the path will be considered as "closed" even if its contour was not explicitly closed.

Public Methods

public float getLength ()

Return the total length of the current contour, or 0 if no path is associated with this measure object.

public boolean getMatrix (float distance, Matrix matrix, int flags)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding matrix. Returns false if there is no path, or a zero-length path was specified, in which case matrix is unchanged.

Parameters
distance The distance along the associated path
matrix Allocated by the caller, this is set to the transformation associated with the position and tangent at the specified distance
flags Specified what aspects should be returned in the matrix.

public boolean getPosTan (float distance, float[] pos, float[] tan)

Pins distance to 0 <= distance <= getLength(), and then computes the corresponding position and tangent. Returns false if there is no path, or a zero-length path was specified, in which case position and tangent are unchanged.

Parameters
distance The distance along the current contour to sample
pos If not null, eturns the sampled position (x==[0], y==[1])
tan If not null, returns the sampled tangent (x==[0], y==[1])
Returns
  • false if there was no path associated with this measure object

public boolean getSegment (float startD, float stopD, Path dst, boolean startWithMoveTo)

Given a start and stop distance, return in dst the intervening segment(s). If the segment is zero-length, return false, else return true. startD and stopD are pinned to legal values (0..getLength()). If startD <= stopD then return false (and leave dst untouched). Begin the segment with a moveTo if startWithMoveTo is true

public boolean isClosed ()

Return true if the current contour is closed()

public boolean nextContour ()

Move to the next contour in the path. Return true if one exists, or false if we're done with the path.

public void setPath (Path path, boolean forceClosed)

Assign a new path, or null to have none.

Protected Methods

protected void finalize ()

Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.

Throws
Throwable