Hello,
I need to be able to obtain path measurements, and I was wondering whether
such functionality was in the works for a future version of Java 2D.
Alternately, I might have missed it in the current API, or someone might
have already provided a third-party implementation.
For instance, I would like to be able to know the (approximate) perimeter of
a shape, or the length of a path segment.
Better yet, I would like to be able to specify a distance from the shape's
initial point (or maybe some arbitrary point) and get the point along the
path that is at the given distance, along the path, from the initial point.
Of course, specifying a negative distance would follow the path clockwise
while specifying a positive one would follow it counterclockwise. Also, the
specified distance could exceed the shape's perimeter, in which case it
would be normalized.
Finally, I would like to be able to retrieve the barycenter of a shape, as
well as the point(s) along the path at a given angle from the barycenter, or
maybe from some arbitrary point.
The API could be something like (this is purely a quick and dirty draft):
public interface Shape
{
...
// returns the shape's barycenter
public Point2D getBarycenter();
// returns the shape's perimeter
public double getPerimeter ();
// returns the point's along the shape's perimeter located at the
// specified distance from the shape's initial point
public Point2D find (double distance);
// returns the points along the shape's perimeter located at the
// specified angle from the shape's barycenter
public Point2D [] find (float angle);
// returns the points along the shape's perimeter located at the
// specified angle from the specified point
public Point2D [] find (Point2D center, float angle);
// etc.
...
}
My rationale for such functionality is twofold:
1)it would be very useful to push the capabilities offered to the average
Java 2D programmer (for example, it would make it easy to cleanly connect
the extremity of some open shape to some arbitrary point along the path of
some other shape).
2) the algorithm used to compute curve points and shapes is supposed to be
hidden from the programmer (thus, one should not try to replicate it, even
if this is done almost perfectly).
I will gladly hear comments, corrections, and criticisms of this proposal.
Thank you,
JM
-- Jean-Michel Decombe ([EMAIL PROTECTED])
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".