Possible Duplicate:
How to calculate the area of a java.awt.geom.Area?
I don't know how to start on this and I hope someone can help ?
I have a closed java.awt.geom.GeneralPath
and I try to measure the square ( area in squarepixel ( point ^ 2
) ).
Because
GeneralPath
implementsShape
, you can count the number timescontains()
istrue
for each pixel in theRectangle
returned bygetBounds()
. If need be, you can scale via thecreateTransformedShape()
method ofAffineTransform
.You could use Green's theorem and do a contour integral to calculate the area. Integrate along the discretized path in a piecewise manner using Gauss quadrature.
This shows you how it works:
http://mathinsight.org/greens_theorem_find_area