0

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 ) ).

Community
  • 1
  • 1
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
  • I don't really see any question there. Please be specific about what you want, and what have you tried that didn't work. – Rohit Jain Jan 05 '13 at 19:49
  • It isn't clear what you're asking. Are you saying that you have a square described by a `GeneralPath` and that you want to find it's size? or the square of the length of the `GeneralPath` or...? – Mike Jan 05 '13 at 19:50

2 Answers2

3

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

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Thank you very much for your answer. But this is to much for me :-) My Math Studies with integrals are too long ago. – mcfly soft Jan 05 '13 at 20:15
3

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.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thank you very much. This is a very clever idea ! Got your point and you explained it very good. Thank you. – mcfly soft Jan 05 '13 at 20:17