I have not come across a library method ... or a pot solution to a problem. I think the reason is that it is fundamentally impossible to solve the problem exactly.
The GeneralPath class inherits the getPathIterator method from Shape2D . If you look at javadoc, you will see that the PathIterator object models the path as a sequence of straight line segments. And the getPathIterator method accepts the flatness parameter specified below:
"is the maximum distance that line segments used to approximate curved segments can deviate from any point in the original curve.
Now, if the shape you are looking for consists of straight line segments, there is a good chance that the path iterator will give you these line segments. But if the figure has curved segments, then the line segments are only an approximation. And, obviously, it is impossible to check whether a point is exactly on the border, if you do not know what the exact border is.
Even assuming that the line segments accurately model the real curve, you still have a problem (except in special cases), most points on a real curve cannot be accurately represented using primitive Java data types (int, double, etc.)). So again, "accuracy" is problematic.
I think the best you can hope for is to check if your point is within a small delta of the border ... and select a flatness value that is less than that delta, iterate the segments of the path line and check the tangent distance of the point from each segment.
Note. If you make flatness very small, you can expect that you will have to test a very large number of line segments. I don't think there is any way around this computational issue, sticking to the GeneralPath API.
If you restrict the problem to regular (i.e., straight) polygons, you just need to iterate the line segments, and for each test, check if the distance from point to line is less than any suitable epsilon.This Wikipedia article gives you the math. Please note that accuracy will still be a problem ...
You do not have an extremely expensive calculation, but calculating the exact square root does not come for free, and you must do this up to N times for an N-sided polygon.
Doing better than that (better than O(N) ) will be difficult. However, if the polygon is fixed, and you are going to test a huge number of points against it, then you can consider using a preliminary calculation of the data structure with four trees to perform the resolution. A preliminary calculation of the quad tree will be expensive, but if N is a fairly large test, then the point will be cheaper. (Approximately O(log(1/epsilon)) in the worst case, not O(N) on average. And the farther from the border the point, the cheaper the answer.)
But, as I said, ATVs will only help in limited situations ...