Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.ext.awt.geom
Class PathLength  view PathLength download PathLength.java

java.lang.Object
  extended byorg.apache.batik.ext.awt.geom.PathLength

public class PathLength
extends java.lang.Object

PathLength is a utility class for calculating the length of a path, the location of a point at a particular length along the path, and the angle of the tangent to the path at a given length.

It uses a FlatteningPathIterator to create a flattened version of the Path. This means the values returned are not always exact (in fact, they rarely are), but in most cases they are reasonably accurate.

Version:
$Id: PathLength.java,v 1.8 2005/02/27 02:08:52 deweese Exp $

Nested Class Summary
protected  class PathLength.PathSegment
           
 
Field Summary
private  boolean initialised
          Has this path been flattened?
private  java.awt.Shape path
           
private  float pathLength
          Cached copy of the path length.
private  java.util.Vector segments
          The list of flattened path segments.
 
Constructor Summary
PathLength(java.awt.Shape path)
          Construct a PathLength utility class to operate on the particular Shape.
 
Method Summary
 float angleAtLength(float length)
           
 int findUpperIndex(float length)
           
 java.awt.Shape getPath()
          Get the path to use in calculations.
protected  void initialise()
           
 float lengthOfPath()
          Returns the length of the path used by this PathLength object.
static void main(java.lang.String[] args)
           
 java.awt.geom.Point2D pointAtLength(float length)
          Return the point that is at the given length along the path.
 void setPath(java.awt.Shape v)
          Set the path to use in calculations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

private java.awt.Shape path

segments

private java.util.Vector segments
The list of flattened path segments.


pathLength

private float pathLength
Cached copy of the path length.


initialised

private boolean initialised
Has this path been flattened?

Constructor Detail

PathLength

public PathLength(java.awt.Shape path)
Construct a PathLength utility class to operate on the particular Shape.

Method Detail

getPath

public java.awt.Shape getPath()
Get the path to use in calculations.


setPath

public void setPath(java.awt.Shape v)
Set the path to use in calculations.


lengthOfPath

public float lengthOfPath()
Returns the length of the path used by this PathLength object.


initialise

protected void initialise()

pointAtLength

public java.awt.geom.Point2D pointAtLength(float length)
Return the point that is at the given length along the path.


angleAtLength

public float angleAtLength(float length)

findUpperIndex

public int findUpperIndex(float length)

main

public static void main(java.lang.String[] args)