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
implements Shape
, you can count the number times contains()
is true
for each pixel in the Rectangle
returned by getBounds()
. If need be, you can scale via the createTransformedShape()
method of AffineTransform
.
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