Android
android.graphics
public class

android.graphics.PathMeasure

java.lang.Object
android.graphics.PathMeasure

Summary

Constants

      Value  
int  POSITION_MATRIX_FLAG    0x00000001 
int  TANGENT_MATRIX_FLAG    0x00000002 

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()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
Methods inherited from class java.lang.Object

Details

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()

Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Throws

Throwable
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56