Is there a reason that they decided not to add the contains method (for Path) in Android?
I’m wanting to know what points I have in a Path and hoped it was easier than seen here:
How can I tell if a closed path contains a given point?
Would it be better for me to create an ArrayList and add the integers into the array? (I only check the points once in a control statement) Ie. if(myPath.contains(x,y)
So far my options are:
- Using a Region
- Using an ArrayList
- Extending the Class
- Your suggestion
I’m just looking for the most efficient way I should go about this
I came up against this same problem a little while ago, and after some searching, I found this to be the best solution.
Java has a
Polygonclass with acontains()method that would make things really simple. Unfortunately, thejava.awt.Polygonclass is not supported in Android. However, I was able to find someone who wrote an equivalent class.I don’t think you can get the individual points that make up the path from the Android
Pathclass, so you will have to store the data in a different way.The class uses a Crossing Number algorithm to determine whether or not the point is inside of the given list of points.