Asked • 04/24/19

How to calculate the area of a java.awt.geom.Area?

I am looking for a way to calculate the area, in pixels, of an arbitrary instance of `java.awt.geom.Area`. The background: I have `Shape`s in my applications that may overlap. I want to know how much one `Shape` overlaps another. The `Shape`s may be skewed, rotated, etc. If I had a function `area(Shape)` (or `Area`), I could use the intersection of two `Shape`s like so: double fractionObscured(Shape bottom, Shape top) { Area intersection = new Area(bottom); intersection.intersect(new Area(top)); return area(intersection) / area(bottom); }

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.