public class MeasuredShape extends Objectimplements Serializable
This object can trace arbitrary amounts of itself using the writeShape() methods.
| Modifier and Type | Field and Description |
|---|---|
static float |
DEFAULT_SPACING
This is the increments t goes throw as each shape segment is traversed.
|
| Constructor and Description |
|---|
MeasuredShape(PathIterator
Construct a
MeasuredShape from a
PathIterator using the default spacing.
|
MeasuredShape(PathIterator
Construct a
MeasuredShape from a
PathIterator.
|
MeasuredShape(Shape
Construct a
MeasuredShape from a
Shape, using the default spacing.
|
MeasuredShape(Shape
Construct a
MeasuredShape from a
Shape.
|
| Modifier and Type | Method and Description |
|---|---|
float |
getClosedDistance()
The distance of this shape, assuming that the path is closed.
|
float |
getCommonDistance(MeasuredShape
Returns the length that this shape has in common with the argument.
|
float |
getMoveToX()
Returns the x-value of where this path begins.
|
float |
getMoveToY()
Returns the y-value of where this path begins.
|
float |
getOriginalDistance()
The distance of the shape used to construct this
MeasuredShape.
|
Point2D |
getPoint(float distance, Point2D
Returns the point at a certain distance from the beginning of this shape.
|
GeneralPath |
getShape(float position, float length)
Trace the shape.
|
static MeasuredShape |
getSubpaths(PathIterator
Because a MeasuredShape must be exactly 1 subpath, this method will safely break up a path into separate subpaths and create one MeasuredShape for each.
|
static MeasuredShape |
getSubpaths(PathIterator
Because a MeasuredShape must be exactly 1 subpath, this method will safely break up a path into separate subpaths and create one MeasuredShape for each.
|
static MeasuredShape |
getSubpaths(Shape
Because a MeasuredShape must be exactly 1 subpath, this method will safely break up a path into separate subpaths and create one MeasuredShape for each.
|
static MeasuredShape |
getSubpaths(Shape
Because a MeasuredShape must be exactly 1 subpath, this method will safely break up a path into separate subpaths and create one MeasuredShape for each.
|
float |
getTangentSlope(float distance)
Returns the tangent slope at a certain distance from the beginning of this shape.
|
void |
writeShape(float position, float length, PathWriter
Trace the shape.
|
void |
writeShape(float position, float length, PathWriter
Trace the shape.
|
void |
writeShape(PathWriter
Writes the entire shape
|
void |
writeShapeBackwards(PathWriter
Writes the entire shape backwards
|
public static final float DEFAULT_SPACING
public MeasuredShape(Shapes)
MeasuredShape from a
Shape, using the default spacing.
s - the shape data
IllegalArgumentException - if the shape has more than 1 path.
public MeasuredShape(Shapes, float spacing)
MeasuredShape from a
Shape.
s - the shape data to create
spacing - the value to increment t as each segment is traversed. The default value is .05.
IllegalArgumentException - if the shape has more than 1 path.
public MeasuredShape(PathIteratori)
MeasuredShape from a
PathIterator using the default spacing.
i - the shape data to create
IllegalArgumentException - if the shape has more than 1 path.
public MeasuredShape(PathIteratori, float spacing)
MeasuredShape from a
PathIterator.
i - the shape data to create
spacing - the value to increment t as each segment is traversed. The default value is .05.
IllegalArgumentException - if the shape has more than 1 path.
public static MeasuredShape[] getSubpaths(Shape s)
s - a path, possibly containing multiple subpaths
i
public static MeasuredShape[] getSubpaths(Shape s, float spacing)
s - a path, possibly containing multiple subpaths
spacing - the spacing to be used for each
MeasuredShape
i
public static MeasuredShape[] getSubpaths(PathIterator i)
i - a path, possibly containing multiple subpaths
i
public static MeasuredShape[] getSubpaths(PathIterator i, float spacing)
i - a path, possibly containing multiple subpaths
i
public void writeShape(PathWriterw)
w - the destination to write to
public float getClosedDistance()
getOriginalDistance().
getOriginalDistance()
public float getOriginalDistance()
MeasuredShape.
This will be less than or equal to getClosedDistance().
getClosedDistance()
public void writeShapeBackwards(PathWriterw)
w - the destination to write to
public float getMoveToX()
Because a MeasuredShape can only be one path, there is only possible moveTo().
public float getMoveToY()
Because a MeasuredShape can only be one path, there is only possible moveTo().
public void writeShape(float position,
float length,
PathWriter w)
position - a fraction from zero to one indicating where to start tracing
length - a fraction from negative one to one indicating how much to trace. If this value is negative then the shape will be traced backwards.
w - the destination to write to
public void writeShape(float position,
float length,
PathWriter w,
boolean includeMoveTo)
position - a fraction from zero to one indicating where to start tracing
length - a fraction from negative one to one indicating how much to trace. If this value is negative then the shape will be traced backwards.
w - the destination to write to
includeMoveTo - this controls whether a moveTo is the first thing written to the path. Note setting this to
false means its the caller's responsibility to make sure the path is in the correct position.
public Point2DgetPoint(float distance, Point2D dest)
distance - the distance from the beginning of this shape to measure
dest - the destination to store the result in. (If this is null a new Point2D will be constructed.)
dest if
dest is non-null.
public float getTangentSlope(float distance)
distance - the distance from the beginning of this shape to measure
public float getCommonDistance(MeasuredShapes)
s -
public GeneralPathgetShape(float position, float length)
position - a fraction from zero to one indicating where to start tracing
length - a fraction from negative one to one indicating how much to trace. If this value is negative then the shape will be traced backwards.